| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | Nikhil Sontakke <nikhil(at)planetscale(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Manu <manuelreyesbravo(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Dropping a composite attribute causes data integrity violations |
| Date: | 2026-11-16 22:41:54 |
| Message-ID: | CAN4CZFNc+sqs_bjLUE0fw0fda63arRtS484TES3R_UGnAdLKjA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello
On Mon, 16 Nov 2026, Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com> wrote:
> v3 missed columns dropped by cascading from their datatype:
This new check can cause temp tablespace cleanup to fail:
CREATE DOMAIN pg_temp.d AS int;
CREATE TYPE ct AS (a int, b pg_temp.d);
CREATE TABLE t (c ct UNIQUE);
INSERT INTO t VALUES (ROW(1,2)), (ROW(1,3));
DISCARD TEMP;
-- ERROR: cannot alter type "ct" because column "t.c" uses it
At session exit we even get a FATAL in the log, and it also causes
issues for the next session that gets the same tablespace.
With a temp table instead of a domain, it breaks autovacuum completely
for the database:
LOG: autovacuum: dropping orphan temp table "postgres.pg_temp_0.tt"
ERROR: cannot alter type "ct" because column "p.c" uses it
And even in the previous version, BEGIN ATOMIC functions using the row
type now block DROP COLUMN, even with CASCADE:
CREATE TABLE person (id int, first text, middle text, last text);
CREATE FUNCTION full_name(person) RETURNS text
BEGIN ATOMIC SELECT $1.first || ' ' || $1.last; END;
ALTER TABLE person DROP COLUMN middle;
ALTER TABLE person DROP COLUMN middle CASCADE; -- also errors
Note that the function doesn't use middle, so I think even the first
error is a bug, but the second with CASCADE is definitely: without the
patch, if the body does use middle, the alter drops the function. With
the patch, it errors instead.
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Heikki Linnakangas | 2026-11-16 22:32:28 | Fix two race conditions in processing interrupts |