You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by jo...@apache.org on 2023/04/11 04:58:07 UTC

[age] branch AGEHA updated: [AGEHA] Fix and Optimize isWriteQuery and extractCypherFuncs (#792)

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

joshinnis pushed a commit to branch AGEHA
in repository https://gitbox.apache.org/repos/asf/age.git


The following commit(s) were added to refs/heads/AGEHA by this push:
     new c30ecebf [AGEHA] Fix and Optimize isWriteQuery and extractCypherFuncs (#792)
c30ecebf is described below

commit c30ecebfb16a20ad094aabb173c1e08fc1c20daa
Author: moeed-k <99...@users.noreply.github.com>
AuthorDate: Tue Apr 11 09:58:02 2023 +0500

    [AGEHA] Fix and Optimize isWriteQuery and extractCypherFuncs (#792)
    
    * Fix isWriteQuery
    
    * Clean up debugging code
    
    * fix return type
    
    * update isWriteQuery header
---
 src/age/age_pool.c                | 55 ++++++++++++---------------------------
 src/include/age/age_pool.h        |  3 +--
 src/protocol/pool_proto_modules.c | 17 ------------
 3 files changed, 18 insertions(+), 57 deletions(-)

diff --git a/src/age/age_pool.c b/src/age/age_pool.c
index 87edc5fe..e298cb3f 100644
--- a/src/age/age_pool.c
+++ b/src/age/age_pool.c
@@ -146,53 +146,32 @@ isCypherQuery (Node* node, char** retstr)
 	return false; 
 }
 
-List* 
-/* Returns all the Cypher Nodes
-   in the given parse tree.
+bool 
+/* Checks if the cypher tree contains any 
+ * clauses that are Write operations.
 */
-extractCypherFuncs(List *ParsedCyphertreeList)
+isWriteQuery(List *ParsedCyphertreeList)
 {
+	//Removing last node because it is only used by EXPLAIN
+	list_delete_ptr(ParsedCyphertreeList, llast(ParsedCyphertreeList));
 
 	ListCell *resultfl;
 
-	List *cypher_funcs_list= NIL;
-
 	foreach (resultfl, ParsedCyphertreeList)
 	{
-		Node *newnode = (Node *)lfirst(resultfl);
-
-		ExtensibleNode *extnode;
-
-		if (IsA(newnode, ExtensibleNode)){
-
-			extnode = (ExtensibleNode *)newnode;
-			cypher_funcs_list = lappend(cypher_funcs_list, extnode->extnodename);
+		Node *node = (Node *)lfirst(resultfl);
 
+		if (IsA(node, ExtensibleNode))
+		{
+			// DETACH DELETE is covered under cypher_delete.
+            // REMOVE command is covered under cypher_set.
+			if (is_ag_node(node, cypher_create) || is_ag_node(node, cypher_set) ||
+				is_ag_node(node, cypher_delete) || is_ag_node(node, cypher_merge))
+			{
+				return true;
+			}
 		}
 	}
 	
-	return cypher_funcs_list;
-}
-
-bool 
-/* Returns true if the given cypher node
-   is a write query.
-*/
-IsWriteQuery(List *cypher_funcs_list){
-	ListCell *cypherfl;
-	foreach (cypherfl, cypher_funcs_list)
-	{
-		char *cypher_func = (char *)lfirst(cypherfl);
-
-
-		// DETACH DELETE is covered under cypher_delete.
-            // REMOVE command is covered under cypher_set.
-        if (is_ag_node(cypher_func, cypher_create) || is_ag_node(cypher_func, cypher_set) ||
-        is_ag_node(cypher_func, cypher_delete) || is_ag_node(cypher_func, cypher_merge))
-        {
-        	return true;
-        }
-	}
-
 	return false;
-}
\ No newline at end of file
+}
diff --git a/src/include/age/age_pool.h b/src/include/age/age_pool.h
index 36c7c5cd..e3376798 100644
--- a/src/include/age/age_pool.h
+++ b/src/include/age/age_pool.h
@@ -24,8 +24,7 @@
 
 bool isCypherQuery (Node* node, char** str);
 void preprocess_cypherstr(char *target);
-List* extractCypherFuncs(List* ParsedCyphertreeList);
-bool IsWriteQuery(List* cypher_funcs_list);
+bool isWriteQuery(List *ParsedCyphertreeList);
 
 
 #endif
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
index 67097b86..96b6252a 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -306,23 +306,6 @@ SimpleQuery(POOL_CONNECTION * frontend,
 	{
 		node = raw_parser2(parse_tree_list);
 
-		char* cypherstr;
-
-		/*
-		 * if query is cypher query then extract cypher functions
-		 */
-		if (isCypherQuery(node,&cypherstr)){
-
-			List* cyphertree = parse_cypher(cypherstr);
-
-			// removing the last node of parsed cypher.
-			Node *temp = llast(cyphertree);
-	        list_delete_ptr(cyphertree, temp);
-			List* cypher_funcs_list = extractCypherFuncs(cyphertree);
-			bool isWriteQuery = IsWriteQuery(cypher_funcs_list);
-			
-		}
-
 		/*
 		 * Start query context
 		 */