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@postgresql.org
Subject: pgsql: Repair failure with SubPlans in multi-row VALUES lists.
Date: Sat, 25 Nov 2017 19:16:01 +0000
Message-ID: <E1eIfvl-0006U2-Qc@gemulon.postgresql.org> (raw)

Repair failure with SubPlans in multi-row VALUES lists.

When nodeValuesscan.c was written, it was impossible to have a SubPlan in
VALUES --- any sub-SELECT there would have to be uncorrelated and thereby
would produce an InitPlan instead.  We therefore took a shortcut in the
logic that throws away a ValuesScan's per-row expression evaluation data
structures.  This was broken by the introduction of LATERAL however; a
sub-SELECT containing a lateral reference produces a correlated SubPlan.

The cleanest fix for this would be to give up the optimization of
discarding the expression eval state.  But that still seems pretty
unappetizing for long VALUES lists.  It seems to work to just prevent
the subexpressions from hooking into the ValuesScan node's subPlan
list, so let's do that and see how well it works.  (If this breaks,
due to additional connections between the subexpressions and the outer
query structures, we might consider compromises like throwing away data
only for VALUES rows not containing SubPlans.)

Per bug #14924 from Christian Duta.  Back-patch to 9.3 where LATERAL
was introduced.

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

Branch
------
REL9_3_STABLE

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

Modified Files
--------------
src/backend/executor/nodeValuesscan.c   | 21 ++++++++++++++++-----
src/test/regress/expected/subselect.out | 30 ++++++++++++++++++++++++++++++
src/test/regress/sql/subselect.sql      | 10 ++++++++++
3 files changed, 56 insertions(+), 5 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1eIfvl-0006U2-Qc@gemulon.postgresql.org>
Permalink:  ../E1eIfvl-0006U2-Qc@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1eIfvl-0006U2-Qc@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: Repair failure with SubPlans in multi-row VALUES lists.
  In-Reply-To: <E1eIfvl-0006U2-Qc@gemulon.postgresql.org>
  References: <E1eIfvl-0006U2-Qc@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