Skip to content

Commit cf24038

Browse files
committed
Only allow NULL in the prpoer places.
1 parent eacd0fd commit cf24038

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/backend/parser/gram.y

Lines changed: 17 additions & 13 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 1.25 1997/01/16 14:56:05 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.26 1997/02/13 15:40:03 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -149,7 +149,8 @@ static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);
149149
%type <coldef> columnDef
150150
%type <defelt> def_elem
151151
%type <node> def_arg, columnElem, where_clause,
152-
a_expr, AexprConst, in_expr_nodes, not_in_expr_nodes,
152+
a_expr, a_expr_or_null, AexprConst,
153+
in_expr_nodes, not_in_expr_nodes,
153154
having_clause
154155
%type <value> NumConst
155156
%type <attr> event_object, attr
@@ -1751,6 +1752,15 @@ Typename: typname opt_array_bounds
17511752
*
17521753
*****************************************************************************/
17531754

1755+
a_expr_or_null: a_expr
1756+
{ $$ = $1;}
1757+
| Pnull
1758+
{
1759+
A_Const *n = makeNode(A_Const);
1760+
n->val.type = T_Null;
1761+
$$ = (Node *)n;
1762+
}
1763+
17541764
a_expr: attr opt_indirection
17551765
{
17561766
$1->indirection = $2;
@@ -1800,7 +1810,7 @@ a_expr: attr opt_indirection
18001810
}
18011811
$$ = (Node *)$2;
18021812
}
1803-
| '(' a_expr ')'
1813+
| '(' a_expr_or_null ')'
18041814
{ $$ = $2; }
18051815
| a_expr Op a_expr
18061816
{ $$ = makeA_Expr(OP, $2, $1, $3); }
@@ -1892,9 +1902,9 @@ opt_indirection: '[' a_expr ']' opt_indirection
18921902
{ $$ = NIL; }
18931903
;
18941904

1895-
expr_list: a_expr
1905+
expr_list: a_expr_or_null
18961906
{ $$ = lcons($1, NIL); }
1897-
| expr_list ',' a_expr
1907+
| expr_list ',' a_expr_or_null
18981908
{ $$ = lappend($1, $3); }
18991909
;
19001910

@@ -1966,7 +1976,7 @@ res_target_list: res_target_list ',' res_target_el
19661976
}
19671977
;
19681978

1969-
res_target_el: Id opt_indirection '=' a_expr
1979+
res_target_el: Id opt_indirection '=' a_expr_or_null
19701980
{
19711981
$$ = makeNode(ResTarget);
19721982
$$->name = $1;
@@ -2014,7 +2024,7 @@ res_target_el2: a_expr AS Id
20142024
$$->indirection = NULL;
20152025
$$->val = (Node *)$1;
20162026
}
2017-
| a_expr
2027+
| a_expr_or_null
20182028
{
20192029
$$ = makeNode(ResTarget);
20202030
$$->name = NULL;
@@ -2108,12 +2118,6 @@ AexprConst: Iconst
21082118
}
21092119
| ParamNo
21102120
{ $$ = (Node *)$1; }
2111-
| Pnull
2112-
{
2113-
A_Const *n = makeNode(A_Const);
2114-
n->val.type = T_Null;
2115-
$$ = (Node *)n;
2116-
}
21172121
;
21182122

21192123
ParamNo: PARAM

0 commit comments

Comments
 (0)