diff --git a/regress/expected/cypher_call.out b/regress/expected/cypher_call.out index a7862b5d0..4aa0c88a3 100644 --- a/regress/expected/cypher_call.out +++ b/regress/expected/cypher_call.out @@ -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 diff --git a/src/backend/parser/cypher_clause.c b/src/backend/parser/cypher_clause.c index b6640e8ea..1ac33138b 100644 --- a/src/backend/parser/cypher_clause.c +++ b/src/backend/parser/cypher_clause.c @@ -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 */ @@ -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"),