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: Teach reparameterize_path() to handle AppendPaths.
Date: Tue, 23 Jan 2018 21:50:52 +0000
Message-ID: <E1ee6Sy-0008UC-8R@gemulon.postgresql.org> (raw)

Teach reparameterize_path() to handle AppendPaths.

If we're inside a lateral subquery, there may be no unparameterized paths
for a particular child relation of an appendrel, in which case we *must*
be able to create similarly-parameterized paths for each other child
relation, else the planner will fail with "could not devise a query plan
for the given query".  This means that there are situations where we'd
better be able to reparameterize at least one path for each child.

This calls into question the assumption in reparameterize_path() that
it can just punt if it feels like it.  However, the only case that is
known broken right now is where the child is itself an appendrel so that
all its paths are AppendPaths.  (I think possibly I disregarded that in
the original coding on the theory that nested appendrels would get folded
together --- but that only happens *after* reparameterize_path(), so it's
not excused from handling a child AppendPath.)  Given that this code's been
like this since 9.3 when LATERAL was introduced, it seems likely we'd have
heard of other cases by now if there were a larger problem.

Per report from Elvis Pranskevichus.  Back-patch to 9.3.

Discussion: https://postgr.es/m/5981018.zdth1YWmNy@hammer.magicstack.net

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/54e1599c76dfa90d179b61615f6473c437cf94f1

Modified Files
--------------
src/backend/optimizer/util/pathnode.c | 22 ++++++++++++++++++++++
src/test/regress/expected/join.out    | 19 +++++++++++++++++++
src/test/regress/sql/join.sql         | 10 ++++++++++
3 files changed, 51 insertions(+)



view thread (6+ messages)  latest in thread

Message-ID: <E1ee6Sy-0008UC-8R@gemulon.postgresql.org>
Permalink:  ../E1ee6Sy-0008UC-8R@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ee6Sy-0008UC-8R@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: Teach reparameterize_path() to handle AppendPaths.
  In-Reply-To: <E1ee6Sy-0008UC-8R@gemulon.postgresql.org>
  References: <E1ee6Sy-0008UC-8R@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