[patch] ALTER COLUMN SET EXPRESSION [GENERATED|STORED] - Mailing list pgsql-hackers

From jian he
Subject [patch] ALTER COLUMN SET EXPRESSION [GENERATED|STORED]
Date
Msg-id CACJufxGXLU400QBBgdoboaza0xK58rQqsCAPrxbAMUmo0f8xCQ@mail.gmail.com
Whole thread Raw
List pgsql-hackers
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?

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy
Next
From: Dilip Kumar
Date:
Subject: Re: Potential problem in commit f777d773878 and 4f7f7b03758