Correct coredump in ALTER TABLE foo ADD(). Accept explicit NULL in
typecasts, eg 'NULL::text'. Later parts of the parser don't like this yet, but I'll work on that next.
This commit is contained in:
parent
f4db5c3c88
commit
f6baabcd0b
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.117 1999/12/06 18:02:43 wieck Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.118 1999/12/10 03:01:05 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -362,7 +362,7 @@ static Node *doNegate(Node *n);
|
|||||||
%right UMINUS
|
%right UMINUS
|
||||||
%left '.'
|
%left '.'
|
||||||
%left '[' ']'
|
%left '[' ']'
|
||||||
%nonassoc TYPECAST
|
%left TYPECAST
|
||||||
%left UNION INTERSECT EXCEPT
|
%left UNION INTERSECT EXCEPT
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@ -759,11 +759,9 @@ alter_clause: ADD opt_column columnDef
|
|||||||
}
|
}
|
||||||
| ADD '(' OptTableElementList ')'
|
| ADD '(' OptTableElementList ')'
|
||||||
{
|
{
|
||||||
Node *lp = lfirst($3);
|
|
||||||
|
|
||||||
if (length($3) != 1)
|
if (length($3) != 1)
|
||||||
elog(ERROR,"ALTER TABLE/ADD() allows one column only");
|
elog(ERROR,"ALTER TABLE/ADD() allows one column only");
|
||||||
$$ = lp;
|
$$ = (Node *) lfirst($3);
|
||||||
}
|
}
|
||||||
| DROP opt_column ColId
|
| DROP opt_column ColId
|
||||||
{ elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }
|
{ elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }
|
||||||
@ -1758,7 +1756,7 @@ comment_tg: TRIGGER { $$ = TRIGGER; }
|
|||||||
;
|
;
|
||||||
|
|
||||||
comment_text: Sconst { $$ = $1; }
|
comment_text: Sconst { $$ = $1; }
|
||||||
| NULL_P { $$ = 0; }
|
| NULL_P { $$ = NULL; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
@ -3807,6 +3805,17 @@ a_expr: com_expr
|
|||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Can't collapse this into prior rule by using a_expr_or_null;
|
||||||
|
* that creates reduce/reduce conflicts. Grumble.
|
||||||
|
*/
|
||||||
|
| NULL_P TYPECAST Typename
|
||||||
|
{
|
||||||
|
A_Const *n = makeNode(A_Const);
|
||||||
|
n->val.type = T_Null;
|
||||||
|
n->typename = $3;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* These operators must be called out explicitly in order to make use
|
* These operators must be called out explicitly in order to make use
|
||||||
* of yacc/bison's automatic operator-precedence handling. All other
|
* of yacc/bison's automatic operator-precedence handling. All other
|
||||||
@ -4041,6 +4050,13 @@ b_expr: com_expr
|
|||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| NULL_P TYPECAST Typename
|
||||||
|
{
|
||||||
|
A_Const *n = makeNode(A_Const);
|
||||||
|
n->val.type = T_Null;
|
||||||
|
n->typename = $3;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
| '-' b_expr %prec UMINUS
|
| '-' b_expr %prec UMINUS
|
||||||
{ $$ = doNegate($2); }
|
{ $$ = doNegate($2); }
|
||||||
| '%' b_expr
|
| '%' b_expr
|
||||||
@ -4110,7 +4126,7 @@ com_expr: attr
|
|||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
| '(' a_expr_or_null ')'
|
| '(' a_expr_or_null ')'
|
||||||
{ $$ = $2; }
|
{ $$ = $2; }
|
||||||
| CAST '(' a_expr AS Typename ')'
|
| CAST '(' a_expr_or_null AS Typename ')'
|
||||||
{
|
{
|
||||||
$$ = (Node *)$3;
|
$$ = (Node *)$3;
|
||||||
/* AexprConst can be either A_Const or ParamNo */
|
/* AexprConst can be either A_Const or ParamNo */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user