diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-20 18:21:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-20 18:21:08 +0000 |
commit | 65e67e2bb2e241e1bec0b4519c0dd8bfa1f9c30f (patch) | |
tree | 5d8f32565df037ac05136cec677d50dd2fc41359 /src | |
parent | fb573ef636b9d5bcaf4ddb3f3a2b28493155bad2 (diff) | |
download | postgresql-65e67e2bb2e241e1bec0b4519c0dd8bfa1f9c30f.tar.gz postgresql-65e67e2bb2e241e1bec0b4519c0dd8bfa1f9c30f.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/parser/analyze.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 0df3bec1694..e1be8a89467 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.353 2006/10/11 16:42:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.353.2.1 2007/06/20 18:21:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1033,6 +1033,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, { bool is_serial; bool saw_nullable; + bool saw_default; Constraint *constraint; ListCell *clist; @@ -1163,6 +1164,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, transformConstraintAttrs(column->constraints); saw_nullable = false; + saw_default = false; foreach(clist, column->constraints) { @@ -1207,13 +1209,15 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, break; case CONSTR_DEFAULT: - if (column->raw_default != NULL) + if (saw_default) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("multiple default values specified for column \"%s\" of table \"%s\"", column->colname, cxt->relation->relname))); + /* 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: |