aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/ecpglib/misc.c
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2017-03-13 20:44:13 +0100
committerMichael Meskes <meskes@postgresql.org>2017-03-13 21:03:55 +0100
commit43c79c7d68044cb804ddf8f549dfc4cb895f8542 (patch)
treeb9894b90c0573f74114b370bae128fba1f1dba39 /src/interfaces/ecpg/ecpglib/misc.c
parentdd12bef58ccee3596066cda9ded4fc6b3399d3ba (diff)
downloadpostgresql-43c79c7d68044cb804ddf8f549dfc4cb895f8542.tar.gz
postgresql-43c79c7d68044cb804ddf8f549dfc4cb895f8542.zip
Ecpg should support COMMIT PREPARED and ROLLBACK PREPARED.
The problem was that "begin transaction" was issued automatically before executing COMMIT/ROLLBACK PREPARED if not in auto commit. This fix by Masahiko Sawada fixes this.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/misc.c')
-rw-r--r--src/interfaces/ecpg/ecpglib/misc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index a13aa0a9da8..019ebe10f99 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -213,9 +213,15 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
* If we got a transaction command but have no open transaction, we
* have to start one, unless we are in autocommit, where the
* developers have to take care themselves. However, if the command is
- * a begin statement, we just execute it once.
+ * a begin statement, we just execute it once. And if the command is
+ * commit or rollback prepared, we don't execute it.
*/
- if (PQtransactionStatus(con->connection) == PQTRANS_IDLE && !con->autocommit && strncmp(transaction, "begin", 5) != 0 && strncmp(transaction, "start", 5) != 0)
+ if (PQtransactionStatus(con->connection) == PQTRANS_IDLE &&
+ !con->autocommit &&
+ strncmp(transaction, "begin", 5) != 0 &&
+ strncmp(transaction, "start", 5) != 0 &&
+ strncmp(transaction, "commit prepared", 15) != 0 &&
+ strncmp(transaction, "rollback prepared", 17) != 0)
{
res = PQexec(con->connection, "begin transaction");
if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_PGSQL))