mirror of
https://github.com/postgres/postgres.git
synced 2026-04-10 19:47:07 -04:00
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.
This commit is contained in:
parent
db6159bcd9
commit
b0bbcbe7d3
1 changed files with 6 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.314.4.2 2006/10/11 20:03:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.314.4.3 2007/06/20 18:21:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
|
@ -841,6 +841,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
|||
{
|
||||
bool is_serial;
|
||||
bool saw_nullable;
|
||||
bool saw_default;
|
||||
Constraint *constraint;
|
||||
ListCell *clist;
|
||||
|
||||
|
|
@ -957,6 +958,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
|||
transformConstraintAttrs(column->constraints);
|
||||
|
||||
saw_nullable = false;
|
||||
saw_default = false;
|
||||
|
||||
foreach(clist, column->constraints)
|
||||
{
|
||||
|
|
@ -1001,13 +1003,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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue