pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Christoph Berg <myon@debian.org>
Cc: 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: Wed, 23 Jul 2025 11:27:04 +0200
Message-ID: <202507230927.jnoadaq5v62v@alvherre.pgsql> (raw)
In-Reply-To: <Z-vD6oJjKqgeST0L@msg.df7cb.de>

On 2025-Apr-01, Christoph Berg wrote:

> Re: Luca Vallisa
> > The provided version throws an error.
> 
> Ok, I can confirm this.

> 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);

FWIW I didn't give closure on this thread, but AFAICT this is the same
bug that was reported in
https://postgr.es/m/18156-a44bc7096f0683e6@postgresql.org
and
https://postgr.es/m/CAECtzeWHCA+6tTcm2Oh2+g7fURUJpLZb-=pRXgeWJ-Pi+VU=_w@mail.gmail.com

That was fixed a couple of months ago.  The above script throws an error
as it should.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/





view thread (5+ messages)

Message-ID: <202507230927.jnoadaq5v62v@alvherre.pgsql>
Permalink:  ../202507230927.jnoadaq5v62v@alvherre.pgsql/
Also on:    postgresql.org/message-id/202507230927.jnoadaq5v62v@alvherre.pgsql

 · 

reply

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: alvherre@kurilemu.de, 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: <202507230927.jnoadaq5v62v@alvherre.pgsql>

* 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