postgresql/src/include/access
Andres Freund 07ef035129 Fix deletion of speculatively inserted TOAST on conflict
INSERT ..  ON CONFLICT runs a pre-check of the possible conflicting
constraints before performing the actual speculative insertion.  In case
the inserted tuple included TOASTed columns the ON CONFLICT condition
would be handled correctly in case the conflict was caught by the
pre-check, but if two transactions entered the speculative insertion
phase at the same time, one would have to re-try, and the code for
aborting a speculative insertion did not handle deleting the
speculatively inserted TOAST datums correctly.

TOAST deletion would fail with "ERROR: attempted to delete invisible
tuple" as we attempted to remove the TOAST tuples using
simple_heap_delete which reasoned that the given tuples should not be
visible to the command that wrote them.

This commit updates the heap_abort_speculative() function which aborts
the conflicting tuple to use itself, via toast_delete, for deleting
associated TOAST datums.  Like before, the inserted toast rows are not
marked as being speculative.

This commit also adds a isolationtester spec test, exercising the
relevant code path. Unfortunately 9.5 cannot handle two waiting
sessions, and thus cannot execute this test.

Reported-By: Viren Negi, Oskari Saarenmaa
Author: Oskari Saarenmaa, edited a bit by me
Bug: #14150
Discussion: <20160519123338.12513.20271@wrigleys.postgresql.org>
Backpatch: 9.5, where ON CONFLICT was introduced
2016-08-17 17:03:36 -07:00
..
amapi.h Add SQL-accessible functions for inspecting index AM properties. 2016-08-13 18:31:14 -04:00
amvalidate.h Improve index AMs' opclass validation procedures. 2016-01-21 19:47:15 -05:00
attnum.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
brin.h Restructure index access method API to hide most of it at the C level. 2016-01-17 19:36:59 -05:00
brin_internal.h Restructure index access method API to hide most of it at the C level. 2016-01-17 19:36:59 -05:00
brin_page.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
brin_pageops.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
brin_revmap.h Add the "snapshot too old" feature 2016-04-08 14:36:30 -05:00
brin_tuple.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
brin_xlog.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
clog.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
commit_ts.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
genam.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
generic_xlog.h Improve API of GenericXLogRegister(). 2016-04-12 11:42:06 -04:00
gin.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
gin_private.h Prevent multiple cleanup process for pending list in GIN. 2016-04-28 16:21:42 +03:00
gist.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
gist_private.h Add SQL-accessible functions for inspecting index AM properties. 2016-08-13 18:31:14 -04:00
gistscan.h Restructure index access method API to hide most of it at the C level. 2016-01-17 19:36:59 -05:00
hash.h Fix building of large (bigger than shared_buffers) hash indexes. 2016-06-24 16:57:36 -04:00
heapam.h Change the format of the VM fork to add a second bit per page. 2016-03-01 21:49:41 -05:00
heapam_xlog.h Clear all-frozen visibilitymap status when locking tuples. 2016-07-18 02:01:13 -07:00
hio.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
htup.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
htup_details.h Fix handling of multixacts predating pg_upgrade 2016-06-24 18:29:28 -04:00
itup.h Revert CREATE INDEX ... INCLUDING ... 2016-04-08 21:52:13 +03:00
multixact.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nbtree.h Add SQL-accessible functions for inspecting index AM properties. 2016-08-13 18:31:14 -04:00
parallel.h Minor cleanup for access/transam/parallel.c. 2016-08-01 16:12:01 -04:00
printtup.h Stop the executor if no more tuples can be sent from worker to leader. 2016-06-06 14:52:58 -04:00
reloptions.h Restructure index access method API to hide most of it at the C level. 2016-01-17 19:36:59 -05:00
relscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
rewriteheap.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
rmgr.h Add rmgr callback to name xlog record types for display purposes. 2014-09-19 16:20:29 +02:00
rmgrlist.h Generic Messages for Logical Decoding 2016-04-06 10:05:41 +01:00
sdir.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
skey.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
slru.h Make all built-in lwlock tranche IDs fixed. 2016-02-02 06:45:55 -05:00
spgist.h Introduce traversalValue for SP-GiST scan 2016-03-30 18:29:28 +03:00
spgist_private.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
stratnum.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
subtrans.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
sysattr.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
timeline.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
transam.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tsmapi.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tupconvert.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tupdesc.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tupmacs.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tuptoaster.h Fix deletion of speculatively inserted TOAST on conflict 2016-08-17 17:03:36 -07:00
twophase.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
twophase_rmgr.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
valid.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
visibilitymap.h Clear all-frozen visibilitymap status when locking tuples. 2016-07-18 02:01:13 -07:00
xact.h Add new replication mode synchronous_commit = 'remote_apply'. 2016-03-29 21:29:49 -04:00
xlog.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
xlog_fn.h Implement backup API functions for non-exclusive backups 2016-04-05 20:03:49 +02:00
xlog_internal.h Clear all-frozen visibilitymap status when locking tuples. 2016-07-18 02:01:13 -07:00
xlogdefs.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
xloginsert.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
xlogreader.h Revert timeline following in replication slots 2016-05-04 17:32:22 -03:00
xlogrecord.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
xlogutils.h XLogReader general code cleanup 2016-03-30 18:56:13 -03:00