|
6 | 6 | * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 |
| - *$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.253.2.2 2003/02/13 22:50:09 tgl Exp $ |
| 9 | + *$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.253.2.3 2007/06/20 18:21:51 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
@@ -793,6 +793,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
793 | 793 | {
|
794 | 794 | boolis_serial;
|
795 | 795 | boolsaw_nullable;
|
| 796 | +boolsaw_default; |
796 | 797 | Constraint*constraint;
|
797 | 798 | List*clist;
|
798 | 799 |
|
@@ -895,6 +896,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
895 | 896 | transformConstraintAttrs(column->constraints);
|
896 | 897 |
|
897 | 898 | saw_nullable= false;
|
| 899 | +saw_default= false; |
898 | 900 |
|
899 | 901 | foreach(clist,column->constraints)
|
900 | 902 | {
|
@@ -935,11 +937,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
935 | 937 | break;
|
936 | 938 |
|
937 | 939 | caseCONSTR_DEFAULT:
|
938 |
| -if (column->raw_default!=NULL) |
| 940 | +if (saw_default) |
939 | 941 | elog(ERROR,"%s/DEFAULT multiple values specified for '%s.%s'",
|
940 | 942 | cxt->stmtType,cxt->relation->relname,column->colname);
|
| 943 | +/* Note: DEFAULT NULL maps to constraint->raw_expr == NULL */ |
941 | 944 | column->raw_default=constraint->raw_expr;
|
942 | 945 | Assert(constraint->cooked_expr==NULL);
|
| 946 | +saw_default= true; |
943 | 947 | break;
|
944 | 948 |
|
945 | 949 | caseCONSTR_PRIMARY:
|
|