diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-03-17 14:59:31 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-03-17 14:59:31 -0400 |
commit | 12d18b4870a2561e39d36999c5ba94899ac07f44 (patch) | |
tree | d2427b49b33283d6f1033d1dcf72c206d131de96 /src/include/executor | |
parent | 5149dc93467465e38645a5c318d7d90d806b5e53 (diff) |
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
Diffstat (limited to 'src/include/executor')
-rw-r--r-- | src/include/executor/tuptable.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index 5ac0b6a1f61..586f3e27b22 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -169,5 +169,7 @@ extern Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull); extern void slot_getallattrs(TupleTableSlot *slot); extern void slot_getsomeattrs(TupleTableSlot *slot, int attnum); extern bool slot_attisnull(TupleTableSlot *slot, int attnum); +extern bool slot_getsysattr(TupleTableSlot *slot, int attnum, + Datum *value, bool *isnull); #endif /* TUPTABLE_H */ |