From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 1482694023@qq.com
Subject: BUG #19777: PERIOD foreign key rejects an empty referencing range even though the referenced period covers it
Date: Tue, 20 Oct 2026 09:14:48 +0000
Message-ID: <19777-e1090cf88c970b8b@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19777
Logged by: N J
Email address: 1482694023@qq.com
PostgreSQL version: 18.6
Operating system: Windows 11 x64
Description:
Tested with PostgreSQL 18.6 on Windows 11 x64. No extensions or non-default
configuration are required.
On a fresh connection, run the setup and check:
CREATE TEMP TABLE period_parent_minimal (
k int4range NOT NULL,
p int4range NOT NULL,
PRIMARY KEY (k, p WITHOUT OVERLAPS)
);
INSERT INTO period_parent_minimal
VALUES ('[1,2)'::int4range, '[0,10)'::int4range);
CREATE TEMP TABLE period_child_minimal (
k int4range NOT NULL,
p int4range NOT NULL,
FOREIGN KEY (k, PERIOD p)
REFERENCES period_parent_minimal (k, PERIOD p)
);
SELECT range_agg(p) @> 'empty'::int4range AS parent_covers_empty
FROM period_parent_minimal
WHERE k = '[1,2)'::int4range;
The SELECT returns true. Then run:
INSERT INTO period_child_minimal
VALUES ('[1,2)'::int4range, 'empty'::int4range);
Actual result: rejected with SQLSTATE 23503 (foreign key violation).
Expected result: the insert should succeed if an empty referencing period is
considered covered by the referenced period, consistent with range
containment and the documented PERIOD foreign-key coverage rule. Please
confirm whether empty referencing periods are intended to satisfy PERIOD
foreign keys.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, 1482694023@qq.com
Subject: Re: BUG #19777: PERIOD foreign key rejects an empty referencing range even though the referenced period covers it
In-Reply-To: <19777-e1090cf88c970b8b@postgresql.org>
References: <19777-e1090cf88c970b8b@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox