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 plan created for inherited UPDATE/DELETE with all tables exc
Date: Fri, 22 Feb 2019 17:23:47 +0000
Message-ID: <E1gxEY7-0002xt-BQ@gemulon.postgresql.org> (raw)

Fix plan created for inherited UPDATE/DELETE with all tables excluded.

In the case where inheritance_planner() finds that every table has
been excluded by constraints, it thought it could get away with
making a plan consisting of just a dummy Result node.  While certainly
there's no updating or deleting to be done, this had two user-visible
problems: the plan did not report the correct set of output columns
when a RETURNING clause was present, and if there were any
statement-level triggers that should be fired, it didn't fire them.

Hence, rather than only generating the dummy Result, we need to
stick a valid ModifyTable node on top, which requires a tad more
effort here.

It's been broken this way for as long as inheritance_planner() has
known about deleting excluded subplans at all (cf commit 635d42e9c),
so back-patch to all supported branches.

Amit Langote and Tom Lane, per a report from Petr Fedorov.

Discussion: https://postgr.es/m/5da6f0f0-1364-1876-6978-907678f89a3e@phystech.edu

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/07fba9ad9b71c87a63f87a0ff16b6165ff08fc5e

Modified Files
--------------
src/backend/optimizer/plan/planner.c   | 68 +++++++++++++++++++++++-----------
src/test/regress/expected/inherit.out  | 41 ++++++++++++++++++++
src/test/regress/expected/triggers.out | 34 +++++++++++++++++
src/test/regress/sql/inherit.sql       | 15 ++++++++
src/test/regress/sql/triggers.sql      | 27 ++++++++++++++
5 files changed, 163 insertions(+), 22 deletions(-)



view thread (9+ messages)  latest in thread

Message-ID: <E1gxEY7-0002xt-BQ@gemulon.postgresql.org>
Permalink:  ../E1gxEY7-0002xt-BQ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gxEY7-0002xt-BQ@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 plan created for inherited UPDATE/DELETE with all tables exc
  In-Reply-To: <E1gxEY7-0002xt-BQ@gemulon.postgresql.org>
  References: <E1gxEY7-0002xt-BQ@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