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