pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ludek Finstrle <luf@pzkagis.cz>
To: Marc Herbert <Marc.Herbert@continuent.com>
Cc: pgsql-odbc@postgresql.org
Subject: patch: BEGIN and autocommit(false)
Date: Fri, 20 Jan 2006 14:22:57 +0100
Message-ID: <20060120132257.GA19840@soptik.pzkagis.cz> (raw)
In-Reply-To: <khjslrktiut.fsf_-_@meije.emic.fr>
References: <43CF0B0B.6000101@necas.nec.com.cn>
	<20060119111957.GA31571@soptik.pzkagis.cz>
	<khjslrktiut.fsf_-_@meije.emic.fr>

Thu, Jan 19, 2006 at 03:03:54PM +0100, Marc Herbert wrote:
> Ludek Finstrle <luf@pzkagis.cz> writes:
> >>  1. set SQL_AUTOCOMMIT_OFF
> >
> > Yes you do ... When you use autocommit = off you have to start and end
> > transaction manually.
> 
> Wrong: in ODBC, you just have to "end" transactions manually, you
> don't have to start them, they are implicitely started when the
> previous one ends.
> 
> In ODBC (and JDBC), you are ALWAYS inside a transaction, there is no
> such thing as a transactional "no man's land" from an ODBC interface
> point of view (internal, hidden implementation details may differ).

I hope I solve this issue in psqlodbc driver. Thank you Marc for pointing
me the right way.
Patch attached (it's created againist 08.01.0107 development snapshot,
not againist CVS). This patch depend on psqlodbc-implicit_rollback.diff
one.

Please review and comment

Luf

Attachments:

psqlodbc-autocommit_off_begin.diff (text/plain, 2.9K) download diff -c psqlodbc.orig\statement.c psqlodbc\statement.c *** psqlodbc.orig\statement.c Fri Jan 20 14:09:35 2006 --- psqlodbc\statement.c Fri Jan 20 15:15:06 2006 *************** *** 71,76 **** --- 71,79 ---- STMT_TYPE_LOCK, "LOCK" }, { + STMT_TYPE_BEGIN, "BEGIN" + }, + { 0, NULL } }; *************** *** 423,428 **** --- 426,441 ---- if (!strnicmp(statement, Statement_Type[i].s, strlen(Statement_Type[i].s))) return Statement_Type[i].type; + /* determine START TRANSACTION */ + if (!strnicmp(statement, "START", 5)) + { + statement += 5; + /* ignore whitespace in query string */ + while (*statement && isspace((UCHAR) *statement)) + statement++; + if (!strnicmp(statement, "TRANSACTION", 11)) + return STMT_TYPE_BEGIN; + } return STMT_TYPE_OTHER; } *************** *** 1148,1154 **** QueryInfo qi; ConnInfo *ci; UDWORD qflag = 0; ! BOOL auto_begin = FALSE, is_in_trans; int func_cs_count = 0; --- 1161,1167 ---- QueryInfo qi; ConnInfo *ci; UDWORD qflag = 0; ! BOOL is_in_trans; int func_cs_count = 0; *************** *** 1175,1184 **** is_in_trans = CC_is_in_trans(conn); if (!self->internal && !is_in_trans && (SC_is_fetchcursor(self) || ! (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER))) { mylog(" about to begin a transaction on statement = %u\n", self); - auto_begin = TRUE; if (PG_VERSION_GE(conn, 7.1)) qflag |= GO_INTO_TRANSACTION; else if (!CC_begin(conn)) --- 1188,1196 ---- is_in_trans = CC_is_in_trans(conn); if (!self->internal && !is_in_trans && (SC_is_fetchcursor(self) || ! (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_BEGIN))) { mylog(" about to begin a transaction on statement = %u\n", self); if (PG_VERSION_GE(conn, 7.1)) qflag |= GO_INTO_TRANSACTION; else if (!CC_begin(conn)) *************** *** 1252,1258 **** */ if (CC_is_in_trans(conn)) { ! if (!is_in_trans && !auto_begin) CC_set_in_manual_trans(conn); if (!self->internal && CC_is_in_autocommit(conn) && !CC_is_in_manual_trans(conn)) CC_commit(conn); --- 1264,1270 ---- */ if (CC_is_in_trans(conn)) { ! if (!is_in_trans) CC_set_in_manual_trans(conn); if (!self->internal && CC_is_in_autocommit(conn) && !CC_is_in_manual_trans(conn)) CC_commit(conn); diff -c psqlodbc.orig\statement.h psqlodbc\statement.h *** psqlodbc.orig\statement.h Wed Nov 30 13:44:37 2005 --- psqlodbc\statement.h Fri Jan 20 15:07:21 2006 *************** *** 96,102 **** STMT_TYPE_GRANT, STMT_TYPE_REVOKE, STMT_TYPE_PROCCALL, ! STMT_TYPE_LOCK }; #define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT) --- 96,103 ---- STMT_TYPE_GRANT, STMT_TYPE_REVOKE, STMT_TYPE_PROCCALL, ! STMT_TYPE_LOCK, ! STMT_TYPE_BEGIN }; #define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT)

Message-ID: <20060120132257.GA19840@soptik.pzkagis.cz>
Permalink:  ../20060120132257.GA19840@soptik.pzkagis.cz/
Also on:    postgresql.org/message-id/20060120132257.GA19840@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, Marc.Herbert@continuent.com
  Subject: Re: patch: BEGIN and autocommit(false)
  In-Reply-To: <20060120132257.GA19840@soptik.pzkagis.cz>
  References: <43CF0B0B.6000101@necas.nec.com.cn> <20060119111957.GA31571@soptik.pzkagis.cz> <khjslrktiut.fsf_-_@meije.emic.fr> <20060120132257.GA19840@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