Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

From: Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression
Date: 2023-08-24 04:06:12
Message-ID: CA+vB=AE-nOqSSSUz62inN6XGKvG9_d7NN2GSa95ZgP7SSjpCEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Amul,

On Wed, Aug 2, 2023 at 4:06 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:

> Hi,
>
> Currently, we have an option to drop the expression of stored generated
> columns
> as:
>
> ALTER [ COLUMN ] column_name DROP EXPRESSION [ IF EXISTS ]
>
> But don't have support to update that expression. The attached patch
> provides
> that as:
>
> ALTER [ COLUMN ] column_name SET EXPRESSION expression
>
> +1 to the idea.

Here are few review comments:.
*0001 patch*
1. Alignment changed for below comment:

> AT_ColumnExpression, /* alter column drop expression */

*00002 patch*
1. EXPRESSION should be added after DEFAULT per alphabetic order?

> + COMPLETE_WITH("(", "COMPRESSION", "EXPRESSION", "DEFAULT", "GENERATED",
> "NOT NULL", "STATISTICS", "STORAGE",
>

2. The variable *isdrop* can be aligned better:

> + bool isdrop = (cmd->def == NULL);
>

3. The AlteredTableInfo structure has member Relation, So need to pass
parameter Relation separately?

> static ObjectAddress ATExecColumnExpression(AlteredTableInfo *tab,
> Relation rel,
> const char *colName, Node *newDefault,
> bool missing_ok, LOCKMODE lockmode);
>

4. Exceeded 80 char limit:

> /*
> * Mark the column as no longer generated. (The atthasdef flag needs to
>

5. Update the comment. Use 'set' along with 'drop':

> AT_ColumnExpression, /* alter column drop expression */

Thanks,
Vaibhav Dalvi

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-08-24 06:10:14 Re: Cirrus-ci is lowering free CI cycles - what to do with cfbot, etc?
Previous Message Amit Kapila 2023-08-24 03:45:36 Re: subscription/015_stream sometimes breaks