postgresql/src/include
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
..
access Fix deletion of speculatively inserted TOAST on conflict 2016-08-17 17:03:36 -07:00
bootstrap Update copyright for 2016 2016-01-02 13:33:40 -05:00
catalog Implement regexp_match(), a simplified alternative to regexp_matches(). 2016-08-17 18:33:01 -04:00
commands Final pgindent + perltidy run for 9.6. 2016-08-15 13:42:51 -04:00
common pgindent run for 9.6 2016-06-09 18:02:36 -04:00
datatype Be more careful about out-of-range dates and timestamps. 2016-03-16 19:09:28 -04:00
executor Fix worst memory leaks in tqueue.c. 2016-07-29 19:31:06 -04:00
fe_utils Fix assorted places in psql to print version numbers >= 10 in new style. 2016-08-16 15:58:45 -04:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Remove mergeHyperLogLog. 2016-04-27 10:55:32 -04:00
libpq Fix pq_putmessage_noblock() to not block. 2016-07-29 12:52:57 -04:00
mb Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodes Improve parsetree representation of special functions such as CURRENT_DATE. 2016-08-16 20:33:01 -04:00
optimizer Avoid making a separate pass over the query to check for partializability. 2016-06-26 15:55:01 -04:00
parser Fix type-safety problem with parallel aggregate serial/deserialization. 2016-06-22 16:52:41 -04:00
port Fix various common mispellings. 2016-06-03 16:08:45 +01:00
portability Update copyright for 2016 2016-01-02 13:33:40 -05:00
postmaster Allow Pin/UnpinBuffer to operate in a lockfree manner. 2016-04-10 20:12:32 -07:00
regex Suppress compiler warnings about useless comparison of unsigned to zero. 2016-02-15 17:12:16 -05:00
replication Add conninfo to pg_stat_wal_receiver 2016-06-29 16:57:17 -04:00
rewrite Update copyright for 2016 2016-01-02 13:33:40 -05:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Once again allow LWLocks to be used within DSM segments. 2016-08-15 18:09:55 -04:00
tcop Stop the executor if no more tuples can be sent from worker to leader. 2016-06-06 14:52:58 -04:00
tsearch Final pgindent + perltidy run for 9.6. 2016-08-15 13:42:51 -04:00
utils Implement regexp_match(), a simplified alternative to regexp_matches(). 2016-08-17 18:33:01 -04:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Make init_spin_delay() C89 compliant and change stuck spinlock reporting. 2016-04-13 17:00:53 -07:00
fmgr.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
funcapi.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
getaddrinfo.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
getopt_long.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
Makefile Create src/fe_utils/, and move stuff into there from pg_dump's dumputils. 2016-03-24 15:55:57 -04:00
miscadmin.h Mark PostmasterPid as PGDLLIMPORT. 2016-06-03 14:06:35 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Add support for more extensive testing of raw_expression_tree_walker(). 2016-05-23 19:08:26 -04:00
pg_config.h.in Add BSD authentication method. 2016-04-08 13:52:06 -04:00
pg_config.h.win32 Stamp HEAD as 10devel. 2016-08-15 13:49:49 -04:00
pg_getopt.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pg_trace.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pgstat.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
pgtar.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pgtime.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
port.h On all Windows platforms, not just Cygwin, use _timezone and _tzname. 2016-03-28 20:59:25 -04:00
postgres_ext.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
postgres_fe.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
postgres.h Adjust DatumGetBool macro, this time for sure. 2016-04-28 11:50:58 -04:00
rusagestub.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
windowapi.h Update copyright for 2016 2016-01-02 13:33:40 -05:00