@@ -103,10 +103,10 @@ makeRawStmt(Node *stmt, int stmt_location)
103
103
static List * cypher_parse (char * string ){
104
104
List * raw_parsetree_list ;
105
105
106
- TRACE_POSTGRESQL_QUERY_PARSE_START (string );
106
+ // TRACE_POSTGRESQL_QUERY_PARSE_START(string);
107
107
108
- if (log_parser_stats )
109
- ResetUsage ();
108
+ // if (log_parser_stats)
109
+ // ResetUsage();
110
110
/*
111
111
raw_parsetree_list = raw_parser(string, RAW_PARSE_DEFAULT);
112
112
@@ -148,7 +148,7 @@ static List *cypher_parse(char *string){
148
148
* here.
149
149
*/
150
150
151
- TRACE_POSTGRESQL_QUERY_PARSE_DONE (string );
151
+ // TRACE_POSTGRESQL_QUERY_PARSE_DONE(string);
152
152
153
153
return raw_parsetree_list ;
154
154
}
@@ -162,6 +162,39 @@ void parse_analyze_fini(void){
162
162
parse_analyze_hook = NULL ;
163
163
}
164
164
165
+ /*
166
+ * Creates the function expression that represents the clause. Adds the
167
+ * extensible node that represents the metadata that the clause needs to
168
+ * handle the clause in the execution phase.
169
+ */
170
+ static FuncExpr * make_clause_create_graph_func_expr (char * graph_name ) {
171
+ Const * c = makeConst (TEXTOID , -1 , InvalidOid , strlen (graph_name ), CStringGetTextDatum (graph_name ), false, false);
172
+
173
+ Oid func_oid = get_ag_func_oid ("create_graph" , 1 , TEXTOID );
174
+
175
+ return makeFuncExpr (func_oid , VOIDOID , list_make1 (c ), InvalidOid , InvalidOid , COERCE_EXPLICIT_CALL );
176
+ }
177
+
178
+ static Query *
179
+ cypher_create_graph_utility (ParseState * pstate , const char * graph_name ) {
180
+ Query * query ;
181
+ TargetEntry * tle ;
182
+ FuncExpr * func_expr ;
183
+
184
+ query = makeNode (Query );
185
+ query -> commandType = CMD_SELECT ;
186
+ query -> targetList = NIL ;
187
+
188
+ func_expr = make_clause_create_graph_func_expr (graph_name );
189
+
190
+ // Create the target entry
191
+ tle = makeTargetEntry ((Expr * )func_expr , pstate -> p_next_resno ++ , "create_graph" , false);
192
+ query -> targetList = lappend (query -> targetList , tle );
193
+
194
+ query -> rtable = pstate -> p_rtable ;
195
+ query -> jointree = makeFromExpr (pstate -> p_joinlist , NULL );
196
+ return query ;
197
+ }
165
198
166
199
/*
167
200
* parse_analyze
@@ -193,6 +226,28 @@ cypher_parse_analyze(RawStmt *parseTree, const char *sourceText,
193
226
pstate -> p_queryEnv = queryEnv ;
194
227
195
228
//query = transformTopLevelStmt(pstate, parseTree);
229
+ if (list_length (parseTree -> stmt ) == 1 ) {
230
+ Node * n = linitial (parseTree -> stmt );
231
+
232
+ if (is_ag_node (n , cypher_create_graph )) {
233
+ cypher_create_graph * ccg = n ;
234
+ //ereport(ERROR, errmsg("Here"));
235
+
236
+ query = cypher_create_graph_utility (pstate , ccg -> graph_name );
237
+
238
+ query -> canSetTag = true;
239
+
240
+ if (IsQueryIdEnabled ())
241
+ jstate = JumbleQuery (query , sourceText );
242
+
243
+ free_parsestate (pstate );
244
+
245
+ pgstat_report_query_id (query -> queryId , false);
246
+ PushActiveSnapshot (GetTransactionSnapshot ());
247
+ return query ;
248
+
249
+ }
250
+ }
196
251
query = analyze_cypher (parseTree -> stmt , pstate , sourceText , 0 , NULL , CurrentGraphOid , NULL );
197
252
198
253
if (IsQueryIdEnabled ())
0 commit comments