Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CALL YIELD grammar more precise #1852

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 40 additions & 58 deletions src/backend/parser/cypher_gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -387,44 +387,35 @@ call_stmt:

$$ = (Node *)n;
}
| CALL expr '.' expr
| CALL expr_var '.' expr_func_norm
{
cypher_call *n = make_ag_node(cypher_call);
FuncCall *fc = (FuncCall*)$4;
ColumnRef *cr = (ColumnRef*)$2;
List *fields = cr->fields;
String *string = linitial(fields);

if (IsA($4, FuncCall) && IsA($2, ColumnRef))
/*
* A function can only be qualified with a single schema. So, we
* check to see that the function isn't already qualified. There
* may be unforeseen cases where we might need to remove this in
* the future.
*/
if (list_length(fc->funcname) == 1)
{
FuncCall *fc = (FuncCall*)$4;
ColumnRef *cr = (ColumnRef*)$2;
List *fields = cr->fields;
String *string = linitial(fields);

/*
* A function can only be qualified with a single schema. So, we
* check to see that the function isn't already qualified. There
* may be unforeseen cases where we might need to remove this in
* the future.
*/
if (list_length(fc->funcname) == 1)
{
fc->funcname = lcons(string, fc->funcname);
$$ = (Node*)fc;
}
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("function already qualified"),
ag_scanner_errposition(@1, scanner)));

n->funccall = fc;
$$ = (Node *)n;
fc->funcname = lcons(string, fc->funcname);
$$ = (Node*)fc;
}
else
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("CALL statement must be a qualified function"),
ag_scanner_errposition(@1, scanner)));
errmsg("function already qualified"),
ag_scanner_errposition(@1, scanner)));
}

n->funccall = fc;
$$ = (Node *)n;
}
| CALL expr_func_norm YIELD yield_item_list where_opt
{
Expand All @@ -434,46 +425,37 @@ call_stmt:
n->where = $5;
$$ = (Node *)n;
}
| CALL expr '.' expr YIELD yield_item_list where_opt
| CALL expr_var '.' expr_func_norm YIELD yield_item_list where_opt
{
cypher_call *n = make_ag_node(cypher_call);
FuncCall *fc = (FuncCall*)$4;
ColumnRef *cr = (ColumnRef*)$2;
List *fields = cr->fields;
String *string = linitial(fields);

if (IsA($4, FuncCall) && IsA($2, ColumnRef))
/*
* A function can only be qualified with a single schema. So, we
* check to see that the function isn't already qualified. There
* may be unforeseen cases where we might need to remove this in
* the future.
*/
if (list_length(fc->funcname) == 1)
{
FuncCall *fc = (FuncCall*)$4;
ColumnRef *cr = (ColumnRef*)$2;
List *fields = cr->fields;
String *string = linitial(fields);

/*
* A function can only be qualified with a single schema. So, we
* check to see that the function isn't already qualified. There
* may be unforeseen cases where we might need to remove this in
* the future.
*/
if (list_length(fc->funcname) == 1)
{
fc->funcname = lcons(string, fc->funcname);
$$ = (Node*)fc;
}
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("function already qualified"),
ag_scanner_errposition(@1, scanner)));

n->funccall = fc;
n->yield_items = $6;
n->where = $7;
$$ = (Node *)n;
fc->funcname = lcons(string, fc->funcname);
$$ = (Node*)fc;
}
else
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("CALL statement must be a qualified function"),
ag_scanner_errposition(@1, scanner)));
errmsg("function already qualified"),
ag_scanner_errposition(@1, scanner)));
}

n->funccall = fc;
n->yield_items = $6;
n->where = $7;
$$ = (Node *)n;
}
;

Expand Down