summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-24 20:17:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-24 20:17:59 +0000
commit701e71cf098db8e1969b2f3a04cf528b949f87d2 (patch)
treef991b1598679fd9f7ac0a9dff4228c38148f1aef /src/backend/commands/tablecmds.c
parentdcd4075379458783e035fd0a5f6bb758ba4700a2 (diff)
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.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 027fe51eca4..18069b808e0 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -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 $
*
*-------------------------------------------------------------------------
*/
@@ -3238,6 +3238,11 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
}
/*
+ * 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.
*/
add_column_datatype_dependency(myrelid, i, attribute->atttypid);