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@lists.postgresql.org
Subject: pgsql: Fix wrong order of operations in inheritance_planner.
Date: Sat, 11 Aug 2018 19:53:28 +0000
Message-ID: <E1foZx2-0003kp-EC@gemulon.postgresql.org> (raw)

Fix wrong order of operations in inheritance_planner.

When considering a partitioning parent rel, we should stop processing that
subroot as soon as we've done adjust_appendrel_attrs and any securityQuals
updates.  The rest of this is unnecessary, and indeed adding duplicate
subquery RTEs to the subroot is *wrong*.  As the code stood, the children
of that partition ended up with two sets of copied subquery RTEs, confusing
matters greatly.  Even more hilarity ensued if all of the children got
excluded by constraint exclusion, so that the extra RTEs didn't make it
back into the parent rtable.

Per fuzz testing by Andreas Seltenreich.  Back-patch to v11 where this
got broken (by commit 0a480502b, it looks like).

Discussion: https://postgr.es/m/87va8g7vq0.fsf@ansel.ydns.eu

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0ff8f521d40f271c57f29f0ca773981e4465b35b

Modified Files
--------------
src/backend/optimizer/plan/planner.c         | 106 ++++++++++++++-------------
src/test/regress/expected/partition_join.out |  43 +++++++++++
src/test/regress/sql/partition_join.sql      |  12 +++
3 files changed, 111 insertions(+), 50 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1foZx2-0003kp-EC@gemulon.postgresql.org>
Permalink:  ../E1foZx2-0003kp-EC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1foZx2-0003kp-EC@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: Fix wrong order of operations in inheritance_planner.
  In-Reply-To: <E1foZx2-0003kp-EC@gemulon.postgresql.org>
  References: <E1foZx2-0003kp-EC@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