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:46:02 |
Message-ID: | Z-vD6oJjKqgeST0L@msg.df7cb.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Re: Luca Vallisa
> The provided version throws an error.
Ok, I can confirm this.
This throws an error like it should:
create table test (
id_1 int4 not null,
id_2 int4 not null,
parent_id_2 int4 null,
primary key (id_1, id_2),
foreign key (id_1, parent_id_2) references test (id_1, id_2)
);
insert into test values (1, 1, null), (1, 2, 1);
delete from test where (id_1, id_2) = (1, 1);
On a partitioned table, it does not throw the error:
create table test (
id_1 int4 not null,
id_2 int4 not null,
parent_id_2 int4 null,
primary key (id_1, id_2),
foreign key (id_1, parent_id_2) references test (id_1, id_2)
) partition by list (id_1);
create table test_1 partition of test for values in (1);
insert into test values (1, 1, null), (1, 2, 1);
delete from test where (id_1, id_2) = (1, 1);
Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Milan Novotny | 2025-04-01 13:13:08 | Summing of INTERVAL returns incorrect number of days and hours |
Previous Message | Luca Vallisa | 2025-04-01 10:24:46 | Re: Self referential foreign keys in partitioned table not working as expected |