mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Revert temporal primary keys and foreign keys
This feature set did not handle empty ranges correctly, and it's now too late for PostgreSQL 17 to fix it. The following commits are reverted:6db4598fcb
Add stratnum GiST support function46a0cd4cef
Add temporal PRIMARY KEY and UNIQUE constraints86232a49a4
Fix comment on gist_stratnum_btree030e10ff1a
Rename pg_constraint.conwithoutoverlaps to conperioda88c800deb
Use daterange and YMD in without_overlaps tests instead of tsrange.5577a71fb0
Use half-open interval notation in without_overlaps tests34768ee361
Add temporal FOREIGN KEY contraints482e108cd3
Add test for REPLICA IDENTITY with a temporal keyc3db1f30cb
doc: clarify PERIOD and WITHOUT OVERLAPS in CREATE TABLE144c2ce0cc
Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes Discussion: https://www.postgresql.org/message-id/d0b64a7a-dfe4-4b84-a906-c7dedfa40a3e@eisentraut.org
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
-- test stratnum support func
|
||||
SELECT gist_stratnum_btree(3::smallint);
|
||||
SELECT gist_stratnum_btree(18::smallint);
|
@ -1,53 +0,0 @@
|
||||
-- Core must test WITHOUT OVERLAPS
|
||||
-- with an int4range + daterange,
|
||||
-- so here we do some simple tests
|
||||
-- to make sure int + daterange works too,
|
||||
-- since that is the expected use-case.
|
||||
CREATE TABLE temporal_rng (
|
||||
id integer,
|
||||
valid_at daterange,
|
||||
CONSTRAINT temporal_rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS)
|
||||
);
|
||||
\d temporal_rng
|
||||
SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname = 'temporal_rng_pk';
|
||||
SELECT pg_get_indexdef(conindid, 0, true) FROM pg_constraint WHERE conname = 'temporal_rng_pk';
|
||||
|
||||
INSERT INTO temporal_rng VALUES
|
||||
(1, '[2000-01-01,2001-01-01)');
|
||||
-- same key, doesn't overlap:
|
||||
INSERT INTO temporal_rng VALUES
|
||||
(1, '[2001-01-01,2002-01-01)');
|
||||
-- overlaps but different key:
|
||||
INSERT INTO temporal_rng VALUES
|
||||
(2, '[2000-01-01,2001-01-01)');
|
||||
-- should fail:
|
||||
INSERT INTO temporal_rng VALUES
|
||||
(1, '[2000-06-01,2001-01-01)');
|
||||
|
||||
-- Foreign key
|
||||
CREATE TABLE temporal_fk_rng2rng (
|
||||
id integer,
|
||||
valid_at daterange,
|
||||
parent_id integer,
|
||||
CONSTRAINT temporal_fk_rng2rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS),
|
||||
CONSTRAINT temporal_fk_rng2rng_fk FOREIGN KEY (parent_id, PERIOD valid_at)
|
||||
REFERENCES temporal_rng (id, PERIOD valid_at)
|
||||
);
|
||||
\d temporal_fk_rng2rng
|
||||
SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname = 'temporal_fk_rng2rng_fk';
|
||||
|
||||
-- okay
|
||||
INSERT INTO temporal_fk_rng2rng VALUES
|
||||
(1, '[2000-01-01,2001-01-01)', 1);
|
||||
-- okay spanning two parent records:
|
||||
INSERT INTO temporal_fk_rng2rng VALUES
|
||||
(2, '[2000-01-01,2002-01-01)', 1);
|
||||
-- key is missing
|
||||
INSERT INTO temporal_fk_rng2rng VALUES
|
||||
(3, '[2000-01-01,2001-01-01)', 3);
|
||||
-- key exist but is outside range
|
||||
INSERT INTO temporal_fk_rng2rng VALUES
|
||||
(4, '[2001-01-01,2002-01-01)', 2);
|
||||
-- key exist but is partly outside range
|
||||
INSERT INTO temporal_fk_rng2rng VALUES
|
||||
(5, '[2000-01-01,2002-01-01)', 2);
|
Reference in New Issue
Block a user