Commit 0cf37659 authored by Bruce Momjian's avatar Bruce Momjian

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
parent 326fbd88
...@@ -314,32 +314,18 @@ int i; ...@@ -314,32 +314,18 @@ int i;
case SQL_AUTOCOMMIT: case SQL_AUTOCOMMIT:
/* Since we are almost always in a transaction, this is now ok.
Even if we were, the logic will handle it by sending a commit
after the statement.
if (CC_is_in_trans(conn)) { if (CC_is_in_trans(conn)) {
conn->errormsg = "Cannot switch commit mode while a transaction is in progres"; conn->errormsg = "Cannot switch commit mode while a transaction is in progress";
conn->errornumber = CONN_TRANSACT_IN_PROGRES; conn->errornumber = CONN_TRANSACT_IN_PROGRES;
CC_log_error(func, "", conn); CC_log_error(func, "", conn);
return SQL_ERROR; return SQL_ERROR;
} }
*/
mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam); mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
switch(vParam) { switch(vParam) {
case SQL_AUTOCOMMIT_OFF: case SQL_AUTOCOMMIT_OFF:
CC_set_autocommit_off(conn); CC_set_autocommit_off(conn);
/* The following two lines are new.
With this modification the SELECT statements
are also included in the transactions.
Error handling should be written,
this is missing yet, see
SC_execute in statement.c for details. Zoltan
*/
CC_send_query(conn,"BEGIN",NULL);
CC_set_in_trans(conn);
break; break;
case SQL_AUTOCOMMIT_ON: case SQL_AUTOCOMMIT_ON:
......
...@@ -750,12 +750,12 @@ QueryInfo qi; ...@@ -750,12 +750,12 @@ QueryInfo qi;
starting a transaction first. starting a transaction first.
A transaction should be begun if and only if A transaction should be begun if and only if
we use declare/fetch and the statement is SELECT. we use declare/fetch and the statement is SELECT
or we are not in autocommit state
We assume that the Postgres backend has an autocommit We assume that the Postgres backend has an autocommit
feature as default. (Zoltan Kovacs, 04/26/2000) feature as default. (Zoltan Kovacs, 04/26/2000)
*/ */
// if ( ! self->internal && ! CC_is_in_trans(conn) && (globals.use_declarefetch || STMT_UPDATE(self))) { if ( ! self->internal && ! CC_is_in_trans(conn) && ((globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) || ! CC_is_in_autocommit(conn))) {
if ( ! self->internal && ! CC_is_in_trans(conn) && globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) {
mylog(" about to begin a transaction on statement = %u\n", self); mylog(" about to begin a transaction on statement = %u\n", self);
res = CC_send_query(conn, "BEGIN", NULL); res = CC_send_query(conn, "BEGIN", NULL);
...@@ -831,16 +831,9 @@ QueryInfo qi; ...@@ -831,16 +831,9 @@ QueryInfo qi;
mylog(" it's NOT a select statement: stmt=%u\n", self); mylog(" it's NOT a select statement: stmt=%u\n", self);
self->result = CC_send_query(conn, self->stmt_with_params, NULL); self->result = CC_send_query(conn, self->stmt_with_params, NULL);
/* If we are in autocommit, we must send the commit. */ /* We shouldn't send COMMIT. Postgres backend does the
/* No, we shouldn't. Postgres backend does the
autocommit if neccessary. (Zoltan, 04/26/2000) autocommit if neccessary. (Zoltan, 04/26/2000)
*/ */
/* if ( ! self->internal && CC_is_in_autocommit(conn) && STMT_UPDATE(self)) {
res = CC_send_query(conn, "COMMIT", NULL);
QR_Destructor(res);
CC_set_no_trans(conn);
}*/
} }
conn->status = oldstatus; conn->status = oldstatus;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment