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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Restore the portal-level snapshot for simple expressions, too.
Date: 2021-06-22 21:48:57
Message-ID: E1lvoGP-0003pE-No@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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
------
master

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

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-06-23 01:43:43 pgsql: Use annotations to reduce instability of isolation-test results.
Previous Message noreply 2021-06-22 21:23:12 pgsql: Tag refs/tags/REL_14_BETA2 was created