--- parser3/src/include/pa_sql_connection.h 2003/03/20 08:11:13 1.30.2.7.2.2 +++ parser3/src/include/pa_sql_connection.h 2003/12/10 14:54:53 1.35 @@ -8,7 +8,7 @@ #ifndef PA_SQL_CONNECTION_H #define PA_SQL_CONNECTION_H -static const char* IDENT_SQL_CONNECTION_H="$Date: 2003/03/20 08:11:13 $"; +static const char * const IDENT_SQL_CONNECTION_H="$Date: 2003/12/10 14:54:53 $"; #include "pa_sql_driver.h" @@ -18,9 +18,12 @@ static const char* IDENT_SQL_CONNECTION_ /// @see SQL_Driver_services_impl::_throw #ifdef PA_WITH_SJLJ_EXCEPTIONS - #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) actions + #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) \ + use(); \ + actions #else #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) \ + use(); \ if(!setjmp(fservices.mark)) { \ actions; \ } else \ @@ -29,16 +32,16 @@ static const char* IDENT_SQL_CONNECTION_ /// SQL_Driver_services Pooled implementation class SQL_Driver_services_impl: public SQL_Driver_services { - Pool *fpool; - const String& furl; + const String* furl; Exception fexception; public: - SQL_Driver_services_impl(): fpool(0), furl(0) {} - void set_pool_and_url(Pool *const String& aurl) { fpool=apool; furl=aurl;} + SQL_Driver_services_impl(): furl(0) {} + void set_url(const String& aurl) { furl=&aurl;} + const String& url_without_login() const; - override void *malloc(size_t size) { return fpool->malloc(size); } - override void *calloc(size_t size) { return fpool->calloc(size); } - override void *realloc(void *ptr, size_t size) { return fpool->realloc(ptr, size); } + override void *malloc(size_t size) { return pa_malloc(size); } + override void *malloc_atomic(size_t size) { return pa_malloc_atomic(size); } + override void *realloc(void *ptr, size_t size) { return pa_realloc(ptr, size); } /** normally we can't 'throw' from dynamic library, so @@ -58,8 +61,8 @@ public: #else fexception= #endif - Exception(aexception.type(), - url_without_login(), + Exception(aexception.type(), + &url_without_login(), aexception.comment()); #ifndef PA_WITH_SJLJ_EXCEPTIONS @@ -71,9 +74,6 @@ public: throw fexception; #endif } - -private: - const String& url_without_login() const; }; /// SQL connection. handy wrapper around low level SQL_Driver @@ -94,14 +94,19 @@ public: time_used(0), marked_to_rollback(false) { } + + SQL_Driver_services_impl& services() { return fservices; } const String& get_url() { return furl; } - void set_pool() { - fservices.set_pool_and_url(pool?furl:0); + void set_url() { + fservices.set_url(furl); + } + void use() { + time_used=time(0); // they started to use at this time } bool expired(time_t older_dies) { - return /*!freferences && */time_used