|
|
| version 1.30.2.7.2.2, 2003/03/20 08:11:13 | version 1.30.2.7.2.8, 2003/07/23 08:19:21 |
|---|---|
| Line 29 static const char* IDENT_SQL_CONNECTION_ | Line 29 static const char* IDENT_SQL_CONNECTION_ |
| /// SQL_Driver_services Pooled implementation | /// SQL_Driver_services Pooled implementation |
| class SQL_Driver_services_impl: public SQL_Driver_services { | class SQL_Driver_services_impl: public SQL_Driver_services { |
| Pool *fpool; | const String* furl; |
| const String& furl; | |
| Exception fexception; | Exception fexception; |
| public: | public: |
| SQL_Driver_services_impl(): fpool(0), furl(0) {} | SQL_Driver_services_impl(): furl(0) {} |
| void set_pool_and_url(Pool *const String& aurl) { fpool=apool; furl=aurl;} | void set_url(const String& aurl) { furl=&aurl;} |
| override void *malloc(size_t size) { return fpool->malloc(size); } | override void *malloc(size_t size) { return pa_malloc(size); } |
| override void *calloc(size_t size) { return fpool->calloc(size); } | override void *malloc_atomic(size_t size) { return pa_malloc_atomic(size); } |
| override void *realloc(void *ptr, size_t size) { return fpool->realloc(ptr, size); } | override void *realloc(void *ptr, size_t size) { return pa_realloc(ptr, size); } |
| /** | /** |
| normally we can't 'throw' from dynamic library, so | normally we can't 'throw' from dynamic library, so |
| Line 58 public: | Line 57 public: |
| #else | #else |
| fexception= | fexception= |
| #endif | #endif |
| Exception(aexception.type(), | Exception(aexception.type(), |
| url_without_login(), | &url_without_login(), |
| aexception.comment()); | aexception.comment()); |
| #ifndef PA_WITH_SJLJ_EXCEPTIONS | #ifndef PA_WITH_SJLJ_EXCEPTIONS |
| Line 97 public: | Line 96 public: |
| const String& get_url() { return furl; } | const String& get_url() { return furl; } |
| void set_pool() { | void set_url() { |
| fservices.set_pool_and_url(pool?furl:0); | fservices.set_url(furl); |
| } | |
| void use() { | |
| time_used=time(0); // they started to use at this time | |
| } | } |
| bool expired(time_t older_dies) { | bool expired(time_t older_dies) { |
| return /*!freferences && */time_used<older_dies; | return /*!freferences && */time_used<older_dies; |
| Line 120 public: | Line 122 public: |
| ); | ); |
| return 0; // never reached | return 0; // never reached |
| } | } |
| uint quote(char *to, const char* from, unsigned int length) { | const char* quote(const char* str, unsigned int length) { |
| SQL_CONNECTION_SERVICED_FUNC_GUARDED( | SQL_CONNECTION_SERVICED_FUNC_GUARDED( |
| return fdriver.quote(fservices, fconnection, to, from, length) | return fdriver.quote(fservices, fconnection, str, length) |
| ); | ); |
| return 0; // never reached | // return 0; // never reached |
| } | } |
| void query( | void query( |
| const char* statement, unsigned long offset, unsigned long limit, | const char* statement, unsigned long offset, unsigned long limit, |
| SQL_Driver_query_event_handlers& handlers, | SQL_Driver_query_event_handlers& handlers, |
| const String* source) { | const String& source) { |
| try { | try { |
| SQL_CONNECTION_SERVICED_FUNC_GUARDED( | SQL_CONNECTION_SERVICED_FUNC_GUARDED( |
| fdriver.query(fservices, fconnection, | fdriver.query(fservices, fconnection, |
| Line 141 public: | Line 143 public: |
| if(strcmp(e.type(), "sql.connect")==0) { // if it is _throw exception, | if(strcmp(e.type(), "sql.connect")==0) { // if it is _throw exception, |
| // give more specific source [were url] | // give more specific source [were url] |
| throw Exception("sql.execute", | throw Exception("sql.execute", |
| source, | &source, |
| "%s", e.comment()); | "%s", e.comment()); |
| } else | } else |
| rethrow; | rethrow; |
| } | } |
| } | } |
| void mark_to_rollback() { | |
| marked_to_rollback=true; | |
| } | |
| private: // closing process | |
| void commit() { | void commit() { |
| SQL_CONNECTION_SERVICED_FUNC_GUARDED( | SQL_CONNECTION_SERVICED_FUNC_GUARDED( |
| fdriver.commit(fservices, fconnection) | fdriver.commit(fservices, fconnection) |
| Line 173 private: // closing process | Line 169 private: // closing process |
| } else | } else |
| commit(); | commit(); |
| SQL_driver_manager.close_connection(furl, SQL_ConnectionPtr(this)); | SQL_driver_manager.close_connection(furl, this); |
| } | } |
| }; | }; |