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

Поиск
Список
Период
Сортировка
От Amul Sul
Тема Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression
Дата
Msg-id CAAJ_b944uerJG+hsXYtBvULoddRFfXGB7i2C2VQ6Bcd7R6E4BQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression  (Peter Eisentraut <peter@eisentraut.org>)
Ответы Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression  (Peter Eisentraut <peter@eisentraut.org>)
Список pgsql-hackers
On Mon, Dec 18, 2023 at 3:01 PM Peter Eisentraut <peter@eisentraut.org> wrote:
On 11.12.23 13:22, Amul Sul wrote:
>
>     create table t1 (a int, b int generated always as (a + 1) stored);
>     alter table t1 add column c int, alter column b set expression as (a
>     + c);
>     ERROR:  42703: column "c" does not exist
>
>     I think intuitively, this ought to work.  Maybe just moving the new
>     pass
>     after AT_PASS_ADD_COL would do it.
>
>
> I think we can't support that (like alter type) since we need to place
> this new
> pass before AT_PASS_OLD_INDEX & AT_PASS_OLD_CONSTR to re-add indexes and
> constraints for the validation.

Could we have AT_PASS_ADD_COL before AT_PASS_OLD_*?  So overall it would be

...
AT_PASS_ALTER_TYPE,
AT_PASS_ADD_COL,         // moved
AT_PASS_SET_EXPRESSION,  // new
AT_PASS_OLD_INDEX,
AT_PASS_OLD_CONSTR,
AT_PASS_ADD_CONSTR,
...

This appears to not break any existing tests.

(Sorry, for the delay)

Agree. I did that change in 0001 patch. 

Regards,
Amul


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ayush Vatsa
Дата:
Сообщение: Re: Proposal to include --exclude-extension Flag in pg_dump
Следующее
От: Nazir Bilal Yavuz
Дата:
Сообщение: Re: Show WAL write and fsync stats in pg_stat_io