diff options
author | Kevin Grittner <kgrittn@postgresql.org> | 2016-12-13 19:14:42 -0600 |
---|---|---|
committer | Kevin Grittner <kgrittn@postgresql.org> | 2016-12-13 19:14:42 -0600 |
commit | bed2a0b06ba54266a4e66affbc8f08e5eea6e8bc (patch) | |
tree | 982fdd8f545339cd1f2c557c12a6282e93bdca2e /src/backend/access/nbtree/nbtinsert.c | |
parent | 15b3722700ca043494804dfd1fe7556c50d4f9e9 (diff) | |
download | postgresql-bed2a0b06ba54266a4e66affbc8f08e5eea6e8bc.tar.gz postgresql-bed2a0b06ba54266a4e66affbc8f08e5eea6e8bc.zip |
Back-patch fcff8a575198478023ada8a48e13b50f70054766 as a bug fix.
When there is both a serialization failure and a unique violation,
throw the former rather than the latter. When initially pushed,
this was viewed as a feature to assist application framework
developers, so that they could more accurately determine when to
retry a failed transaction, but a test case presented by Ian
Jackson has shown that this patch can prevent serialization
anomalies in some cases where a unique violation is caught within a
subtransaction, the work of that subtransaction is discarded, and
no error is thrown. That makes this a bug fix, so it is being
back-patched to all supported branches where it is not already
present (i.e., 9.2 to 9.5).
Discussion: https://postgr.es/m/1481307991-16971-1-git-send-email-ian.jackson@eu.citrix.com
Discussion: https://postgr.es/m/22607.56276.807567.924144@mariner.uk.xensource.com
Diffstat (limited to 'src/backend/access/nbtree/nbtinsert.c')
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 77c2fdf90b4..3b18a78a48f 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -392,6 +392,14 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, } /* + * Check for a conflict-in as we would if we were going to + * write to this page. We aren't actually going to write, + * but we want a chance to report SSI conflicts that would + * otherwise be masked by this unique constraint violation. + */ + CheckForSerializableConflictIn(rel, NULL, buf); + + /* * This is a definite conflict. Break the tuple down into * datums and report the error. But first, make sure we * release the buffer locks we're holding --- |