Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xG8yX-000000027GK-3S3f for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Oct 2026 05:53:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xG8yW-00000006k6W-3RkE for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Oct 2026 05:53:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xFYj8-0000000369w-0KRx for pgsql-bugs@lists.postgresql.org; Sat, 10 Oct 2026 15:11:10 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xFYj5-00000001LZh-3TNj for pgsql-bugs@lists.postgresql.org; Sat, 10 Oct 2026 15:11:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=eVeTi5og7gweK4QISZfYcbtRu3xG2t9JXQPVmkOzQzs=; b=cAwd2nOdpcp8h/JlqaXd7FQNDn 8SmBWvTU0WjY5cqUtolqmyF0v5lC06o2Xz016S43duIrRYYL4Ov5ozevm3rgXJ+51+jpE0J4MwBW9 U8IsOxlDegxciaPcuQ1ds4frsm7HPK0aiktOQJw+sW3XccE4vwxIK97zzJdDTMA4nK8R0xxIS/lb2 qYPVdzqg46OpYpLJbYRLH5F9PmseoHcpEq7qNdUYSZoglsVA+JEUwfk/JNrMGfysJfpa+7ggI/Q5Y XScLhQ7KCNI8TImDjoTlopfwj4SOe3iaE2hyD9APjy05hMb0Cm37VsF8alaq9xt7rqVCpSWqlIN5k aKu6uXnA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xFYj2-00000003yAR-3lpD for pgsql-bugs@lists.postgresql.org; Sat, 10 Oct 2026 15:11:07 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xFYj1-0000000BlUp-3VEL for pgsql-bugs@lists.postgresql.org; Sat, 10 Oct 2026 15:11:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19753: PERIOD foreign key rejects an empty referencing range although the coverage test returns true To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1482694023@qq.com Reply-To: 1482694023@qq.com, pgsql-bugs@lists.postgresql.org Date: Sat, 10 Oct 2026 15:10:24 +0000 Message-ID: <19753-e0e5fc5bef24f5ab@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: =20 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 =3D 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)=3D(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.