Re: Self referential foreign keys in partitioned table not working as expected

From: Christoph Berg <myon(at)debian(dot)org>
To: Luca Vallisa <luca(dot)vallisa(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Self referential foreign keys in partitioned table not working as expected
Date: 2025-04-01 10:18:30
Message-ID: Z-u9dhA5ikSgOul9@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: Luca Vallisa
> create table test (
> id_1 int4 not null,
> id_2 int4 not null,
> parent_id_1 int4 null,
> primary key (id_1, id_2),
> foreign key (parent_id_1, id_2) references test(id_1, id_2)
> ) partition by list(id_1);
>
> insert into test values (1, 1, null), (1, 2, 1);

Multi-column foreign keys where one column is NULL effectively disable
the FK, this is not specific to partitioned tables. They works as
designed, but best avoid them.

Christoph

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Luca Vallisa 2025-04-01 10:24:46 Re: Self referential foreign keys in partitioned table not working as expected
Previous Message Luca Vallisa 2025-04-01 09:06:13 Self referential foreign keys in partitioned table not working as expected