You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by de...@apache.org on 2022/12/08 03:22:37 UTC

[age] branch master updated: Fix null pointer on name compare (#376)

This is an automated email from the ASF dual-hosted git repository.

dehowef 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 ccd413d  Fix null pointer on name compare (#376)
ccd413d is described below

commit ccd413dc15410d7262e754f21f0970f1861c9430
Author: Vittorio Parrella <93...@users.noreply.github.com>
AuthorDate: Wed Dec 7 22:22:31 2022 -0500

    Fix null pointer on name compare (#376)
    
    * Fix null pointer on name compare
    
    * typo in name of test script
    
    * additional regression tests and style fixes
---
 regress/sql/issue_369.sql                    | 31 ++++++++++++++++++++++++++++
 src/backend/parser/cypher_transform_entity.c |  9 ++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/regress/sql/issue_369.sql b/regress/sql/issue_369.sql
new file mode 100644
index 0000000..038a282
--- /dev/null
+++ b/regress/sql/issue_369.sql
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+LOAD 'age';
+SET search_path TO ag_catalog;
+
+SELECT create_graph('cypher');
+
+SELECT * from cypher('cypher', $$ CREATE (a {x:1})-[:foo]->(b {x:2}),(c {x:3}) $$) as (v0 agtype);
+
+SELECT * from cypher('cypher', $$ MATCH ()-[a:foo]->(), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
+
+SELECT * from cypher('cypher', $$ MATCH (x)-[a:foo]->(), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
+
+SELECT * from cypher('cypher', $$ MATCH ()-[a:foo]->(y), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
diff --git a/src/backend/parser/cypher_transform_entity.c b/src/backend/parser/cypher_transform_entity.c
index c9f13a8..465539d 100644
--- a/src/backend/parser/cypher_transform_entity.c
+++ b/src/backend/parser/cypher_transform_entity.c
@@ -60,6 +60,11 @@ transform_entity *find_transform_entity(cypher_parsestate *cpstate,
                                         char *name,
                                         enum transform_entity_type type)
 {
+    if( name == NULL )
+    {
+        return NULL;
+    }
+    
     ListCell *lc;
 
     foreach(lc, cpstate->entities)
@@ -73,14 +78,14 @@ transform_entity *find_transform_entity(cypher_parsestate *cpstate,
 
         if (type == ENT_VERTEX)
         {
-            if (!strcmp(entity->entity.node->name, name))
+            if (entity->entity.node->name != NULL && !strcmp(entity->entity.node->name, name))
             {
                 return entity;
             }
         }
         else if (type == ENT_EDGE || type == ENT_VLE_EDGE)
         {
-            if (!strcmp(entity->entity.rel->name, name))
+            if (entity->entity.rel->name != NULL && !strcmp(entity->entity.rel->name, name))
             {
                 return entity;
             }