From: Alexander Lakhin <exclusion@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tender Wang <tndrwang@gmail.com>
Cc: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Cc: Junwang Zhao <zhjwpku@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Guillaume Lelarge <guillaume@lelarge.info>
Cc: Michael Paquier <michael@paquier.xyz>
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Date: Fri, 25 Oct 2024 17:00:00 +0300
Message-ID: <a6b7545b-a99a-7009-8161-0ac149efec3f@gmail.com> (raw)
In-Reply-To: <461e9c26-2076-8224-e119-84998b6a784e@gmail.com>
References: <202410221432.3qtqbk2q6o7q@alvherre.pgsql>
<461e9c26-2076-8224-e119-84998b6a784e@gmail.com>
Hello Alvaro and Tender Wang,
24.10.2024 17:00, Alexander Lakhin wrote:
> Please look at a new anomaly introduced with 53af9491a. When running the
> following script:
> CREATE TABLE t (a int, b int, PRIMARY KEY (a, b));
> CREATE TABLE pt (a int, b int, FOREIGN KEY (a, b) REFERENCES t(a, b))
> PARTITION BY LIST (a);
>
> CREATE TABLE tp1 (x int, a int, b int);
> ALTER TABLE tp1 DROP COLUMN x;
>
> ALTER TABLE pt ATTACH PARTITION tp1 FOR VALUES IN (1);
>
> ALTER TABLE pt DETACH PARTITION tp1;
I've also discovered another anomaly with a similar setup, but it's not
related to 53af9491a.
CREATE TABLE t (a int, PRIMARY KEY (a));
INSERT INTO t VALUES (1);
CREATE TABLE pt (b int, a int) PARTITION BY RANGE (a);
ALTER TABLE pt DROP COLUMN b;
ALTER TABLE pt ADD FOREIGN KEY (a) REFERENCES t ON DELETE SET DEFAULT (a);
CREATE TABLE tp1 PARTITION OF pt FOR VALUES FROM (1) TO (2);
ALTER TABLE pt DETACH PARTITION tp1;
DELETE FROM t;
\d+ t
This script ends up with:
ERROR: invalid attribute number 2
ERROR: cache lookup failed for attribute 2 of relation 16398
(Perhaps it deserves a separate discussion.)
Best regards,
Alexander
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-hackers@postgresql.org
Cc: exclusion@gmail.com, alvherre@alvh.no-ip.org, tndrwang@gmail.com, jgdr@dalibo.com, zhjwpku@gmail.com, guillaume@lelarge.info, michael@paquier.xyz
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
In-Reply-To: <a6b7545b-a99a-7009-8161-0ac149efec3f@gmail.com>
* 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