pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid Assert failure when processing empty statement in aborted
Date: Wed, 21 Jun 2023 15:07:35 +0000
Message-ID: <E1qBzQk-002ulW-DM@gemulon.postgresql.org> (raw)

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_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/120ea65b8a0c7fd5c8f45030ec6a7fd979eaafc3

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(-)



view thread (6+ messages)

Message-ID: <E1qBzQk-002ulW-DM@gemulon.postgresql.org>
Permalink:  ../E1qBzQk-002ulW-DM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qBzQk-002ulW-DM@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Avoid Assert failure when processing empty statement in aborted
  In-Reply-To: <E1qBzQk-002ulW-DM@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox