Re: ALTER COLUMN SET EXPRESSION on partitions not work in case of constraint dependencies

From: Nitin Motiani <nitinmotiani(at)google(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Alberto Piai <alberto(dot)piai(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER COLUMN SET EXPRESSION on partitions not work in case of constraint dependencies
Date: 2026-11-17 13:02:02
Message-ID: CAH5HC94F8j6u3udDaVYie6TgDCBkOVgwS02XD9gkbQVrbY0LJA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I looked at this as was mentioned on the bug fix for #19773 [1]. The
pg_dump fix for that bug restores a child's differing generation
expression with ALTER TABLE ONLY ... SET EXPRESSION. With either of
the v4 patches here, that restore fails when the child has a
constraint on the column, e.g.:

CREATE TABLE p (v int, g int GENERATED ALWAYS AS (v * 2) STORED,
CONSTRAINT p_g_pos CHECK (g > 0));
CREATE TABLE c () INHERITS (p);
ALTER TABLE ONLY c ALTER COLUMN g SET EXPRESSION AS (v * 5);
ERROR: ALTER TABLE ONLY ... SET EXPRESSION is not supported for
generated columns with dependent objects on a parent table

On master, the same ALTER succeeds but c loses the inherited CHECK.

Could the re-validate approach also cover inheritance children and
ONLY, so that such dumps restore correctly?

[1] https://www.postgresql.org/message-id/flat/CAH5HC97y7PFE6rJh8kVDUszPxGQE030nZvyHu%3DwZT7FBkOV3qA%40mail.gmail.com

Thanks & Regards,
Nitin Motiani
Google

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-11-17 13:53:23 Re: pg_stat_io_histogram
Previous Message Nitin Motiani 2026-11-17 12:59:35 Re: [PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns