|
|
| version 1.41, 2008/06/26 09:41:43 | version 1.45, 2019/09/11 15:26:09 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: sql fconnection decl. | Parser: sql fconnection decl. |
| Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| #ifndef PA_SQL_CONNECTION_H | #ifndef PA_SQL_CONNECTION_H |
| #define PA_SQL_CONNECTION_H | #define PA_SQL_CONNECTION_H |
| static const char * const IDENT_SQL_CONNECTION_H="$Date$"; | #define IDENT_PA_SQL_CONNECTION_H "$Id$" |
| #include "pa_sql_driver.h" | #include "pa_sql_driver.h" |
| Line 64 public: | Line 64 public: |
| one can simply 'throw' from dynamic library. | one can simply 'throw' from dynamic library. |
| [sad story: one can not longjump/throw due to some bug in gcc as of 3.2.1 version] | [sad story: one can not longjump/throw due to some bug in gcc as of 3.2.1 version] |
| */ | */ |
| override void _throw(const SQL_Error& aexception) { | override void _throw(const SQL_Error& aexception) { |
| // converting SQL_exception to parser Exception | // converting SQL_exception to parser Exception |
| // hiding passwords and addresses from accidental show [imagine user forgot @exception] | // hiding passwords and addresses from accidental show [imagine user forgot @exception] |
| #ifdef PA_WITH_SJLJ_EXCEPTIONS | #ifdef PA_WITH_SJLJ_EXCEPTIONS |
| Line 72 public: | Line 72 public: |
| #else | #else |
| fexception= | fexception= |
| #endif | #endif |
| Exception(aexception.type(), | Exception(aexception.type() ? aexception.type() : "sql.connect", &url_without_login(), aexception.comment()); |
| &url_without_login(), | |
| aexception.comment()); | |
| #ifndef PA_WITH_SJLJ_EXCEPTIONS | #ifndef PA_WITH_SJLJ_EXCEPTIONS |
| longjmp(mark, 1); | longjmp(mark, 1); |
| #endif | #endif |
| } | } |
| virtual void propagate_exception() { | virtual void propagate_exception() { |
| #ifndef PA_WITH_SJLJ_EXCEPTIONS | #ifndef PA_WITH_SJLJ_EXCEPTIONS |
| throw fexception; | throw fexception; |
| Line 148 public: | Line 147 public: |
| const String& source) { | const String& source) { |
| try { | try { |
| SQL_CONNECTION_SERVICED_FUNC_GUARDED( | SQL_CONNECTION_SERVICED_FUNC_GUARDED( |
| fdriver.query(fconnection, | fdriver.query(fconnection, statement, placeholders_count, placeholders, offset, limit, handlers) |
| statement, | ); |
| placeholders_count, placeholders, | |
| offset, limit, | |
| handlers) | |
| ); | |
| } catch(const Exception& e) { // query problem | } catch(const Exception& e) { // query problem |
| 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] | // show query instead of connect string |
| throw Exception("sql.execute", | throw Exception("sql.execute", &source, "%s", e.comment()); |
| &source, | |
| "%s", e.comment()); | |
| } else | } else |
| rethrow; | rethrow; |
| } | } |