summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2007-06-20 18:21:51 +0000
committerTom Lane2007-06-20 18:21:51 +0000
commit01e570e68491335fa3902afdb59ca7df7e72bdcc (patch)
tree3a7b88acfca38e2949a5a9a6ca758055e7d7930d
parentcbe8af81b215392f3bd2a29170963fee29bedb90 (diff)
transformColumnDefinition failed to complain about
create table foo (bar int default null default 3); due to not thinking about the special-case handling of DEFAULT NULL. Problem noticed while investigating bug #3396.
-rw-r--r--src/backend/parser/analyze.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index b955b1f4928..3dbcd520986 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.253.2.2 2003/02/13 22:50:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.253.2.3 2007/06/20 18:21:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -793,6 +793,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
{
bool is_serial;
bool saw_nullable;
+ bool saw_default;
Constraint *constraint;
List *clist;
@@ -895,6 +896,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
transformConstraintAttrs(column->constraints);
saw_nullable = false;
+ saw_default = false;
foreach(clist, column->constraints)
{
@@ -935,11 +937,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
break;
case CONSTR_DEFAULT:
- if (column->raw_default != NULL)
+ if (saw_default)
elog(ERROR, "%s/DEFAULT multiple values specified for '%s.%s'",
cxt->stmtType, cxt->relation->relname, column->colname);
+ /* Note: DEFAULT NULL maps to constraint->raw_expr == NULL */
column->raw_default = constraint->raw_expr;
Assert(constraint->cooked_expr == NULL);
+ saw_default = true;
break;
case CONSTR_PRIMARY: