pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <rhodiumtoad@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set scan direction appropriately for SubPlans (bug #15336)
Date: Fri, 17 Aug 2018 15:31:16 +0000
Message-ID: <E1fqgia-0000TP-Hd@gemulon.postgresql.org> (raw)

Set scan direction appropriately for SubPlans (bug #15336)

When executing a SubPlan in an expression, the EState's direction
field was left alone, resulting in an attempt to execute the subplan
backwards if it was encountered during a backwards scan of a cursor.
Also, though much less likely, it was possible to reach the execution
of an InitPlan while in backwards-scan state.

Repair by saving/restoring estate->es_direction and forcing forward
scan mode in the relevant places.

Backpatch all the way, since this has been broken since 8.3 (prior to
commit c7ff7663e, SubPlans had their own EStates rather than sharing
the parent plan's, so there was no confusion over scan direction).

Per bug #15336 reported by Vladimir Baranoff; analysis and patch by
me, review by Tom Lane.

Discussion: https://postgr.es/m/153449812167.1304.1741624125628126322@wrigleys.postgresql.org

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/backend/executor/nodeSubplan.c      | 26 ++++++++++++++++++++++++--
src/test/regress/expected/subselect.out | 17 +++++++++++++++++
src/test/regress/sql/subselect.sql      | 16 ++++++++++++++++
3 files changed, 57 insertions(+), 2 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1fqgia-0000TP-Hd@gemulon.postgresql.org>
Permalink:  ../E1fqgia-0000TP-Hd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fqgia-0000TP-Hd@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: rhodiumtoad@postgresql.org
  Subject: Re: pgsql: Set scan direction appropriately for SubPlans (bug #15336)
  In-Reply-To: <E1fqgia-0000TP-Hd@gemulon.postgresql.org>
  References: <E1fqgia-0000TP-Hd@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