Skip to content

Commit 99bb9c5

Browse files
committed
Fix interaction between psql \set AUTOCOMMIT and "ON_ERROR_ROLLBACK"
by properly updating transaction state after AUTOCOMMIT.
1 parent 8d86982 commit 99bb9c5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/bin/psql/common.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.104 2005/06/22 21:14:30 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.105 2005/09/20 21:43:08 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -1010,13 +1010,15 @@ SendQuery(const char *query)
10101010
return false;
10111011
}
10121012
PQclear(results);
1013+
transaction_status = PQtransactionStatus(pset.db);
10131014
}
1014-
else if (transaction_status == PQTRANS_INTRANS &&
1015-
(rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL &&
1016-
/* !off and !interactive is 'on' */
1017-
pg_strcasecmp(rollback_str, "off") != 0 &&
1018-
(pset.cur_cmd_interactive ||
1019-
pg_strcasecmp(rollback_str, "interactive") != 0))
1015+
1016+
if (transaction_status == PQTRANS_INTRANS &&
1017+
(rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL &&
1018+
/* !off and !interactive is 'on' */
1019+
pg_strcasecmp(rollback_str, "off") != 0 &&
1020+
(pset.cur_cmd_interactive ||
1021+
pg_strcasecmp(rollback_str, "interactive") != 0))
10201022
{
10211023
if (on_error_rollback_warning == false && pset.sversion < 80000)
10221024
{

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