Skip to content

Commit 01e570e

Browse files
committed
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.
1 parent cbe8af8 commit 01e570e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/parser/analyze.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
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 $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -793,6 +793,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
793793
{
794794
bool is_serial;
795795
bool saw_nullable;
796+
bool saw_default;
796797
Constraint *constraint;
797798
List *clist;
798799

@@ -895,6 +896,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
895896
transformConstraintAttrs(column->constraints);
896897

897898
saw_nullable = false;
899+
saw_default = false;
898900

899901
foreach(clist, column->constraints)
900902
{
@@ -935,11 +937,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
935937
break;
936938

937939
case CONSTR_DEFAULT:
938-
if (column->raw_default != NULL)
940+
if (saw_default)
939941
elog(ERROR, "%s/DEFAULT multiple values specified for '%s.%s'",
940942
cxt->stmtType, cxt->relation->relname, column->colname);
943+
/* Note: DEFAULT NULL maps to constraint->raw_expr == NULL */
941944
column->raw_default = constraint->raw_expr;
942945
Assert(constraint->cooked_expr == NULL);
946+
saw_default = true;
943947
break;
944948

945949
case CONSTR_PRIMARY:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy