|
|
| version 1.22, 2002/02/08 07:27:45 | version 1.28, 2002/09/04 14:59:54 |
|---|---|
| Line 2 | Line 2 |
| Parser: sql fconnection decl. | Parser: sql fconnection decl. |
| Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | |
| */ | */ |
| #ifndef PA_SQL_CONNECTION_H | #ifndef PA_SQL_CONNECTION_H |
| #define PA_SQL_CONNECTION_H | #define PA_SQL_CONNECTION_H |
| static const char* IDENT_SQL_CONNECTION_H="$Date$"; | |
| #include "pa_pool.h" | #include "pa_pool.h" |
| #include "pa_sql_driver.h" | #include "pa_sql_driver.h" |
| #include "pa_sql_driver_manager.h" | #include "pa_sql_driver_manager.h" |
| Line 17 | Line 17 |
| // defines | // defines |
| /// @see SQL_Driver_services_impl::_throw | /// @see SQL_Driver_services_impl::_throw |
| #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) \ | #ifdef PA_WITH_SJLJ_EXCEPTIONS |
| if(!fservices || !setjmp(fservices->mark)) { \ | #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) actions |
| actions; \ | #else |
| } else \ | #define SQL_CONNECTION_SERVICED_FUNC_GUARDED(actions) \ |
| fservices->propagate_exception(); | if(!fservices || !setjmp(fservices->mark)) { \ |
| actions; \ | |
| } else \ | |
| fservices->propagate_exception(); | |
| #endif | |
| /// SQL connection. handy wrapper around low level SQL_Driver | /// SQL connection. handy wrapper around low level SQL_Driver |
| class SQL_Connection : public Pooled { | class SQL_Connection : public Pooled { |
| Line 72 public: | Line 76 public: |
| 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, |
| SQL_CONNECTION_SERVICED_FUNC_GUARDED( | const String& source) { |
| fdriver.query(*fservices, fconnection, | try { |
| statement, offset, limit, | SQL_CONNECTION_SERVICED_FUNC_GUARDED( |
| handlers) | fdriver.query(*fservices, fconnection, |
| ); | statement, offset, limit, |
| handlers) | |
| ); | |
| } catch(const Exception& e) { // query problem | |
| // give more specific source [were url] | |
| throw Exception("sql.execute", | |
| &source, | |
| "%s", e.comment()); | |
| } | |
| } | } |
| void mark_to_rollback() { | void mark_to_rollback() { |
| Line 99 private: // closing process | Line 111 private: // closing process |
| /// return to cache | /// return to cache |
| void close() { | void close() { |
| if(marked_to_rollback) | if(marked_to_rollback) { |
| rollback(); | rollback(); |
| else | marked_to_rollback=false; |
| } else | |
| commit(); | commit(); |
| SQL_driver_manager->close_connection(furl, *this); | SQL_driver_manager->close_connection(furl, *this); |