From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tender Wang <tndrwang@gmail.com>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18541: Reattaching a partition referenced by a foreign key fails with an error
Date: Wed, 7 Aug 2024 14:44:55 -0400
Message-ID: <202408071844.d7mzelswgpdu@alvherre.pgsql> (raw)
In-Reply-To: <CAHewXNkcJo3d9Qj00FGof9dpHg8A4W9x-XJx9EsfrS8w7M395Q@mail.gmail.com>
On 2024-Jul-15, Tender Wang wrote:
> PG Bug reporting form <noreply@postgresql.org> 于2024年7月15日周一 21:02写道:
>
> > The following script:
> > CREATE TABLE t1 (a int, PRIMARY KEY (a));
> > CREATE TABLE t (a int, PRIMARY KEY (a), FOREIGN KEY (a) REFERENCES t1)
> > PARTITION BY LIST (a);
> > ALTER TABLE t ATTACH PARTITION t1 FOR VALUES IN (1);
> > ALTER TABLE t DETACH PARTITION t1;
> > ALTER TABLE t ATTACH PARTITION t1 FOR VALUES IN (1);
> >
> > ends up with the error complaining about check triggers:
> > ERROR: XX000: could not find ON INSERT check triggers of foreign key
> > constraint 16400
> > LOCATION: GetForeignKeyCheckTriggers, tablecmds.c:11260
> I saw the same error in [1]. I guess it is same issue.
> I send a patch in [1], but it may need a more work.
I think this schema is nuts. Do you have a practical use for something
like this?
I am tempted to fix this by dictating that you can't join a table as a
partition if the partitioned table contains an FK that references that
table.
FWIW the patch I have fixes all the other reported problems with FKs and
partitioned tables, but not this one.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
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@alvh.no-ip.org, tndrwang@gmail.com, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18541: Reattaching a partition referenced by a foreign key fails with an error
In-Reply-To: <202408071844.d7mzelswgpdu@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