diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 56a732a..0091b5d 100644 *** a/src/interfaces/ecpg/ecpglib/connect.c --- b/src/interfaces/ecpg/ecpglib/connect.c *************** ECPGsetcommit(int lineno, const char *mo *** 167,191 **** if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0) { ! if (con->committed) { results = PQexec(con->connection, "begin transaction"); if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL)) return false; PQclear(results); - con->committed = false; } con->autocommit = false; } else if (con->autocommit == false && strncmp(mode, "on", strlen("on")) == 0) { ! if (!con->committed) { results = PQexec(con->connection, "commit"); if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL)) return false; PQclear(results); - con->committed = true; } con->autocommit = true; } --- 167,189 ---- if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0) { ! if (PQtransactionStatus(con->connection) == PQTRANS_IDLE) { results = PQexec(con->connection, "begin transaction"); if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL)) return false; PQclear(results); } con->autocommit = false; } else if (con->autocommit == false && strncmp(mode, "on", strlen("on")) == 0) { ! if (PQtransactionStatus(con->connection) != PQTRANS_IDLE) { results = PQexec(con->connection, "commit"); if (!ecpg_check_PQresult(results, lineno, con->connection, ECPG_COMPAT_PGSQL)) return false; PQclear(results); } con->autocommit = true; } *************** ECPGconnect(int lineno, int c, const cha *** 540,546 **** pthread_mutex_unlock(&connections_mutex); #endif - this->committed = true; this->autocommit = autocommit; PQsetNoticeReceiver(this->connection, &ECPGnoticeReceiver, (void *) this); --- 538,543 ---- diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 817724a..970fa93 100644 *** a/src/interfaces/ecpg/ecpglib/execute.c --- b/src/interfaces/ecpg/ecpglib/execute.c *************** ecpg_execute(struct statement * stmt) *** 1427,1433 **** /* The request has been build. */ ! if (stmt->connection->committed && !stmt->connection->autocommit) { results = PQexec(stmt->connection->connection, "begin transaction"); if (!ecpg_check_PQresult(results, stmt->lineno, stmt->connection->connection, stmt->compat)) --- 1427,1433 ---- /* The request has been build. */ ! if (PQtransactionStatus(stmt->connection->connection) == PQTRANS_IDLE && !stmt->connection->autocommit) { results = PQexec(stmt->connection->connection, "begin transaction"); if (!ecpg_check_PQresult(results, stmt->lineno, stmt->connection->connection, stmt->compat)) *************** ecpg_execute(struct statement * stmt) *** 1436,1442 **** return false; } PQclear(results); - stmt->connection->committed = false; } ecpg_log("ecpg_execute on line %d: query: %s; with %d parameter(s) on connection %s\n", stmt->lineno, stmt->command, nParams, stmt->connection->name); --- 1436,1441 ---- diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h index 0193ad1..2d9636d 100644 *** a/src/interfaces/ecpg/ecpglib/extern.h --- b/src/interfaces/ecpg/ecpglib/extern.h *************** struct connection *** 76,82 **** { char *name; PGconn *connection; - bool committed; int autocommit; struct ECPGtype_information_cache *cache_head; struct prepared_statement *prep_stmts; --- 76,81 ---- diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 20725e4..98e0597 100644 *** a/src/interfaces/ecpg/ecpglib/misc.c --- b/src/interfaces/ecpg/ecpglib/misc.c *************** ECPGtrans(int lineno, const char *connec *** 206,212 **** * developers have to take care themselves. However, if the command is * a begin statement, we just execute it once. */ ! if (con->committed && !con->autocommit && strncmp(transaction, "begin", 5) != 0 && strncmp(transaction, "start", 5) != 0) { res = PQexec(con->connection, "begin transaction"); if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL)) --- 206,212 ---- * developers have to take care themselves. However, if the command is * a begin statement, we just execute it once. */ ! if (PQtransactionStatus(con->connection) == PQTRANS_IDLE && !con->autocommit && strncmp(transaction, "begin", 5) != 0 && strncmp(transaction, "start", 5) != 0) { res = PQexec(con->connection, "begin transaction"); if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL)) *************** ECPGtrans(int lineno, const char *connec *** 218,228 **** if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL)) return FALSE; PQclear(res); - - if (strncmp(transaction, "commit", 6) == 0 || strncmp(transaction, "rollback", 8) == 0) - con->committed = true; - else - con->committed = false; } return true; --- 218,223 ----