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: Restore the portal-level snapshot for simple expressions, too.
Date: Tue, 22 Jun 2021 21:48:57 +0000
Message-ID: <E1lvoGP-0003pF-OC@gemulon.postgresql.org> (raw)

Restore the portal-level snapshot for simple expressions, too.

Commits 84f5c2908 et al missed the need to cover plpgsql's "simple
expression" code path.  If the first thing we execute after a
COMMIT/ROLLBACK is one of those, rather than a full-fledged SPI command,
we must explicitly do EnsurePortalSnapshotExists() to make sure we have
an outer snapshot.  Note that it wouldn't be good enough to just push a
snapshot for the duration of the expression execution: what comes back
might be toasted, so we'd better have a snapshot protecting it.

The test case demonstrating this fact cheats a bit by marking a SQL
function immutable even though it fetches from a table.  That's
nothing that users haven't been seen to do, though.

Per report from Jim Nasby.  Back-patch to v11, like the previous fix.

Discussion: https://postgr.es/m/378885e4-f85f-fc28-6c91-c4d1c080bf26@amazon.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6f1321d5ae8e0db1500def46f12eadf94521f5ee

Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_transaction.out | 18 ++++++++++++++++++
src/pl/plpgsql/src/pl_exec.c                        | 10 ++++++++++
src/pl/plpgsql/src/sql/plpgsql_transaction.sql      | 21 +++++++++++++++++++++
3 files changed, 49 insertions(+)



view thread (8+ messages)  latest in thread

Message-ID: <E1lvoGP-0003pF-OC@gemulon.postgresql.org>
Permalink:  ../E1lvoGP-0003pF-OC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lvoGP-0003pF-OC@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Restore the portal-level snapshot for simple expressions, too.
  In-Reply-To: <E1lvoGP-0003pF-OC@gemulon.postgresql.org>
  References: <E1lvoGP-0003pF-OC@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