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: Remove faulty support for MergeAppend plan with WHERE CURRENT OF
Date: Tue, 19 Jan 2021 18:26:32 +0000
Message-ID: <E1l1vi4-0003MU-QP@gemulon.postgresql.org> (raw)

Remove faulty support for MergeAppend plan with WHERE CURRENT OF.

Somebody extended search_plan_tree() to treat MergeAppend exactly
like Append, which is 100% wrong, because unlike Append we can't
assume that only one input node is actively returning tuples.
Hence a cursor using a MergeAppend across a UNION ALL or inheritance
tree could falsely match a WHERE CURRENT OF query at a row that
isn't actually the cursor's current output row, but coincidentally
has the same TID (in a different table) as the current output row.

Delete the faulty code; this means that such a case will now return
an error like 'cursor "foo" is not a simply updatable scan of table
"bar"', instead of silently misbehaving.  Users should not find that
surprising though, as the same cursor query could have failed that way
already depending on the chosen plan.  (It would fail like that if the
sort were done with an explicit Sort node instead of MergeAppend.)

Expand the clearly-inadequate commentary to be more explicit about
what this code is doing, in hopes of forestalling future mistakes.

It's been like this for awhile, so back-patch to all supported
branches.

Discussion: https://postgr.es/m/482865.1611075182@sss.pgh.pa.us

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/794562d0770ae0ba4096c57c116e80a2be043fbf

Modified Files
--------------
src/backend/executor/execCurrent.c | 53 +++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 26 deletions(-)



view thread (7+ messages)

Message-ID: <E1l1vi4-0003MU-QP@gemulon.postgresql.org>
Permalink:  ../E1l1vi4-0003MU-QP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1l1vi4-0003MU-QP@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: Remove faulty support for MergeAppend plan with WHERE CURRENT OF
  In-Reply-To: <E1l1vi4-0003MU-QP@gemulon.postgresql.org>
  References: <E1l1vi4-0003MU-QP@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