Add temporal PRIMARY KEY and UNIQUE constraints

Peter Eisentraut <peter@eisentraut.org>

Commit: 46a0cd4cefb4d9b462d8cc4df5e7ecdd190bea92
Author: Peter Eisentraut <peter@eisentraut.org>
Date: 2024-01-24T15:34:37Z
Releases: 17.0
Add temporal PRIMARY KEY and UNIQUE constraints

Add WITHOUT OVERLAPS clause to PRIMARY KEY and UNIQUE constraints.
These are backed by GiST indexes instead of B-tree indexes, since they
are essentially exclusion constraints with = for the scalar parts of
the key and && for the temporal part.

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com

Files

PathChange+/−
contrib/btree_gist/expected/without_overlaps.out added +44 −0
contrib/btree_gist/Makefile modified +1 −1
contrib/btree_gist/meson.build modified +1 −0
contrib/btree_gist/sql/without_overlaps.sql added +25 −0
doc/src/sgml/catalogs.sgml modified +10 −0
doc/src/sgml/gist.sgml modified +13 −1
doc/src/sgml/ref/create_table.sgml modified +36 −9
src/backend/access/gist/gistutil.c modified +29 −0
src/backend/catalog/heap.c modified +2 −0
src/backend/catalog/index.c modified +4 −0
src/backend/catalog/pg_constraint.c modified +2 −0
src/backend/commands/indexcmds.c modified +129 −14
src/backend/commands/tablecmds.c modified +5 −1
src/backend/commands/trigger.c modified +1 −0
src/backend/commands/typecmds.c modified +1 −0
src/backend/nodes/outfuncs.c modified +2 −0
src/backend/nodes/readfuncs.c modified +2 −0
src/backend/parser/gram.y modified +18 −11
src/backend/parser/parse_utilcmd.c modified +27 −1
src/backend/utils/adt/ruleutils.c modified +2 −0
src/backend/utils/cache/relcache.c modified +12 −6
src/bin/pg_dump/pg_dump.c modified +14 −2
src/bin/pg_dump/pg_dump.h modified +2 −0
src/bin/pg_dump/t/002_pg_dump.pl modified +36 −0
src/bin/psql/describe.c modified +10 −2
src/include/access/gist.h modified +3 −0
src/include/catalog/catversion.h modified +1 −1
src/include/catalog/index.h modified +1 −0
src/include/catalog/pg_constraint.h modified +9 −1
src/include/commands/defrem.h modified +5 −1
src/include/nodes/parsenodes.h modified +2 −0
src/test/regress/expected/without_overlaps.out added +395 −0
src/test/regress/parallel_schedule modified +1 −1
src/test/regress/sql/without_overlaps.sql added +290 −0

Documentation touched

Discussion