--- parser3/src/include/pa_sql_connection.h 2001/09/26 10:32:25 1.13 +++ parser3/src/include/pa_sql_connection.h 2001/10/29 17:34:24 1.16 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_sql_connection.h,v 1.13 2001/09/26 10:32:25 parser Exp $ + $Id: pa_sql_connection.h,v 1.16 2001/10/29 17:34:24 paf Exp $ */ #ifndef PA_SQL_CONNECTION_H @@ -15,7 +15,16 @@ #include "pa_sql_driver.h" #include "pa_sql_driver_manager.h" -/// SQL fconnection. handy wrapper around low level SQL_Driver +// defines + +/// @see SQL_Driver_services_impl::_throw +#define SQL_CONNECTION_FUNC_GUARDED(actions) \ + if(!fservices || !setjmp(fservices->mark)) { \ + actions; \ + } else \ + fservices->propagate_exception(); + +/// SQL connection. handy wrapper around low level SQL_Driver class SQL_Connection : public Pooled { public: @@ -43,22 +52,44 @@ public: bool connected() { return fconnection!=0; } void connect(char *used_only_in_connect_url_cstr) { - fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection); + SQL_CONNECTION_FUNC_GUARDED( + fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection) + ); + } + void disconnect() { + fdriver.disconnect(fconnection); fconnection=0; + } + void commit() { + SQL_CONNECTION_FUNC_GUARDED( + fdriver.commit(*fservices, fconnection) + ); + } + void rollback() { + SQL_CONNECTION_FUNC_GUARDED( + fdriver.rollback(*fservices, fconnection) + ); + } + bool ping() { + SQL_CONNECTION_FUNC_GUARDED( + return fdriver.ping(*fservices, fconnection) + ); + return 0; // never reached } - void disconnect() { fdriver.disconnect(fconnection); fconnection=0; } - void commit() { fdriver.commit(*fservices, fconnection); } - void rollback() { fdriver.rollback(*fservices, fconnection); } - bool ping() { return fdriver.ping(*fservices, fconnection); } uint quote(char *to, const char *from, unsigned int length) { - return fdriver.quote(*fservices, fconnection, to, from, length); + SQL_CONNECTION_FUNC_GUARDED( + return fdriver.quote(*fservices, fconnection, to, from, length) + ); + return 0; // never reached } void query( const char *statement, unsigned long offset, unsigned long limit, SQL_Driver_query_event_handlers& handlers) { - fdriver.query(*fservices, fconnection, - statement, offset, limit, - handlers); + SQL_CONNECTION_FUNC_GUARDED( + fdriver.query(*fservices, fconnection, + statement, offset, limit, + handlers) + ); }