aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_utilcmd.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-24 20:46:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-24 20:46:49 +0000
commit46e9709f48687af327a35f9129c971a148a73396 (patch)
tree5b1eeb7370c00017367fd9474e5867e618e2315a /src/backend/parser/parse_utilcmd.c
parentbb908d98798c79a915facee94117865d72302ea6 (diff)
downloadpostgresql-46e9709f48687af327a35f9129c971a148a73396.tar.gz
postgresql-46e9709f48687af327a35f9129c971a148a73396.zip
Remove transformAlterTableStmt's kluge to replace ColumnDef.is_not_null
flags by separate AT_SetNotNull subcommands. That was always ugly and inefficient, and it's now clear that it was merely a partial workaround for the bug just identified in ATExecAddColumn. This is just code beautification not a bug fix, so no back-patch. Brendan Jurd, with some trivial additional cleanup by me.
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r--src/backend/parser/parse_utilcmd.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 88fba239cdb..a6ec85350f1 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -19,7 +19,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.11 2008/03/25 22:42:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.12 2008/04/24 20:46:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1718,41 +1718,23 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString)
{
ColumnDef *def = (ColumnDef *) cmd->def;
- Assert(IsA(cmd->def, ColumnDef));
- transformColumnDefinition(pstate, &cxt,
- (ColumnDef *) cmd->def);
+ Assert(IsA(def, ColumnDef));
+ transformColumnDefinition(pstate, &cxt, def);
/*
* If the column has a non-null default, we can't skip
* validation of foreign keys.
*/
- if (((ColumnDef *) cmd->def)->raw_default != NULL)
+ if (def->raw_default != NULL)
skipValidation = false;
- newcmds = lappend(newcmds, cmd);
-
- /*
- * Convert an ADD COLUMN ... NOT NULL constraint to a
- * separate command
- */
- if (def->is_not_null)
- {
- /* Remove NOT NULL from AddColumn */
- def->is_not_null = false;
-
- /* Add as a separate AlterTableCmd */
- newcmd = makeNode(AlterTableCmd);
- newcmd->subtype = AT_SetNotNull;
- newcmd->name = pstrdup(def->colname);
- newcmds = lappend(newcmds, newcmd);
- }
-
/*
* All constraints are processed in other ways. Remove the
* original list
*/
def->constraints = NIL;
+ newcmds = lappend(newcmds, cmd);
break;
}
case AT_AddConstraint:
@@ -1760,7 +1742,6 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString)
/*
* The original AddConstraint cmd node doesn't go to newcmds
*/
-
if (IsA(cmd->def, Constraint))
transformTableConstraint(pstate, &cxt,
(Constraint *) cmd->def);