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 6d32c746 implemented function to extract cypher functions (#756)
6d32c746 is described below
commit 6d32c74667ddd05a1d1a435786a41b3acfdf6b0f
Author: Kamlesh Kumar <[email protected]>
AuthorDate: Wed Mar 22 11:16:07 2023 +0500
implemented function to extract cypher functions (#756)
---
src/age/age_pool.c | 27 ++++++++++++++++++++++++++-
src/include/age/age_pool.h | 2 ++
src/protocol/pool_proto_modules.c | 12 ++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/age/age_pool.c b/src/age/age_pool.c
index de559eec..6df6ea75 100644
--- a/src/age/age_pool.c
+++ b/src/age/age_pool.c
@@ -23,7 +23,8 @@
#include "parser/nodes.h"
#include "parser/parsenodes.h"
#include "utils/elog.h"
-
+#include "parser/extensible.h"
+#include "age/cypher_nodes.h"
void
@@ -143,4 +144,28 @@ isCypherQuery (Node* node, char** retstr)
}
return false;
+}
+
+List* extractCypherFuncs(List *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);
+
+ }
+ }
+
+ return cypher_funcs_list;
}
\ No newline at end of file
diff --git a/src/include/age/age_pool.h b/src/include/age/age_pool.h
index 7a98c3a2..341017a7 100644
--- a/src/include/age/age_pool.h
+++ b/src/include/age/age_pool.h
@@ -24,5 +24,7 @@
bool isCypherQuery (Node* node, char** str);
void preprocess_cypherstr(char *target);
+List* extractCypherFuncs(List* ParsedCyphertreeList);
+
#endif
diff --git a/src/protocol/pool_proto_modules.c
b/src/protocol/pool_proto_modules.c
index 33b6d9a6..22a41642 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -66,6 +66,7 @@
#include "age/cypher_parser.h"
#include "age/age_pool.h"
+
char *copy_table = NULL; /* copy table name */
char *copy_schema = NULL; /* copy table name */
char copy_delimiter; /* copy delimiter char */
@@ -306,8 +307,19 @@ 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);
+
}
/*