forked from postgres/postgres
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support INSERT ... ON CONFLICT IGNORE
This non-standard INSERT clause allows DML statement authors to specify that in the event of each of any of the tuples being inserted duplicating an existing tuple in terms of a value or set of values constrained by a unique index, an alternative IGNORE path may be taken (the tuple slot proposed for insertion is skipped without raising an error). The implementation loops until either an insert occurs, or a conclusively committed conflicting tuple is determined to exist. This is implemented using a new infrastructure called "speculative insertion", which is an optimistic variant of regular insertion that has sessions attempt an insert following a pre-check, and handle uncommon conflicts (would-be unique/exclusion violations) in a special manner (this necessiates "super-deletion", and a new iteration). Speculative heap insertions are WAL-logged in two steps: One record relates to an initial intent to insert, while a second minimal record simply confirms that that attempt was ultimately successful (i.e. no conflicts where detected when inserting into constraint-related indexes). Logical decoding does not rely on the presence of this second record to affirm that a speculative insertion succeeded, though; it relies on the *absence* on an (internal) "super-deletion" record. Optionally, INSERT ... ON CONFLICT IGNORE commands may restrict the implementation from considering all would-be duplicate violations as reason to take the IGNORE path. A "unique index inference" clause/specification can be provided, which must have a set of user-supplied column names (or expressions), and optionally, a predicate (for partial indexes). This is used to infer some existing unique index (or, in corner cases, multiple unique indexes). Failure to infer at least one unique index is an error. Arbiter unique indexes are displayed in EXPLAIN output. Peter Geoghegan, with review and contributions from numerous others, including Heikki Linnakangas, Andres Freund, and Robert Haas. External testing infrastructure used during review developed by Jeff Janes.
- Loading branch information
1 parent
3cf8686
commit c842c79
Showing
77 changed files
with
3,089 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.