mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Add a convenience routine makeFuncCall to reduce duplication.
David Fetter and Andrew Gierth, reviewed by Jeevan Chalke
This commit is contained in:
parent
3132a9b7ab
commit
0d22987ae9
@ -508,3 +508,28 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* makeFuncCall -
|
||||||
|
*
|
||||||
|
* Initialize a FuncCall struct with the information every caller must
|
||||||
|
* supply. Any non-default parameters have to be handled by the
|
||||||
|
* caller.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FuncCall *
|
||||||
|
makeFuncCall(List *name, List *args, int location)
|
||||||
|
{
|
||||||
|
FuncCall *n = makeNode(FuncCall);
|
||||||
|
n->funcname = name;
|
||||||
|
n->args = args;
|
||||||
|
n->location = location;
|
||||||
|
n->agg_order = NIL;
|
||||||
|
n->agg_star = FALSE;
|
||||||
|
n->agg_distinct = FALSE;
|
||||||
|
n->func_variadic = FALSE;
|
||||||
|
n->over = NULL;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -10503,16 +10503,9 @@ a_expr: c_expr { $$ = $1; }
|
|||||||
}
|
}
|
||||||
| a_expr AT TIME ZONE a_expr %prec AT
|
| a_expr AT TIME ZONE a_expr %prec AT
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
|
||||||
n->funcname = SystemFuncName("timezone");
|
list_make2($5, $1),
|
||||||
n->args = list_make2($5, $1);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (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
|
||||||
@ -10564,113 +10557,65 @@ a_expr: c_expr { $$ = $1; }
|
|||||||
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, $3, @2); }
|
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, $3, @2); }
|
||||||
| a_expr LIKE a_expr ESCAPE a_expr
|
| a_expr LIKE a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("like_escape"),
|
||||||
n->funcname = SystemFuncName("like_escape");
|
list_make2($3, $5),
|
||||||
n->args = list_make2($3, $5);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr NOT LIKE a_expr
|
| a_expr NOT LIKE a_expr
|
||||||
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, $4, @2); }
|
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, $4, @2); }
|
||||||
| a_expr NOT LIKE a_expr ESCAPE a_expr
|
| a_expr NOT LIKE a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("like_escape"),
|
||||||
n->funcname = SystemFuncName("like_escape");
|
list_make2($4, $6),
|
||||||
n->args = list_make2($4, $6);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr ILIKE a_expr
|
| a_expr ILIKE a_expr
|
||||||
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, $3, @2); }
|
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, $3, @2); }
|
||||||
| a_expr ILIKE a_expr ESCAPE a_expr
|
| a_expr ILIKE a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("like_escape"),
|
||||||
n->funcname = SystemFuncName("like_escape");
|
list_make2($3, $5),
|
||||||
n->args = list_make2($3, $5);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr NOT ILIKE a_expr
|
| a_expr NOT ILIKE a_expr
|
||||||
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, $4, @2); }
|
{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, $4, @2); }
|
||||||
| a_expr NOT ILIKE a_expr ESCAPE a_expr
|
| a_expr NOT ILIKE a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("like_escape"),
|
||||||
n->funcname = SystemFuncName("like_escape");
|
list_make2($4, $6),
|
||||||
n->args = list_make2($4, $6);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
|
|
||||||
| a_expr SIMILAR TO a_expr %prec SIMILAR
|
| a_expr SIMILAR TO a_expr %prec SIMILAR
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("similar_escape"),
|
||||||
n->funcname = SystemFuncName("similar_escape");
|
list_make2($4, makeNullAConst(-1)),
|
||||||
n->args = list_make2($4, makeNullAConst(-1));
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr SIMILAR TO a_expr ESCAPE a_expr
|
| a_expr SIMILAR TO a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("similar_escape"),
|
||||||
n->funcname = SystemFuncName("similar_escape");
|
list_make2($4, $6),
|
||||||
n->args = list_make2($4, $6);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr NOT SIMILAR TO a_expr %prec SIMILAR
|
| a_expr NOT SIMILAR TO a_expr %prec SIMILAR
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("similar_escape"),
|
||||||
n->funcname = SystemFuncName("similar_escape");
|
list_make2($5, makeNullAConst(-1)),
|
||||||
n->args = list_make2($5, makeNullAConst(-1));
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
| a_expr NOT SIMILAR TO a_expr ESCAPE a_expr
|
| a_expr NOT SIMILAR TO a_expr ESCAPE a_expr
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall(SystemFuncName("similar_escape"),
|
||||||
n->funcname = SystemFuncName("similar_escape");
|
list_make2($5, $7),
|
||||||
n->args = list_make2($5, $7);
|
@2);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @2;
|
|
||||||
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2);
|
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11097,97 +11042,45 @@ c_expr: columnref { $$ = $1; }
|
|||||||
|
|
||||||
func_application: func_name '(' ')'
|
func_application: func_name '(' ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall($1, NIL, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| func_name '(' func_arg_list ')'
|
| func_name '(' func_arg_list ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall($1, $3, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| func_name '(' VARIADIC func_arg_expr ')'
|
| func_name '(' VARIADIC func_arg_expr ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, list_make1($4), @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = list_make1($4);
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = TRUE;
|
n->func_variadic = TRUE;
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| func_name '(' func_arg_list ',' VARIADIC func_arg_expr ')'
|
| func_name '(' func_arg_list ',' VARIADIC func_arg_expr ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, lappend($3, $6), @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = lappend($3, $6);
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = TRUE;
|
n->func_variadic = TRUE;
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| func_name '(' func_arg_list sort_clause ')'
|
| func_name '(' func_arg_list sort_clause ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, $3, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = $4;
|
n->agg_order = $4;
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| func_name '(' ALL func_arg_list opt_sort_clause ')'
|
| func_name '(' ALL func_arg_list opt_sort_clause ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, $4, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = $4;
|
|
||||||
n->agg_order = $5;
|
n->agg_order = $5;
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
/* Ideally we'd mark the FuncCall node to indicate
|
/* Ideally we'd mark the FuncCall node to indicate
|
||||||
* "must be an aggregate", but there's no provision
|
* "must be an aggregate", but there's no provision
|
||||||
* for that in FuncCall at the moment.
|
* for that in FuncCall at the moment.
|
||||||
*/
|
*/
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
|
| func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, $4, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = $4;
|
|
||||||
n->agg_order = $5;
|
n->agg_order = $5;
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = TRUE;
|
n->agg_distinct = TRUE;
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| func_name '(' '*' ')'
|
| func_name '(' '*' ')'
|
||||||
@ -11202,15 +11095,8 @@ func_application: func_name '(' ')'
|
|||||||
* so that later processing can detect what the argument
|
* so that later processing can detect what the argument
|
||||||
* really was.
|
* really was.
|
||||||
*/
|
*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n = makeFuncCall($1, NIL, @1);
|
||||||
n->funcname = $1;
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = TRUE;
|
n->agg_star = TRUE;
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -11252,16 +11138,9 @@ func_expr_windowless:
|
|||||||
func_expr_common_subexpr:
|
func_expr_common_subexpr:
|
||||||
COLLATION FOR '(' a_expr ')'
|
COLLATION FOR '(' a_expr ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("pg_collation_for"),
|
||||||
n->funcname = SystemFuncName("pg_collation_for");
|
list_make1($4),
|
||||||
n->args = list_make1($4);
|
@1);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CURRENT_DATE
|
| CURRENT_DATE
|
||||||
{
|
{
|
||||||
@ -11313,16 +11192,7 @@ func_expr_common_subexpr:
|
|||||||
* Translate as "now()", since we have a function that
|
* Translate as "now()", since we have a function that
|
||||||
* does exactly what is needed.
|
* does exactly what is needed.
|
||||||
*/
|
*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("now"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("now");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CURRENT_TIMESTAMP '(' Iconst ')'
|
| CURRENT_TIMESTAMP '(' Iconst ')'
|
||||||
{
|
{
|
||||||
@ -11385,96 +11255,33 @@ func_expr_common_subexpr:
|
|||||||
}
|
}
|
||||||
| CURRENT_ROLE
|
| CURRENT_ROLE
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("current_user"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("current_user");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CURRENT_USER
|
| CURRENT_USER
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("current_user"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("current_user");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| SESSION_USER
|
| SESSION_USER
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("session_user"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("session_user");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| USER
|
| USER
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("current_user"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("current_user");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CURRENT_CATALOG
|
| CURRENT_CATALOG
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("current_database"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("current_database");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CURRENT_SCHEMA
|
| CURRENT_SCHEMA
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("current_schema"), NIL, @1);
|
||||||
n->funcname = SystemFuncName("current_schema");
|
|
||||||
n->args = NIL;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| CAST '(' a_expr AS Typename ')'
|
| CAST '(' a_expr AS Typename ')'
|
||||||
{ $$ = makeTypeCast($3, $5, @1); }
|
{ $$ = makeTypeCast($3, $5, @1); }
|
||||||
| EXTRACT '(' extract_list ')'
|
| EXTRACT '(' extract_list ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("date_part"), $3, @1);
|
||||||
n->funcname = SystemFuncName("date_part");
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| OVERLAY '(' overlay_list ')'
|
| OVERLAY '(' overlay_list ')'
|
||||||
{
|
{
|
||||||
@ -11483,46 +11290,19 @@ func_expr_common_subexpr:
|
|||||||
* overlay(A PLACING B FROM C) is converted to
|
* overlay(A PLACING B FROM C) is converted to
|
||||||
* overlay(A, B, C)
|
* overlay(A, B, C)
|
||||||
*/
|
*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("overlay"), $3, @1);
|
||||||
n->funcname = SystemFuncName("overlay");
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| POSITION '(' position_list ')'
|
| POSITION '(' position_list ')'
|
||||||
{
|
{
|
||||||
/* position(A in B) is converted to position(B, A) */
|
/* position(A in B) is converted to position(B, A) */
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("position"), $3, @1);
|
||||||
n->funcname = SystemFuncName("position");
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| SUBSTRING '(' substr_list ')'
|
| SUBSTRING '(' substr_list ')'
|
||||||
{
|
{
|
||||||
/* substring(A from B for C) is converted to
|
/* substring(A from B for C) is converted to
|
||||||
* substring(A, B, C) - thomas 2000-11-28
|
* substring(A, B, C) - thomas 2000-11-28
|
||||||
*/
|
*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("substring"), $3, @1);
|
||||||
n->funcname = SystemFuncName("substring");
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| TREAT '(' a_expr AS Typename ')'
|
| TREAT '(' a_expr AS Typename ')'
|
||||||
{
|
{
|
||||||
@ -11531,75 +11311,32 @@ func_expr_common_subexpr:
|
|||||||
* In SQL99, this is intended for use with structured UDTs,
|
* In SQL99, this is intended for use with structured UDTs,
|
||||||
* but let's make this a generally useful form allowing stronger
|
* but let's make this a generally useful form allowing stronger
|
||||||
* coercions than are handled by implicit casting.
|
* coercions than are handled by implicit casting.
|
||||||
*/
|
*
|
||||||
FuncCall *n = makeNode(FuncCall);
|
* Convert SystemTypeName() to SystemFuncName() even though
|
||||||
/* Convert SystemTypeName() to SystemFuncName() even though
|
|
||||||
* at the moment they result in the same thing.
|
* at the moment they result in the same thing.
|
||||||
*/
|
*/
|
||||||
n->funcname = SystemFuncName(((Value *)llast($5->names))->val.str);
|
$$ = (Node *) makeFuncCall(SystemFuncName(((Value *)llast($5->names))->val.str),
|
||||||
n->args = list_make1($3);
|
list_make1($3),
|
||||||
n->agg_order = NIL;
|
@1);
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| TRIM '(' BOTH trim_list ')'
|
| TRIM '(' BOTH trim_list ')'
|
||||||
{
|
{
|
||||||
/* various trim expressions are defined in SQL
|
/* various trim expressions are defined in SQL
|
||||||
* - thomas 1997-07-19
|
* - thomas 1997-07-19
|
||||||
*/
|
*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("btrim"), $4, @1);
|
||||||
n->funcname = SystemFuncName("btrim");
|
|
||||||
n->args = $4;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| TRIM '(' LEADING trim_list ')'
|
| TRIM '(' LEADING trim_list ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("ltrim"), $4, @1);
|
||||||
n->funcname = SystemFuncName("ltrim");
|
|
||||||
n->args = $4;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| TRIM '(' TRAILING trim_list ')'
|
| TRIM '(' TRAILING trim_list ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("rtrim"), $4, @1);
|
||||||
n->funcname = SystemFuncName("rtrim");
|
|
||||||
n->args = $4;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| TRIM '(' trim_list ')'
|
| TRIM '(' trim_list ')'
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("btrim"), $3, @1);
|
||||||
n->funcname = SystemFuncName("btrim");
|
|
||||||
n->args = $3;
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| NULLIF '(' a_expr ',' a_expr ')'
|
| NULLIF '(' a_expr ',' a_expr ')'
|
||||||
{
|
{
|
||||||
@ -11652,16 +11389,7 @@ func_expr_common_subexpr:
|
|||||||
{
|
{
|
||||||
/* xmlexists(A PASSING [BY REF] B [BY REF]) is
|
/* xmlexists(A PASSING [BY REF] B [BY REF]) is
|
||||||
* converted to xmlexists(A, B)*/
|
* converted to xmlexists(A, B)*/
|
||||||
FuncCall *n = makeNode(FuncCall);
|
$$ = (Node *) makeFuncCall(SystemFuncName("xmlexists"), list_make2($3, $4), @1);
|
||||||
n->funcname = SystemFuncName("xmlexists");
|
|
||||||
n->args = list_make2($3, $4);
|
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = @1;
|
|
||||||
$$ = (Node *)n;
|
|
||||||
}
|
}
|
||||||
| XMLFOREST '(' xml_attribute_list ')'
|
| XMLFOREST '(' xml_attribute_list ')'
|
||||||
{
|
{
|
||||||
@ -13317,9 +13045,7 @@ makeBoolAConst(bool state, int location)
|
|||||||
static FuncCall *
|
static FuncCall *
|
||||||
makeOverlaps(List *largs, List *rargs, int location, core_yyscan_t yyscanner)
|
makeOverlaps(List *largs, List *rargs, int location, core_yyscan_t yyscanner)
|
||||||
{
|
{
|
||||||
FuncCall *n = makeNode(FuncCall);
|
FuncCall *n;
|
||||||
|
|
||||||
n->funcname = SystemFuncName("overlaps");
|
|
||||||
if (list_length(largs) == 1)
|
if (list_length(largs) == 1)
|
||||||
largs = lappend(largs, largs);
|
largs = lappend(largs, largs);
|
||||||
else if (list_length(largs) != 2)
|
else if (list_length(largs) != 2)
|
||||||
@ -13334,13 +13060,7 @@ makeOverlaps(List *largs, List *rargs, int location, core_yyscan_t yyscanner)
|
|||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("wrong number of parameters on right side of OVERLAPS expression"),
|
errmsg("wrong number of parameters on right side of OVERLAPS expression"),
|
||||||
parser_errposition(location)));
|
parser_errposition(location)));
|
||||||
n->args = list_concat(largs, rargs);
|
n = makeFuncCall(SystemFuncName("overlaps"), list_concat(largs, rargs), location);
|
||||||
n->agg_order = NIL;
|
|
||||||
n->agg_star = FALSE;
|
|
||||||
n->agg_distinct = FALSE;
|
|
||||||
n->func_variadic = FALSE;
|
|
||||||
n->over = NULL;
|
|
||||||
n->location = location;
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,16 +448,9 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
|||||||
castnode->typeName = SystemTypeName("regclass");
|
castnode->typeName = SystemTypeName("regclass");
|
||||||
castnode->arg = (Node *) snamenode;
|
castnode->arg = (Node *) snamenode;
|
||||||
castnode->location = -1;
|
castnode->location = -1;
|
||||||
funccallnode = makeNode(FuncCall);
|
funccallnode = makeFuncCall(SystemFuncName("nextval"),
|
||||||
funccallnode->funcname = SystemFuncName("nextval");
|
list_make1(castnode),
|
||||||
funccallnode->args = list_make1(castnode);
|
-1);
|
||||||
funccallnode->agg_order = NIL;
|
|
||||||
funccallnode->agg_star = false;
|
|
||||||
funccallnode->agg_distinct = false;
|
|
||||||
funccallnode->func_variadic = false;
|
|
||||||
funccallnode->over = NULL;
|
|
||||||
funccallnode->location = -1;
|
|
||||||
|
|
||||||
constraint = makeNode(Constraint);
|
constraint = makeNode(Constraint);
|
||||||
constraint->contype = CONSTR_DEFAULT;
|
constraint->contype = CONSTR_DEFAULT;
|
||||||
constraint->location = -1;
|
constraint->location = -1;
|
||||||
|
@ -75,6 +75,8 @@ extern TypeName *makeTypeNameFromOid(Oid typeOid, int32 typmod);
|
|||||||
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
|
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
|
||||||
Oid funccollid, Oid inputcollid, CoercionForm fformat);
|
Oid funccollid, Oid inputcollid, CoercionForm fformat);
|
||||||
|
|
||||||
|
extern FuncCall *makeFuncCall(List *name, List *args, int location);
|
||||||
|
|
||||||
extern DefElem *makeDefElem(char *name, Node *arg);
|
extern DefElem *makeDefElem(char *name, Node *arg);
|
||||||
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
||||||
DefElemAction defaction);
|
DefElemAction defaction);
|
||||||
|
@ -285,6 +285,11 @@ typedef struct CollateClause
|
|||||||
* construct *must* be an aggregate call. Otherwise, it might be either an
|
* construct *must* be an aggregate call. Otherwise, it might be either an
|
||||||
* aggregate or some other kind of function. However, if OVER is present
|
* aggregate or some other kind of function. However, if OVER is present
|
||||||
* it had better be an aggregate or window function.
|
* it had better be an aggregate or window function.
|
||||||
|
*
|
||||||
|
* Normally, you'd initialize this via makeFuncCall() and then only
|
||||||
|
* change the parts of the struct its defaults don't match afterwards
|
||||||
|
* if needed.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct FuncCall
|
typedef struct FuncCall
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user