pgsql: Avoid fetching from an already-terminated plan.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid fetching from an already-terminated plan.
Date: 2021-09-09 17:36:58
Message-ID: E1mONys-0001zo-4d@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid fetching from an already-terminated plan.

Some plan node types don't react well to being called again after
they've already returned NULL. PortalRunSelect() has long dealt
with this by calling the executor with NoMovementScanDirection
if it sees that we've already run the portal to the end. However,
commit ba2c6d6ce overlooked this point, so that persisting an
already-fully-fetched cursor would fail if it had such a plan.

Per report from Tomas Barton. Back-patch to v11, as the faulty
commit was. (I've omitted a test case because the type of plan
that causes a problem isn't all that stable.)

Discussion: https://postgr.es/m/CAPV2KRjd=ErgVGbvO2Ty20tKTEZZr6cYsYLxgN_W3eAo9pf5sw@mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7813451c20c3b341c8af542d80bb941c9c893825

Modified Files
--------------
src/backend/commands/portalcmds.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2021-09-10 06:39:18 pgsql: Revoke PUBLIC CREATE from public schema, now owned by pg_databas
Previous Message Fujii Masao 2021-09-09 16:29:26 pgsql: pgbench: Stop counting skipped transactions as soon as timer is