Re: [GENERAL] I think this is a BUG?
| От | Tom Lane |
|---|---|
| Тема | Re: [GENERAL] I think this is a BUG? |
| Дата | |
| Msg-id | 1424.1209059182@sss.pgh.pa.us обсуждение |
| Ответ на | Re: [GENERAL] I think this is a BUG? (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: [GENERAL] I think this is a BUG?
|
| Список | pgsql-hackers |
I wrote:
> So somehow the constraint-validation code isn't getting applied in
> this case. I suspect you'll find it's a pretty localized fix.
I traced through this and found that for
alter table t1 add column f2 int not null;
transformAlterTableStmt will produce an AT_AddColumn subcommand
containing a ColumnDef with is_not_null = false, followed by an
AT_SetNotNull subcommand. But for
alter table t1 add column f2 int primary key;
it produces an AT_AddColumn subcommand containing a ColumnDef with
is_not_null = true, followed by an AT_AddIndex subcommand.
This is not super consistent, and maybe should be cleaned up;
but the intent is perfectly clear in both cases so I think tablecmds.c
should be able to do the right thing with either.
It looks to me that the appropriate fix involves doing
tab->new_notnull |= colDef->is_not_null;
somewhere in ATExecAddColumn; but I haven't tested this much.
regards, tom lane
В списке pgsql-hackers по дате отправления: