From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | bug, ALTER TABLE call ATPostAlterTypeCleanup twice for the same relation |
Date: | 2025-09-27 09:54:00 |
Message-ID: | CACJufxHZsgn3zM5g-x7YmtFGzNDnRwR07S+GYfiUs+tZ45MDDw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
hi.
bug demo:
drop table if exists gtest25;
CREATE TABLE gtest25 (a0 int, a int, b int GENERATED ALWAYS AS (a * 2
+ a0) STORED);
alter table gtest25 add constraint cc check (b > 0);
alter table gtest25 alter column b set data type int8, ALTER COLUMN b
SET EXPRESSION AS (a * 3 + a0);
ERROR: cache lookup failed for constraint 18432
ALTER COLUMN SET EXPRESSION only in 17, so it's a 17 and up related bug.
The reason is ATRewriteCatalogs->ATPostAlterTypeCleanup is called
twice for the same relation.
the second time you call it, the constraint cc is already dropped,
then the "cache lookup failed" error will happen.
While at it, maybe we can also polish the comment below in ATRewriteCatalogs.
/*
* After the ALTER TYPE or SET EXPRESSION pass, do cleanup work
* (this is not done in ATExecAlterColumnType since it should be
* done only once if multiple columns of a table are altered).
*/
but I didn't do it...
Attachment | Content-Type | Size |
---|---|---|
v1-0001-ALTER-TABLE-each-relation-call-ATPostAlterTypeCleanup-only-once.patch | text/x-patch | 4.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2025-09-27 10:43:13 | Re: Fixing MSVC's inability to detect elog(ERROR) does not return |
Previous Message | Daniil Davydov | 2025-09-27 09:20:45 | Re: Fix bug with accessing to temporary tables of other sessions |