1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

Fix ALTER TABLE ADD COLUMN ... PRIMARY KEY so that the new column is correctly

checked to see if it's been initialized to all non-nulls.  The implicit NOT
NULL constraint was not being checked during the ALTER (in fact, not even if
there was an explicit NOT NULL too), because ATExecAddColumn neglected to
set the flag needed to make the test happen.  This has been broken since
the capability was first added, in 8.0.

Brendan Jurd, per a report from Kaloyan Iliev.
This commit is contained in:
Tom Lane
2008-04-24 20:17:59 +00:00
parent dcd4075379
commit 701e71cf09
3 changed files with 28 additions and 1 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242 2008/02/07 17:09:51 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242.2.1 2008/04/24 20:17:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3237,6 +3237,11 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
tab->newvals = lappend(tab->newvals, newval);
}
/*
* If the new column is NOT NULL, tell Phase 3 it needs to test that.
*/
tab->new_notnull |= colDef->is_not_null;
/*
* Add needed dependency entries for the new column.
*/