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

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression
Date: 2023-11-20 07:42:00
Message-ID: 394d8c0f-4085-48c7-a833-b5bacea49ecb@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 17.11.23 13:25, Amul Sul wrote:
> To fix this we should be doing something like ALTER COLUMN TYPE and the pass
> should be AT_PASS_ALTER_TYPE (rename it or invent a new one near to that) so
> that in ATRewriteCatalogs(), we would execute ATPostAlterTypeCleanup().
>
> I simply tried that by doing blind copy of code from
> ATExecAlterColumnType() in
> 0002 patch.  We don't really need to do all the stuff such as re-adding
> indexes, constraints etc, but I am out of time for today to figure out the
> optimum code and I will be away from work in the first half of the coming
> week and the week after that. Therefore, I thought of sharing an approach to
> get comments/thoughts on the direction, thanks.

The exact sequencing of this seems to be tricky. It's clear that we
need to do it earlier than at the end. I also think it should be
strictly after AT_PASS_ALTER_TYPE so that the new expression can refer
to the new type of a column. It should also be after AT_PASS_ADD_COL,
so that the new expression can refer to any newly added column. But
then it's after AT_PASS_OLD_INDEX and AT_PASS_OLD_CONSTR, is that a problem?

(It might be an option for the first version of this feature to not
support altering columns that have constraints on them. But we do need
to support columns with indexes on them. Does that work ok? Does that
depend on the relative order of AT_PASS_OLD_INDEX?)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-11-20 07:47:19 Re: Show WAL write and fsync stats in pg_stat_io
Previous Message Michael Paquier 2023-11-20 07:34:11 Re: PATCH: Add REINDEX tag to event triggers