--- parser3/src/main/pa_sql_driver_manager.C 2003/01/27 16:19:11 1.69.2.2 +++ parser3/src/main/pa_sql_driver_manager.C 2003/04/11 15:00:05 1.70 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/01/27 16:19:11 $"; +static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/04/11 15:00:05 $"; #include "pa_sql_driver_manager.h" #include "ltdl.h" @@ -13,12 +13,13 @@ static const char* IDENT_SQL_DRIVER_MANA #include "pa_exception.h" #include "pa_common.h" #include "pa_threads.h" +#include "pa_stack.h" #include "pa_vhash.h" #include "pa_vtable.h" // globals -SQL_Driver_manager SQL_driver_manager; +SQL_Driver_manager *SQL_driver_manager; // consts @@ -27,7 +28,7 @@ const int CHECK_EXPIRED_CONNECTIONS_SECO // helpers -ConstStringPtr url_without_login(Pool& pool, ConstStringPtr url) { +const String& url_without_login(Pool& pool, const String& url) { String& result=*new(pool) String(pool); result << url.mid(0, url.pos(":")) << "://****"; @@ -41,7 +42,7 @@ ConstStringPtr url_without_login(Pool& p /// SQL_Driver_services Pooled implementation class SQL_Driver_services_impl : public SQL_Driver_services, public Pooled { public: - SQL_Driver_services_impl(Pool& apool, ConstStringPtr aurl) : Pooled(apool), + SQL_Driver_services_impl(Pool& apool, const String& aurl) : Pooled(apool), furl(aurl) { } @@ -82,7 +83,7 @@ public: } private: - ConstStringPtr furl; + const String& furl; Exception fexception; }; @@ -103,8 +104,10 @@ static void expire_connections(const Has // SQL_Driver_manager -SQL_Driver_manager::SQL_Driver_manager(): - prev_expiration_pass_time(0) { +SQL_Driver_manager::SQL_Driver_manager(Pool& apool) : Cache_manager(apool), + driver_cache(apool), + connection_cache(apool), + prev_expiration_pass_time(0) { } SQL_Driver_manager::~SQL_Driver_manager() { @@ -113,8 +116,8 @@ SQL_Driver_manager::~SQL_Driver_manager( } /// @param request_url protocol://[driver-dependent] -SQL_ConnectionPtr SQL_Driver_manager::get_connection(ConstStringPtr request_url, - ConstStringPtr request_origin, +SQL_Connection_ptr SQL_Driver_manager::get_connection(const String& request_url, + const String& request_origin, Table *protocol2driver_and_client) { Pool& pool=request_origin.pool(); // request pool @@ -171,7 +174,8 @@ SQL_ConnectionPtr SQL_Driver_manager::ge // no cached const String *library=0; const String *dlopen_file_spec=0; - if(protocol2driver_and_client->locate(0, global_protocol)) { + Table::Action_options options; + if(protocol2driver_and_client->locate(0, global_protocol, options)) { if(!(library=protocol2driver_and_client->item(1)) || library->size()==0) throw Exception("parser.runtime", protocol2driver_and_client->origin_string(), @@ -242,10 +246,10 @@ SQL_ConnectionPtr SQL_Driver_manager::ge if(!connection->connected()) connection->connect(request_url_cstr); // return autoclosing object for it - return SQL_ConnectionPtr(connection); + return SQL_Connection_ptr(connection); } -void SQL_Driver_manager::close_connection(ConstStringPtr url, +void SQL_Driver_manager::close_connection(const String& url, SQL_Connection& connection) { // deassociate from services[request] connection.set_services(0); @@ -255,13 +259,13 @@ void SQL_Driver_manager::close_connectio // driver cache -SQL_Driver *SQL_Driver_manager::get_driver_from_cache(ConstStringPtr protocol) { +SQL_Driver *SQL_Driver_manager::get_driver_from_cache(const String& protocol) { SYNCHRONIZED; return static_cast(driver_cache.get(protocol)); } -void SQL_Driver_manager::put_driver_to_cache(ConstStringPtr protocol, +void SQL_Driver_manager::put_driver_to_cache(const String& protocol, SQL_Driver& driver) { SYNCHRONIZED; @@ -270,7 +274,7 @@ void SQL_Driver_manager::put_driver_to_c // connection cache /// @todo get rid of memory spending Stack [zeros deep inside got accumulated] -SQL_Connection *SQL_Driver_manager::get_connection_from_cache(ConstStringPtr url) { +SQL_Connection *SQL_Driver_manager::get_connection_from_cache(const String& url) { SYNCHRONIZED; if(Stack *connections=static_cast(connection_cache.get(url))) @@ -283,7 +287,7 @@ SQL_Connection *SQL_Driver_manager::get_ return 0; } -void SQL_Driver_manager::put_connection_to_cache(ConstStringPtr url, +void SQL_Driver_manager::put_connection_to_cache(const String& url, SQL_Connection& connection) { SYNCHRONIZED; @@ -333,7 +337,7 @@ static void add_connections_to_status_ca for(int countdown=stack.top_index(); countdown-->=0; ) add_connection_to_status_cache_table(iter.next(), info); } -ValuePtr SQL_Driver_manager::get_status(Pool& pool, ConstStringPtr source) { +Value& SQL_Driver_manager::get_status(Pool& pool, const String *source) { VHash& result=*new(pool) VHash(pool); // cache