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

Commitf6baabc

Browse files
committed
Correct coredump in ALTER TABLE foo ADD(). Accept explicit NULL in
typecasts, eg 'NULL::text'. Later parts of the parser don't like thisyet, but I'll work on that next.
1 parentf4db5c3 commitf6baabc

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

‎src/backend/parser/gram.y

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.117 1999/12/06 18:02:43 wieck Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.118 1999/12/10 03:01:05 tgl Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -362,7 +362,7 @@ static Node *doNegate(Node *n);
362362
%rightUMINUS
363363
%left'.'
364364
%left'[' ']'
365-
%nonassocTYPECAST
365+
%leftTYPECAST
366366
%leftUNION INTERSECT EXCEPT
367367
%%
368368

@@ -759,11 +759,9 @@ alter_clause: ADD opt_column columnDef
759759
}
760760
| ADD '(' OptTableElementList ')'
761761
{
762-
Node *lp = lfirst($3);
763-
764762
if (length($3) != 1)
765763
elog(ERROR,"ALTER TABLE/ADD() allows one column only");
766-
$$ =lp;
764+
$$ =(Node *) lfirst($3);
767765
}
768766
| DROP opt_column ColId
769767
{elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }
@@ -1532,7 +1530,7 @@ ConstraintTimeSpec: INITIALLY IMMEDIATE
15321530
| INITIALLY DEFERRED
15331531
{ $$ = 2; }
15341532
;
1535-
1533+
15361534

15371535
DropTrigStmt: DROP TRIGGER name ON relation_name
15381536
{
@@ -1758,7 +1756,7 @@ comment_tg:TRIGGER { $$ = TRIGGER; }
17581756
;
17591757

17601758
comment_text:Sconst { $$ = $1; }
1761-
| NULL_P { $$ =0; }
1759+
| NULL_P { $$ =NULL; }
17621760
;
17631761

17641762
/*****************************************************************************
@@ -3807,6 +3805,17 @@ a_expr: com_expr
38073805
$$ = (Node *)n;
38083806
}
38093807
}
3808+
/*
3809+
* Can't collapse this into prior rule by using a_expr_or_null;
3810+
* that creates reduce/reduce conflicts. Grumble.
3811+
*/
3812+
| NULL_P TYPECAST Typename
3813+
{
3814+
A_Const *n = makeNode(A_Const);
3815+
n->val.type = T_Null;
3816+
n->typename = $3;
3817+
$$ = (Node *)n;
3818+
}
38103819
/*
38113820
* These operators must be called out explicitly in order to make use
38123821
* of yacc/bison's automatic operator-precedence handling. All other
@@ -4041,6 +4050,13 @@ b_expr: com_expr
40414050
$$ = (Node *)n;
40424051
}
40434052
}
4053+
| NULL_P TYPECAST Typename
4054+
{
4055+
A_Const *n = makeNode(A_Const);
4056+
n->val.type = T_Null;
4057+
n->typename = $3;
4058+
$$ = (Node *)n;
4059+
}
40444060
| '-' b_expr %prec UMINUS
40454061
{$$ = doNegate($2); }
40464062
| '%' b_expr
@@ -4110,7 +4126,7 @@ com_expr: attr
41104126
{$$ = $1; }
41114127
| '(' a_expr_or_null ')'
41124128
{$$ = $2; }
4113-
| CAST '('a_expr AS Typename ')'
4129+
| CAST '('a_expr_or_null AS Typename ')'
41144130
{
41154131
$$ = (Node *)$3;
41164132
/* AexprConst can be either A_Const or ParamNo */
@@ -4870,7 +4886,7 @@ ColId: IDENT{ $$ = $1; }
48704886
| STATEMENT{ $$ = "statement"; }
48714887
| STDIN{ $$ = "stdin"; }
48724888
| STDOUT{ $$ = "stdout"; }
4873-
| SYSID{ $$ = "sysid"; }
4889+
| SYSID{ $$ = "sysid"; }
48744890
| TIME{ $$ = "time"; }
48754891
| TIMESTAMP{ $$ = "timestamp"; }
48764892
| TIMEZONE_HOUR{ $$ = "timezone_hour"; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp