Hello

On Mon, 16 Nov 2026, Nikhil Sontakke <[email protected]> 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.


Reply via email to