--- sql/pgsql/parser3pgsql.C 2008/12/18 01:45:03 1.32 +++ sql/pgsql/parser3pgsql.C 2008/12/21 00:14:25 1.33 @@ -7,7 +7,7 @@ 2007.10.25 using PgSQL 8.1.5 */ -static const char *RCSId="$Id: parser3pgsql.C,v 1.32 2008/12/18 01:45:03 misha Exp $"; +static const char *RCSId="$Id: parser3pgsql.C,v 1.33 2008/12/21 00:14:25 misha Exp $"; #include "config_includes.h" @@ -126,7 +126,7 @@ public: charset=value& // transcode by server with 'SET CLIENT_ENCODING=value' datestyle=value& // 'SET DATESTYLE=value' available values are: ISO|SQL|Postgres|European|US|German [default=ISO] autocommit=1& // each transaction is commited automatically (default) - WithoutDefaultTransaction=0 // 1 -- disable auto commit, 'BEGIN TRAN' at connection start and COMMIT/ROLLBACK at the end [can't be used together with autocommit option] + WithoutDefaultTransaction=0 // 1 -- disable any BEGIN TRAN/COMMIT/ROLLBACK [can NOT be used with autocommit option] */ void connect( char* url, @@ -206,7 +206,7 @@ public: _execute_cmd(connection, statement); } - _begin_transaction(connection); + _transaction_begin(connection); } void disconnect(void *aconnection){ @@ -217,18 +217,14 @@ public: void commit(void *aconnection){ Connection& connection=*static_cast(aconnection); - if(!connection.without_default_transactions){ - _execute_cmd(connection, "COMMIT"); - } - _begin_transaction(connection); + _transaction_commit(connection); + _transaction_begin(connection); } void rollback(void *aconnection){ Connection& connection=*static_cast(aconnection); - if(!connection.without_default_transactions){ - _execute_cmd(connection, "ROLLBACK"); - } - _begin_transaction(connection); + _transaction_rollback(connection); + _transaction_begin(connection); } bool ping(void *aconnection) { @@ -287,13 +283,16 @@ public: if(!res) throwPQerror; + bool failed=false; + SQL_Error sql_error; + switch(PQresultStatus(res)) { case PGRES_EMPTY_QUERY: PQclear_throw("no query"); break; case PGRES_COMMAND_OK: // empty result: insert|delete|update|... - PQclear(res); - return; + goto cleanup; + break; case PGRES_TUPLES_OK: break; default: @@ -301,18 +300,16 @@ public: break; } - int column_count=PQnfields(res); - if(!column_count) - PQclear_throw("result contains no columns"); - - bool failed=false; - SQL_Error sql_error; #define CHECK(afailed) \ if(afailed) { \ failed=true; \ goto cleanup; \ } + int column_count=PQnfields(res); + if(!column_count) + PQclear_throw("result contains no columns"); + if(column_count>MAX_COLS) column_count=MAX_COLS; @@ -320,8 +317,6 @@ public: bool transcode_column[MAX_COLS]; for(int i=0; i