diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 304849a5c0b..9176129744d 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -3496,17 +3496,11 @@ transformCypherStmt(ParseState *pstate, CypherStmt *stmt) { update_type = T_CypherCreateClause; } - if (read) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Cypher read clauses cannot follow update clauses"))); + /* todo: restriction is required? */ break; case T_CypherDeleteClause: case T_CypherSetClause: - if (read) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Cypher read clauses cannot follow update clauses"))); + /* todo: restriction is required? */ break; case T_CypherMergeClause: if (update_type == T_Invalid || @@ -3514,10 +3508,7 @@ transformCypherStmt(ParseState *pstate, CypherStmt *stmt) { update_type = T_CypherMergeClause; } - if (read) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Cypher read clauses cannot follow update clauses"))); + /* todo: restriction is required? */ break; case T_CypherLoadClause: read = true; diff --git a/src/test/regress/expected/cypher_dml.out b/src/test/regress/expected/cypher_dml.out index fd23c623863..ccf09ecd8a6 100644 --- a/src/test/regress/expected/cypher_dml.out +++ b/src/test/regress/expected/cypher_dml.out @@ -2670,7 +2670,10 @@ MATCH (a) DETACH DELETE a; -- wrong case MERGE (a:v1) MERGE (b:v2 {name: a.notexistent}); MERGE (a:v1) MATCH (b:v2 {name: a.name}) RETURN a, b; -ERROR: Cypher read clauses cannot follow update clauses + a | b +---+--- +(0 rows) + MERGE (a:v1) MERGE (b:v2 {name: a.name}) MERGE (a); ERROR: duplicate variable "a" LINE 1: MERGE (a:v1) MERGE (b:v2 {name: a.name}) MERGE (a); diff --git a/src/test/regress/expected/cypher_eager.out b/src/test/regress/expected/cypher_eager.out index 26769b8bd40..813cbf54960 100644 --- a/src/test/regress/expected/cypher_eager.out +++ b/src/test/regress/expected/cypher_eager.out @@ -520,7 +520,10 @@ MATCH (a) RETURN properties(a); -- wrong case MERGE (a:v1) MERGE (b:v2 {name: a.notexistent}); MERGE (a:v1) MATCH (b:v2 {name: a.name}) RETURN a, b; -ERROR: Cypher read clauses cannot follow update clauses + a | b +---+--- +(0 rows) + MERGE (a:v1) MERGE (b:v2 {name: a.name}) MERGE (a); ERROR: duplicate variable "a" LINE 1: MERGE (a:v1) MERGE (b:v2 {name: a.name}) MERGE (a); diff --git a/src/test/regress/sql/cypher_dml2.sql b/src/test/regress/sql/cypher_dml2.sql index 72153350e7f..76df411a977 100644 --- a/src/test/regress/sql/cypher_dml2.sql +++ b/src/test/regress/sql/cypher_dml2.sql @@ -110,6 +110,29 @@ SELECT * FROM _trigger_history; DROP GRAPH cypher_dml2 CASCADE; +-- #589 ( Cypher read clauses cannot follow update clauses ) +CREATE GRAPH cypher_dml2; +SET GRAPH_PATH to cypher_dml2; + +CREATE VLABEL main; +CREATE ELABEL main2; + +CREATE (n:another {id: 593}) RETURN n.id; + +MERGE (n:main {id: 593}) +ON CREATE SET n.id = 593 +WITH n +MATCH (g: another) +WHERE g.id = 593 +MERGE (g)-[:main2]->(n); + +MATCH ()-[e:main2]-() RETURN e; +MATCH (g: another) RETURN g; +MATCH (g: main) RETURN g; + +DROP GRAPH cypher_dml2 CASCADE; + +-- fix: Includes necessary JOINs of vertices (#599) CREATE GRAPH cypher_dml2; SET GRAPH_PATH to cypher_dml2; @@ -130,4 +153,4 @@ EXPLAIN VERBOSE MATCH (a)-[]-(a) RETURN a; EXPLAIN VERBOSE MATCH (a)-[]-(a) RETURN *; EXPLAIN VERBOSE MATCH p=(a)-[]-(a) RETURN *; -DROP GRAPH cypher_dml2 CASCADE; \ No newline at end of file +DROP GRAPH cypher_dml2 CASCADE;