Re: Prevent foreign key references to unlogged partitions

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Subject: Re: Prevent foreign key references to unlogged partitions
Date: 2026-11-11 13:07:42
Message-ID: CAHGQGwGPYHGZjLLxuSFgE_WXjObc7eDwRxdTY=-RyOtNq=HYbw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 11, 2026 at 8:24 PM Aleksander Alekseev
<aleksander(at)tigerdata(dot)com> wrote:
> Thanks for the patch. Looks good to me. Changing the CF entry status to RfC.

Even with the v2 patch, the following steps seem to allow a permanent table
to reference an unlogged partition. Is this an issue?

----------------------
CREATE TABLE pk (i int PRIMARY KEY) PARTITION BY RANGE (i);
CREATE UNLOGGED TABLE pk1 PARTITION OF pk FOR VALUES FROM (0) TO (100);
CREATE UNLOGGED TABLE fk (x int);
ALTER TABLE fk SET LOGGED, ADD CONSTRAINT fk_pk FOREIGN KEY (x) REFERENCES pk;
----------------------

AFAIR, earlier versions allowed unlogged partitioned tables to have permanent
partitions. In those versions, would the check added by this patch still work
as expected in that case?

Regards,

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-11-11 13:09:22 Re: UNDO with FILEOPS, and the FLUX table AM
Previous Message Greg Burd 2026-11-11 13:02:37 Re: UNDO with FILEOPS, and the FLUX table AM