From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 1482694023@qq.com
Subject: BUG #19753: PERIOD foreign key rejects an empty referencing range although the coverage test returns true
Date: Sat, 10 Oct 2026 15:10:24 +0000
Message-ID: <19753-e0e5fc5bef24f5ab@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19753
Logged by: N J
Email address: 1482694023@qq.com
PostgreSQL version: 18.6
Operating system: Windows 11 64-bit
Description:
PostgreSQL version: 18.6
Client: pgAdmin 4
Operating system: Windows 11 64-bit
Steps to reproduce:
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE TEMP TABLE parent_period (
k integer NOT NULL,
p int4range NOT NULL,
PRIMARY KEY (k, p WITHOUT OVERLAPS)
);
INSERT INTO parent_period VALUES (1, '[0,10)'::int4range);
CREATE TEMP TABLE child_period (
k integer NOT NULL,
p int4range NOT NULL,
FOREIGN KEY (k, PERIOD p)
REFERENCES parent_period (k, PERIOD p)
);
SELECT range_agg(p) @> 'empty'::int4range AS covered
FROM parent_period
WHERE k = 1;
The SELECT returns true.
Then run:
INSERT INTO child_period VALUES (1, 'empty'::int4range);
Actual result:
The INSERT fails with SQLSTATE 23503 (foreign_key_violation):
Key (k, p)=(1, empty) is not present in table "parent_period".
Expected result:
I expected the INSERT to succeed because the referencing period is empty and
the coverage query returns true. This expectation follows the documented
PERIOD foreign-key coverage rule and the set-containment behavior of empty
ranges.
The behavior appears inconsistent between the coverage query and PERIOD
foreign-key enforcement. I have reproduced it on this installation, but have
not established the underlying cause.
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 #19753: PERIOD foreign key rejects an empty referencing range although the coverage test returns true
In-Reply-To: <19753-e0e5fc5bef24f5ab@postgresql.org>
References: <19753-e0e5fc5bef24f5ab@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