hi.
I realized that we can also modify attgenerated when updating the generated
expression using ALTER COLUMN SET EXPRESSION.
so POC attached.
I have also considered using ALTER TABLE ALTER COLUMN STORED/VIRTUAL
to change attgenerated,
but since we can update both the generated expression and attgenerated
simultaneously, extending ALTER COLUMN SET EXPRESSION seems more better
than ALTER COLUMN {STORED|VIRTUAL}
example syntax explanation:
ALTER TABLE gtest29 ALTER COLUMN b SET EXPRESSION AS (a * 3);
exists syntax, nothing changed.
ALTER TABLE gtest29 ALTER COLUMN b SET EXPRESSION AS (a * 3) STORED;
column b attgenerated will be set to ATTRIBUTE_GENERATED_STORED,
table rewrite will happen.
ALTER TABLE gtest29 ALTER COLUMN b SET EXPRESSION AS (a * 3) VIRTUAL;
column b attgenerated will set to ATTRIBUTE_GENERATED_VIRTUAL,
table rewrite will not happen. (VACUUM FULL will make that column
values as 0, isnull as true).
what do you think?