postgresql/src/backend/access
Tom Lane 8f5ac44043 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
2018-03-17 14:59:49 -04:00
..
brin Log when a BRIN autosummarization request fails 2018-03-14 11:59:40 -03:00
common Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan. 2018-03-17 14:59:49 -04:00
gin Support parallel btree index builds. 2018-02-02 13:32:44 -05:00
gist Make gistvacuumcleanup() count the actual number of index tuples. 2018-03-02 11:22:42 -05:00
hash Remove redundant IndexTupleDSize macro. 2018-02-28 19:25:54 -05:00
heap Fix HEAP_INSERT_IS_SPECULATIVE to HEAP_INSERT_SPECULATIVE in comments. 2018-03-05 15:28:03 -08:00
index Local partitioned indexes 2018-01-19 11:49:22 -03:00
nbtree Remove redundant IndexTupleDSize macro. 2018-02-28 19:25:54 -05:00
rmgrdesc Update copyright for 2018 2018-01-02 23:30:12 -05:00
spgist Support parallel btree index builds. 2018-02-02 13:32:44 -05:00
tablesample Update copyright for 2018 2018-01-02 23:30:12 -05:00
transam Change transaction state debug strings to match enum symbols 2018-03-16 13:18:06 -04:00
Makefile TABLESAMPLE, SQL Standard and extensible 2015-05-15 14:37:10 -04:00