|
20 | 20 | * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
21 | 21 | * Portions Copyright (c) 1994, Regents of the University of California
|
22 | 22 | *
|
23 |
| - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.365 2007/06/19 21:24:48 neilc Exp $ |
| 23 | + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.366 2007/06/20 18:21:00 tgl Exp $ |
24 | 24 | *
|
25 | 25 | *-------------------------------------------------------------------------
|
26 | 26 | */
|
@@ -956,6 +956,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
956 | 956 | {
|
957 | 957 | bool is_serial;
|
958 | 958 | bool saw_nullable;
|
| 959 | + bool saw_default; |
959 | 960 | Constraint *constraint;
|
960 | 961 | ListCell *clist;
|
961 | 962 |
|
@@ -1086,6 +1087,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
1086 | 1087 | transformConstraintAttrs(column->constraints);
|
1087 | 1088 |
|
1088 | 1089 | saw_nullable = false;
|
| 1090 | + saw_default = false; |
1089 | 1091 |
|
1090 | 1092 | foreach(clist, column->constraints)
|
1091 | 1093 | {
|
@@ -1130,13 +1132,15 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
1130 | 1132 | break;
|
1131 | 1133 |
|
1132 | 1134 | case CONSTR_DEFAULT:
|
1133 |
| - if (column->raw_default != NULL) |
| 1135 | + if (saw_default) |
1134 | 1136 | ereport(ERROR,
|
1135 | 1137 | (errcode(ERRCODE_SYNTAX_ERROR),
|
1136 | 1138 | errmsg("multiple default values specified for column \"%s\" of table \"%s\"",
|
1137 | 1139 | column->colname, cxt->relation->relname)));
|
| 1140 | + /* Note: DEFAULT NULL maps to constraint->raw_expr == NULL */ |
1138 | 1141 | column->raw_default = constraint->raw_expr;
|
1139 | 1142 | Assert(constraint->cooked_expr == NULL);
|
| 1143 | + saw_default = true; |
1140 | 1144 | break;
|
1141 | 1145 |
|
1142 | 1146 | case CONSTR_PRIMARY:
|
|
0 commit comments