pgsql: Avoid Assert failure when processing empty statement in aborted - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Avoid Assert failure when processing empty statement in aborted
Date
Msg-id E1qBzQk-002uld-FD@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Avoid Assert failure when processing empty statement in aborted xact.

exec_parse_message() wants to create a cached plan in all cases,
including for empty input.  The empty-input path does not have
a test for being in an aborted transaction, making it possible
that plancache.c will fail due to trying to do database lookups
even though there's no real work to do.

One solution would be to throw an aborted-transaction error in
this path too, but it's not entirely clear whether the lack of
such an error was intentional or whether some clients might be
relying on non-error behavior.  Instead, let's hack plancache.c
so that it treats empty statements with the same logic it
already had for transaction control commands, ensuring that it
can soldier through even in an already-aborted transaction.

Per bug #17983 from Alexander Lakhin.  Back-patch to all
supported branches.

Discussion: https://postgr.es/m/17983-da4569fcb878672e@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a8be2356c55617eb959d38c8c249b454e1280a18

Modified Files
--------------
src/backend/utils/cache/plancache.c |  4 +++-
src/test/regress/expected/psql.out  | 11 +++++++++++
src/test/regress/sql/psql.sql       |  8 ++++++++
3 files changed, 22 insertions(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Avoid Assert failure when processing empty statement in aborted
Next
From: Jeff Davis
Date:
Subject: pgsql: initdb: change default --locale-provider back to libc.