]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Mar 2018 18:59:31 +0000 (14:59 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Mar 2018 18:59:31 +0000 (14:59 -0400)
commit7de7ddb27a868f7bf2e5f802752723041dd32d60
tree47bddf5378bacee6a56fb9123cffd2782df31785
parentc17a58967d97461a088ca2f19da4c46cf35e4194
Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan.

"UPDATE/DELETE WHERE CURRENT OF cursor_name" failed, with an error message
like "cannot extract system attribute from virtual tuple", if the cursor
was using a index-only scan for the target table.  Fix it by digging the
current TID out of the indexscan state.

It seems likely that the same failure could occur for CustomScan plans
and perhaps some FDW plan types, so that leaving this to be treated as an
internal error with an obscure message isn't as good an idea as it first
seemed.  Hence, add a bit of heaptuple.c infrastructure to let us deliver
a more on-topic message.  I chose to make the message match what you get
for the case where execCurrentOf can't identify the target scan node at
all, "cursor "foo" is not a simply updatable scan of table "bar"".
Perhaps it should be different, but we can always adjust that later.

In the future, it might be nice to provide hooks that would let custom
scan providers and/or FDWs deal with this in other ways; but that's
not a suitable topic for a back-patchable bug fix.

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

Yugo Nagata and Tom Lane

Discussion: https://postgr.es/m/20180201013349.937dfc5f.nagata@sraoss.co.jp
src/backend/access/common/heaptuple.c
src/backend/executor/execCurrent.c
src/include/executor/tuptable.h
src/test/regress/expected/portals.out
src/test/regress/sql/portals.sql