From: Christoph Berg <myon@debian.org>
To: Luca Vallisa <luca.vallisa@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Self referential foreign keys in partitioned table not working as expected
Date: Tue, 1 Apr 2025 12:46:02 +0200
Message-ID: <Z-vD6oJjKqgeST0L@msg.df7cb.de> (raw)
In-Reply-To: <CAAT=mysWBFOPfDZGW9hahRkThBgDeoHhMDJ-q5GsxoRd4+YDtg@mail.gmail.com>
References: <CAAT=myvsiF-Attja5DcWoUWh21R12R-sfXECY2-3ynt8kaOqjw@mail.gmail.com>
<Z-u9dhA5ikSgOul9@msg.df7cb.de>
<CAAT=mysWBFOPfDZGW9hahRkThBgDeoHhMDJ-q5GsxoRd4+YDtg@mail.gmail.com>
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
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: myon@debian.org, luca.vallisa@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Self referential foreign keys in partitioned table not working as expected
In-Reply-To: <Z-vD6oJjKqgeST0L@msg.df7cb.de>
* 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