Re: Fix inherited constraint loss in ALTER COLUMN SET EXPRESSION

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix inherited constraint loss in ALTER COLUMN SET EXPRESSION
Date: 2026-09-09 00:40:31
Message-ID: CACJufxHV4ChuzFLyHdL8=ZxYiBjaqEcNsN6uA08xkj9JR23ckQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 8, 2026 at 5:15 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi,
>
> Here is a simple repro

> evantest=# create table p (a int, b int generated always as (a*2) virtual, check (b<100));
> evantest=# create table c () inherits (p);
> evantest=# alter table c alter b set expression as (a*3);

See https://www.postgresql.org/message-id/flat/CACJufxEomSz3BwUGfk8A6MeAKj%3DCki5B%2BgYTbJO%3DACCJyytWZg%40mail.gmail.com
It seems my latest patch isn't working; I need to rebase it.

ALTER TABLE ONLY SET EXPRESSION also doesn't work in some cases.

> Is this a PG19-new bug? Not really. PG19 allows SET EXPRESSION on virtual generated columns with CHECK constraints, but PG17 introduced SET EXPRESSION for stored generated columns. This fix covers both virtual and stored generated columns, so ideally it can be back-patched to PG17.
>

The required change is too extensive. For older branches, I think we
should raise an error, treating this as a new feature for the master
branch.

--
jian
https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-09-09 00:40:40 Re: [PATCH] Optimization: avoid repeated strlen() calls in function CreateTriggerFiringOn when parsing trigger arguments
Previous Message Noah Misch 2026-09-09 00:03:57 Re: pg_dump: assert failure sorting casts/transforms