pgsql: Remove faulty support for MergeAppend plan with WHERE CURRENT OF - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Remove faulty support for MergeAppend plan with WHERE CURRENT OF
Date
Msg-id E1l1vi4-0003Ma-RG@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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
------
REL9_6_STABLE

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

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


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: pageinspect: Change block number arguments to bigint
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix ALTER DEFAULT PRIVILEGES with duplicated objects