postgresql/src/include/executor
Tom Lane 5b77c11da2 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:31 -04:00
..
execdebug.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
execdesc.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
executor.h Fix latent crash in do_text_output_multiline(). 2016-05-23 14:16:41 -04:00
functions.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
hashjoin.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
instrument.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeAgg.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeAppend.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeBitmapAnd.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeBitmapHeapscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeBitmapIndexscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeBitmapOr.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeCtescan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeForeignscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeFunctionscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeGroup.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeHash.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeHashjoin.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeIndexonlyscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeIndexscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeLimit.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeLockRows.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeMaterial.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeMergeAppend.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeMergejoin.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeModifyTable.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeNestloop.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeRecursiveunion.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeResult.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeSeqscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeSetOp.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeSort.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeSubplan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeSubqueryscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeTidscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeUnique.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeValuesscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeWindowAgg.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeWorktablescan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
spi.h Prevent leakage of SPI tuple tables during subtransaction abort. 2013-07-25 16:45:47 -04:00
spi_priv.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
tstoreReceiver.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tuptable.h Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan. 2018-03-17 14:59:31 -04:00