This is an automated email from the ASF dual-hosted git repository.
jgemignani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git
The following commit(s) were added to refs/heads/master by this push:
new a84c0392 Include invalid labels in reused variables. (#751) (#762)
a84c0392 is described below
commit a84c0392ffcfe63ecbc70ca4b45f1f0c3de28f7d
Author: Dehowe Feng <[email protected]>
AuthorDate: Fri Mar 24 01:12:09 2023 +0900
Include invalid labels in reused variables. (#751) (#762)
Fixed a segmentation fault edge case regarding invalid labels
being used in a repeated variable.
---
regress/expected/cypher_match.out | 6 ++++++
regress/sql/cypher_match.sql | 3 +++
src/backend/parser/cypher_clause.c | 7 +++++--
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/regress/expected/cypher_match.out
b/regress/expected/cypher_match.out
index 0e596406..d1c58c1f 100644
--- a/regress/expected/cypher_match.out
+++ b/regress/expected/cypher_match.out
@@ -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
diff --git a/regress/sql/cypher_match.sql b/regress/sql/cypher_match.sql
index b05e79c5..2d9c5758 100644
--- a/regress/sql/cypher_match.sql
+++ b/regress/sql/cypher_match.sql
@@ -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', $$
diff --git a/src/backend/parser/cypher_clause.c
b/src/backend/parser/cypher_clause.c
index ad876d8c..4c2b10eb 100644
--- a/src/backend/parser/cypher_clause.c
+++ b/src/backend/parser/cypher_clause.c
@@ -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),