Re: ALTER TABLE with multiple SET NOT NULL

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Allison Kaptur <allison(dot)kaptur(at)gmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE with multiple SET NOT NULL
Date: 2019-01-09 11:11:58
Message-ID: 1189371547032318@sas2-80cfc068821c.qloud-c.yandex.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general 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 have no AlteredTableInfo->newvals and we do not proper transform tuple.

not sure how we can proper rewrite this case.

regards, Sergei

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2019-01-09 16:27:37 Re: (multiplatform) replication problem
Previous Message Nicolas Karolak 2019-01-09 06:51:15 Re: multiple configurations with repmgr

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2019-01-09 11:12:42 Re: Misleading panic message in backend/access/transam/xlog.c
Previous Message Michael Banck 2019-01-09 11:06:39 Misleading panic message in backend/access/transam/xlog.c