Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01e570e

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 parentcbe8af8 commit01e570e

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
boolis_serial;
795795
boolsaw_nullable;
796+
boolsaw_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
caseCONSTR_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
caseCONSTR_PRIMARY:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp