Skip to content
Merged
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
6 changes: 6 additions & 0 deletions regress/expected/cypher_match.out
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ $$) AS (a agtype);
ERROR: multiple labels for variable 'a' are not supported
LINE 2: MATCH (a)-[]-(a)-[]-(a:v1) RETURN a
^
SELECT * FROM cypher('cypher_match', $$
MATCH (a)-[]-(a)-[]-(a:invalid_label) RETURN a
$$) AS (a agtype);
ERROR: multiple labels for variable 'a' are not supported
LINE 2: MATCH (a)-[]-(a)-[]-(a:invalid_label) RETURN a
^
--Valid variable reuse, although why would you want to do it this way?
SELECT * FROM cypher('cypher_match', $$
MATCH (a:v1)-[]-()-[a]-() RETURN a
Expand Down
3 changes: 3 additions & 0 deletions regress/sql/cypher_match.sql
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ $$) AS (a agtype);
SELECT * FROM cypher('cypher_match', $$
MATCH (a)-[]-(a)-[]-(a:v1) RETURN a
$$) AS (a agtype);
SELECT * FROM cypher('cypher_match', $$
MATCH (a)-[]-(a)-[]-(a:invalid_label) RETURN a
$$) AS (a agtype);

--Valid variable reuse, although why would you want to do it this way?
SELECT * FROM cypher('cypher_match', $$
Expand Down
7 changes: 5 additions & 2 deletions src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -4527,12 +4527,15 @@ static Expr *transform_cypher_node(cypher_parsestate *cpstate,
{
cypher_node *cnode = (cypher_node *)entity->entity.node;

if (cnode != NULL &&


if (!node->label ||
(cnode != NULL &&
node != NULL &&
/* allow node using a default label against resolved var */
pg_strcasecmp(node->label, AG_DEFAULT_LABEL_VERTEX) != 0 &&
/* allow labels with the same name */
pg_strcasecmp(cnode->label, node->label) != 0)
pg_strcasecmp(cnode->label, node->label) != 0))
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
Expand Down