Re: BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it
Date
Msg-id 1636674.1686669171@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> From what I know, it is possible to transform a GENERATED ALWAYS AS ..
> STORED column into a normal one, by using:
> ALTER TABLE items ALTER COLUMN transformed_id DROP EXPRESSION;
> But the reverse (i.e. re-adding the "GENERATED ALWAYS AS .. STORED" part to
> an existing column) is not possible.

Just drop the column and re-add it.  The system would have to recompute
all the entries anyway, so I can't get excited about offering a shortcut.

> I think this is a contradiction, because, by modifying the underlying
> function, I am able to insert incoherent values in the generated column,

As David mentioned, that is not considered a supported thing.  We cannot
enforce it (look up the "halting problem" sometime), but if you change
an immutable function's behavior then ensuing problems are your fault
not Postgres'.

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it
Next
From: PG Bug reporting form
Date:
Subject: BUG #17972: Assert failed in pull_varattnos_walker() for view with subquery and security qual