diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index c8fc085fa0..81a633a3d0 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -1369,8 +1369,20 @@ command_no_begin(const char *query) return true; } + /* DISCARD ALL isn't allowed in xacts, but other variants are allowed. */ if (wordlen == 7 && pg_strncasecmp(query, "discard", 7) == 0) - return true; + { + query += wordlen; + + query = skip_white_space(query); + + wordlen = 0; + while (isalpha((unsigned char) query[wordlen])) + wordlen += PQmblen(&query[wordlen], pset.encoding); + + if (wordlen == 3 && pg_strncasecmp(query, "all", 3) == 0) + return true; + } return false; }