From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgp@gmx.it
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it
Date: Tue, 13 Jun 2023 11:12:51 -0400
Message-ID: <1636674.1686669171@sss.pgh.pa.us> (raw)
In-Reply-To: <17970-63daec21cbb50126@postgresql.org>
References: <17970-63daec21cbb50126@postgresql.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgp@gmx.it, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17970: FEATURE REQUEST-allow re-adding GENERATED ALWAYS AS constraint to existing columns after removing it
In-Reply-To: <1636674.1686669171@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox