Обсуждение: Re: ALTER TABLE with multiple SET NOT NULL

Поиск
Список
Период
Сортировка

Re: ALTER TABLE with multiple SET NOT NULL

От
Sergei Kornilov
Дата:
Hello

I investigate this bug and found reason:
>  alter table t1 add column b float8 not null default random(), add primary key(a);

Here we call ATController (src/backend/commands/tablecmds.c) with two cmds: AT_AddColumn and AT_AddIndex
Then we go to phase 2 in ATRewriteCatalogs:
- succesful add new attribute, but without table rewrite - it will be later in phase 3
- call ATExecAddIndex, we want add primary key, so we call index_check_primary_key.
index_check_primary_key call AlterTableInternal and therefore another ATController with independent one AT_SetNotNull
command.
ATController will call phase 2, and then its own phase 3 with validation all constraints. But at this nested level we
haveno AlteredTableInfo->newvals and we do not proper transform tuple.
 

not sure how we can proper rewrite this case.

regards, Sergei