pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ludek Finstrle <luf@pzkagis.cz>
To: pgsql-odbc@postgresql.org
Subject: patch: recognize transaction
Date: Thu, 12 Jan 2006 15:17:45 +0100
Message-ID: <20060112141745.GC7886@soptik.pzkagis.cz> (raw)

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

Attachments:

psqlodbc-libpq_exec+start_trans.diff (text/plain, 3.0K) download 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);

Message-ID: <20060112141745.GC7886@soptik.pzkagis.cz>
Permalink:  ../20060112141745.GC7886@soptik.pzkagis.cz/
Also on:    postgresql.org/message-id/20060112141745.GC7886@soptik.pzkagis.cz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: luf@pzkagis.cz
  Subject: Re: patch: recognize transaction
  In-Reply-To: <20060112141745.GC7886@soptik.pzkagis.cz>
  References: <20060112141745.GC7886@soptik.pzkagis.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox