Re: ALTER TABLE with multiple SET NOT NULL - Mailing list pgsql-hackers

From Sergei Kornilov
Subject Re: ALTER TABLE with multiple SET NOT NULL
Date
Msg-id 1189371547032318@sas2-80cfc068821c.qloud-c.yandex.net
Whole thread Raw
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Michael Banck
Date:
Subject: Misleading panic message in backend/access/transam/xlog.c
Next
From: Magnus Hagander
Date:
Subject: Re: Misleading panic message in backend/access/transam/xlog.c