Re: [PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns

From: Henson Choi <assam258(at)gmail(dot)com>
To: Nitin Motiani <nitinmotiani(at)google(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: [PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns
Date: 2026-12-03 16:39:08
Message-ID: CAAAe_zAGBcgPx5B20+wkphHJdMTfEXf5bGddNQuBHe9dsqtQxA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Nitin,

> A gentle ping on v3. It still applies to master and CFBot is green;
> the only change from v2 is the rename you suggested. If you have
> further comments, please let me know. If v3 looks fine, would you be
> willing to mark it Ready for Committer on the CommitFest entry [1]?

Thanks for the ping, and sorry for the delay. I looked at v3 again.
The new name reads well, and it applies cleanly to current master.

A commit that went in after my v2 review adds one thing to do,
though. Since 0b0f5c5af11 ("Forbid ALTERing column type by default
when other objects depend on it", back-patched to 14), SET
EXPRESSION on a STORED column fails if views, function bodies and
the like use the table's row type. pg_dump restores such objects
before the attrdefs, so the child's SET EXPRESSION fails when
restoring a v3 dump:

CREATE TABLE p (x int, g int GENERATED ALWAYS AS (x * 2) STORED);
CREATE TABLE c () INHERITS (p);
ALTER TABLE ONLY c ALTER COLUMN g SET EXPRESSION AS (x * 3);
INSERT INTO c VALUES (1);
CREATE VIEW v AS SELECT ROW(1, 3)::c AS r;

ERROR: cannot alter table "c" because rule _RETURN on view public.v uses
its row type

The same happens with a BEGIN ATOMIC function (function public.f()
uses its row type) or a column of that type in another table (column
"audit.old_row" uses its row type). The restored c.g stays (x * 2),
and with -1 the whole restore aborts.

The SET EXPRESSION defect that drops inherited CHECK and NOT NULL
constraints I still see as I said in my v2 review: a backend problem
separate from this patch.

Once this is fixed, I will mark it Ready for Committer.

Best regards,
Henson

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayoub Kazar 2026-12-03 16:44:37 Should we retain spilled hash tables across rescans?
Previous Message Heikki Linnakangas 2026-12-03 16:07:50 Re: add --transfer-mode to pg_upgrade