patch: recognize transaction

patch: recognize transaction

am 12.01.2006 15:17:45 von Ludek Finstrle

--t0UkRYy7tHLRMCai
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

I have changed the transaction recognition in LIBPQ_execute_query and
I add handling of START TRANSACTION command. Patch attached.

Please review and comment

Luf

--t0UkRYy7tHLRMCai
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="psqlodbc-libpq_exec+start_trans.diff"

diff -c psqlodbc.orig\connection.c psqlodbc\connection.c
*** psqlodbc.orig\connection.c Sun Jan 08 12:12:01 2006
--- psqlodbc\connection.c Thu Jan 12 14:53:34 2006
***************
*** 1836,1873 ****
return qres;
}

! if (strnicmp(query, "BEGIN", 5) == 0)
! {
! CC_set_in_trans(self);
! }
! else if (strnicmp(query, "COMMIT", 6) == 0)
! CC_on_commit(self);
! else if (strnicmp(query, "ROLLBACK", 8) == 0)
{
! /*
! The method of ROLLBACK an original form ....
! ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] savepoint_name
! */
! if (PG_VERSION_LT(self, 8.0) || !(contains_token(query, " TO ")))
CC_on_abort(self, NO_TRANS);
- }
- else if (strnicmp(query, "END", 3) == 0)
- CC_on_commit(self);
- else if (strnicmp(query, "ABORT", 5) == 0)
- CC_on_abort(self, NO_TRANS);
- else
- {
- if (PQcmdTuples(pgres)[0])
- qres->recent_processed_row_count = atoi(PQcmdTuples(pgres));
- else if (self->connInfo.drivers.use_declarefetch)
- qres->recent_processed_row_count = -1;
else
! qres->recent_processed_row_count = PQntuples(pgres);
! mylog("LIBPQ_execute_query: recent_processed_row_count = %i\n",qres->recent_processed_row_count);
! }
!
! if( (PQresultStatus(pgres) == PGRES_COMMAND_OK) )
! {
mylog("The query was executed successfully and the query did not return any result \n");
PQclear(pgres);
return qres;
--- 1798,1830 ----
return qres;
}

! if( (PQresultStatus(pgres) == PGRES_COMMAND_OK) )
{
! if ((strnicmp(query, "BEGIN", 5) == 0) ||
! (strnicmp(query, "START TRANSACTION", 17) == 0))
! CC_set_in_trans(self);
! else if ((strnicmp(query, "COMMIT", 6) == 0) ||
! (strnicmp(query, "END", 3) == 0))
! CC_on_commit(self);
! else if (strnicmp(query, "ROLLBACK", 8) == 0)
! {
! /*
! The method of ROLLBACK an original form ....
! ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] savepoint_name
! */
! if (PG_VERSION_LT(self, 8.0) || !(contains_token(query, " TO ")))
! CC_on_abort(self, NO_TRANS);
! }
! else if (strnicmp(query, "ABORT", 5) == 0)
CC_on_abort(self, NO_TRANS);
else
! {
! if (PQcmdTuples(pgres)[0])
! qres->recent_processed_row_count = atoi(PQcmdTuples(pgres));
! else
! qres->recent_processed_row_count = -1;
! mylog("LIBPQ_execute_query: recent_processed_row_count = %i\n",qres->recent_processed_row_count);
! }
mylog("The query was executed successfully and the query did not return any result \n");
PQclear(pgres);
return qres;
***************
*** 1892,1897 ****
--- 1849,1862 ----

mylog("LIBPQ_execute_query: rest types ...\n");

+ if (PQcmdTuples(pgres)[0])
+ qres->recent_processed_row_count = atoi(PQcmdTuples(pgres));
+ else if (self->connInfo.drivers.use_declarefetch)
+ qres->recent_processed_row_count = -1;
+ else
+ qres->recent_processed_row_count = PQntuples(pgres);
+ mylog("LIBPQ_execute_query: recent_processed_row_count = %i\n",qres->recent_processed_row_count);
+
qres=CC_mapping(self,pgres,qres);
QR_set_command(qres, query);
PQclear(pgres);

--t0UkRYy7tHLRMCai
Content-Type: text/plain
Content-Disposition: inline
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

--t0UkRYy7tHLRMCai--