Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions regress/expected/cypher_call.out
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ SELECT * FROM cypher('cypher_call', $$CALL sqrt(64)$$) as (sqrt agtype);

/* CALL RETURN, should fail */
SELECT * FROM cypher('cypher_call', $$CALL sqrt(64) RETURN sqrt$$) as (sqrt agtype);
ERROR: Procedure call inside a query does not support naming results implicitly
LINE 2: SELECT * FROM cypher('cypher_call', $$CALL sqrt(64) RETURN s...
^
HINT: Name explicitly using `YIELD` instead
ERROR: could not find rte for sqrt
LINE 2: ...FROM cypher('cypher_call', $$CALL sqrt(64) RETURN sqrt$$) as...
^
/* CALL YIELD */
SELECT * FROM cypher('cypher_call', $$CALL sqrt(64) YIELD sqrt$$) as (sqrt agtype);
sqrt
Expand Down
19 changes: 18 additions & 1 deletion src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ static Query * transform_cypher_call_stmt(cypher_parsestate *cpstate,
{
ParseState *pstate = (ParseState *)cpstate;
cypher_call *self = (cypher_call *)clause->self;

Node *nextClause = NULL;

if (!clause->prev && !clause->next) /* CALL [YIELD] -- the most simple call */
{
if (self->where) /* Error check for WHERE clause after YIELD without RETURN */
Expand All @@ -1048,6 +1049,22 @@ static Query * transform_cypher_call_stmt(cypher_parsestate *cpstate,
{
if (!self->yield_items)
{
nextClause = (Node *) clause->next->self;

if (!clause->prev && is_ag_node(nextClause, cypher_return))
{
cypher_return *returnClause = (cypher_return *) nextClause;
ResTarget *target = (ResTarget *) lfirst(returnClause->items->head);
ColumnRef *cref = (ColumnRef *) target->val;
char *colName = (char *) strVal((Node *) linitial(cref->fields));

ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("could not find rte for %s", colName),
parser_errposition(pstate,
exprLocation((Node *) target))));
}

ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("Procedure call inside a query does not support naming results implicitly"),
Expand Down