Skip to content

Commit d97e98e

Browse files
committed
Prevent psql from issuing BEGIN before ALTER SYSTEM when AUTOCOMMIT is off.
The autocommit-off mode works by issuing an implicit BEGIN just before any command that is not already in a transaction block and is not itself a BEGIN or other transaction-control command, nor a command that cannot be executed inside a transaction block. This commit prevents psql from issuing such an implicit BEGIN before ALTER SYSTEM because it's not allowed inside a transaction block. Backpatch to 9.4 where ALTER SYSTEM was added. Report by Feike Steenbergen
1 parent fbb1d7d commit d97e98e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bin/psql/common.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,23 @@ command_no_begin(const char *query)
15241524
return false;
15251525
}
15261526

1527+
if (wordlen == 5 && pg_strncasecmp(query, "alter", 5) == 0)
1528+
{
1529+
query += wordlen;
1530+
1531+
query = skip_white_space(query);
1532+
1533+
wordlen = 0;
1534+
while (isalpha((unsigned char) query[wordlen]))
1535+
wordlen += PQmblen(&query[wordlen], pset.encoding);
1536+
1537+
/* ALTER SYSTEM isn't allowed in xacts */
1538+
if (wordlen == 6 && pg_strncasecmp(query, "system", 6) == 0)
1539+
return true;
1540+
1541+
return false;
1542+
}
1543+
15271544
/*
15281545
* Note: these tests will match DROP SYSTEM and REINDEX TABLESPACE, which
15291546
* aren't really valid commands so we don't care much. The other four

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