X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 149959DCDBE for ; Thu, 12 Jan 2006 10:17:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48188-02 for ; Thu, 12 Jan 2006 10:17:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.pzkagis.cz (gis6.netbox.cz [83.240.30.214]) by postgresql.org (Postfix) with ESMTP id E46E19DCDBB for ; Thu, 12 Jan 2006 10:17:43 -0400 (AST) Received: from soptik.pzkagis.cz (localhost.localdomain [127.0.0.1]) by smtp.pzkagis.cz (8.13.1/8.13.1) with ESMTP id k0CEHjTI007992 for ; Thu, 12 Jan 2006 15:17:45 +0100 Received: (from luf@localhost) by soptik.pzkagis.cz (8.13.1/8.13.1/Submit) id k0CEHjTe007991 for pgsql-odbc@postgresql.org; Thu, 12 Jan 2006 15:17:45 +0100 Date: Thu, 12 Jan 2006 15:17:45 +0100 From: Ludek Finstrle To: pgsql-odbc@postgresql.org Subject: patch: recognize transaction Message-ID: <20060112141745.GC7886@soptik.pzkagis.cz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="t0UkRYy7tHLRMCai" Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Virus-Scanned: ClamAV version 0.87.1, clamav-milter version 0.87 on smtp.pzkagis.cz X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.073 required=5 tests=[AWL=0.073] X-Spam-Score: 0.073 X-Spam-Level: X-Archive-Number: 200601/121 X-Sequence-Number: 6936 --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--