Skip to content

Commit 0cf3765

Browse files
committed
there is one problem with Zoltan patches commited into the tree:
if we set autocommit off and issued COMMIT (or ROLLBACK) on a connection new transaction is not started Max Khon
1 parent 326fbd8 commit 0cf3765

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/interfaces/odbc/options.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,32 +314,18 @@ int i;
314314

315315
case SQL_AUTOCOMMIT:
316316

317-
/* Since we are almost always in a transaction, this is now ok.
318-
Even if we were, the logic will handle it by sending a commit
319-
after the statement.
320-
321317
if (CC_is_in_trans(conn)) {
322-
conn->errormsg = "Cannot switch commit mode while a transaction is in progres";
318+
conn->errormsg = "Cannot switch commit mode while a transaction is in progress";
323319
conn->errornumber = CONN_TRANSACT_IN_PROGRES;
324320
CC_log_error(func, "", conn);
325321
return SQL_ERROR;
326322
}
327-
*/
328323

329324
mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
330325

331326
switch(vParam) {
332327
case SQL_AUTOCOMMIT_OFF:
333328
CC_set_autocommit_off(conn);
334-
/* The following two lines are new.
335-
With this modification the SELECT statements
336-
are also included in the transactions.
337-
Error handling should be written,
338-
this is missing yet, see
339-
SC_execute in statement.c for details. Zoltan
340-
*/
341-
CC_send_query(conn,"BEGIN",NULL);
342-
CC_set_in_trans(conn);
343329
break;
344330

345331
case SQL_AUTOCOMMIT_ON:

src/interfaces/odbc/statement.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,12 @@ QueryInfo qi;
750750
starting a transaction first.
751751
752752
A transaction should be begun if and only if
753-
we use declare/fetch and the statement is SELECT.
753+
we use declare/fetch and the statement is SELECT
754+
or we are not in autocommit state
754755
We assume that the Postgres backend has an autocommit
755756
feature as default. (Zoltan Kovacs, 04/26/2000)
756757
*/
757-
// if ( ! self->internal && ! CC_is_in_trans(conn) && (globals.use_declarefetch || STMT_UPDATE(self))) {
758-
if ( ! self->internal && ! CC_is_in_trans(conn) && globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) {
758+
if ( ! self->internal && ! CC_is_in_trans(conn) && ((globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) || ! CC_is_in_autocommit(conn))) {
759759

760760
mylog(" about to begin a transaction on statement = %u\n", self);
761761
res = CC_send_query(conn, "BEGIN", NULL);
@@ -831,16 +831,9 @@ QueryInfo qi;
831831
mylog(" it's NOT a select statement: stmt=%u\n", self);
832832
self->result = CC_send_query(conn, self->stmt_with_params, NULL);
833833

834-
/* If we are in autocommit, we must send the commit. */
835-
/* No, we shouldn't. Postgres backend does the
834+
/* We shouldn't send COMMIT. Postgres backend does the
836835
autocommit if neccessary. (Zoltan, 04/26/2000)
837836
*/
838-
/* if ( ! self->internal && CC_is_in_autocommit(conn) && STMT_UPDATE(self)) {
839-
res = CC_send_query(conn, "COMMIT", NULL);
840-
QR_Destructor(res);
841-
CC_set_no_trans(conn);
842-
}*/
843-
844837
}
845838

846839
conn->status = oldstatus;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy