PERIOD foreign key feature

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: PERIOD foreign key feature
Date: 2024-05-07 14:54:30
Message-ID: ZjpApuq8I9DE5Elv@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In this commit:

commit 34768ee3616
Author: Peter Eisentraut <peter(at)eisentraut(dot)org>
Date: Sun Mar 24 07:37:13 2024 +0100

Add temporal FOREIGN KEY contraints

Add PERIOD clause to foreign key constraint definitions. This is
supported for range and multirange types. Temporal foreign keys check
for range containment instead of equality.

This feature matches the behavior of the SQL standard temporal foreign
keys, but it works on PostgreSQL's native ranges instead of SQL's
"periods", which don't exist in PostgreSQL (yet).

Reference actions ON {UPDATE,DELETE} {CASCADE,SET NULL,SET DEFAULT}
are not supported yet.

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

this text was added to create_table.sgml:

In addition, the referenced table must have a primary
key or unique constraint declared with <literal>WITHOUT
--> OVERLAPS</literal>. Finally, if one side of the foreign key
--> uses <literal>PERIOD</literal>, the other side must too. If the
<replaceable class="parameter">refcolumn</replaceable> list is
omitted, the <literal>WITHOUT OVERLAPS</literal> part of the
primary key is treated as if marked with <literal>PERIOD</literal>.

In the two marked lines, it says "if one side of the foreign key uses
PERIOD, the other side must too." However, looking at the example
queries, it seems like if the foreign side has PERIOD, the primary side
must have WITHOUT OVERLAPS, not PERIOD.

Does this doc text need correcting?

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Only you can decide what is important to you.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2024-05-07 15:23:52 Re: PERIOD foreign key feature
Previous Message Tom Lane 2024-05-07 14:49:29 Re: pg_restore -N loses extension comment