@@ -78,6 +78,9 @@ static FuncExpr *make_clause_create_graph_func_expr(char *graph_name);
7878static Query * cypher_create_graph_utility (ParseState * pstate , const char * graph_name );
7979static FuncExpr * make_clause_use_graph_func_expr (char * graph_name );
8080static Query * cypher_use_graph_utility (ParseState * pstate , const char * graph_name );
81+ static FuncExpr * make_clause_create_vlabel_func_expr (char * label_name );
82+ static Query * cypher_create_vlabel_utility (ParseState * pstate , const char * label_name );
83+
8184static Oid get_session_graph_oid ();
8285static CommandTag
8386CypherCreateCommandTag (Node * parsetree );
@@ -1223,6 +1226,10 @@ cypher_parse_analyze(RawStmt *parseTree, const char *sourceText,
12231226 cypher_drop_graph * ccg = n ;
12241227
12251228 query = cypher_drop_graph_utility (pstate , ccg -> graph_name );
1229+ } else if (is_ag_node (n , cypher_create_vlabel )) {
1230+ cypher_create_vlabel * ccg = n ;
1231+
1232+ query = cypher_create_vlabel_utility (pstate , ccg -> label_name );
12261233 } else {
12271234 query = parse_analyze ((makeRawStmt (n , 0 )), sourceText , paramTypes , numParams , queryEnv );
12281235
@@ -1452,6 +1459,47 @@ cypher_use_graph_utility(ParseState *pstate, const char *graph_name) {
14521459 return query ;
14531460}
14541461
1462+
1463+
1464+ /*
1465+ * Creates the function expression that represents the clause. Adds the
1466+ * extensible node that represents the metadata that the clause needs to
1467+ * handle the clause in the execution phase.
1468+ */
1469+ static FuncExpr * make_clause_create_vlabel_func_expr (char * label_name ) {
1470+
1471+ graph_cache_data * gcd = search_graph_namespace_cache (get_session_graph_oid ());
1472+
1473+ Const * c = makeConst (TEXTOID , -1 , InvalidOid , strlen (label_name ), CStringGetTextDatum (label_name ), false, false);
1474+ Const * c1 = makeConst (TEXTOID , -1 , InvalidOid , strlen (gcd -> name .data ), CStringGetTextDatum (gcd -> name .data ), false, false);
1475+
1476+
1477+ Oid func_oid = get_ag_func_oid ("create_vlabel" , 2 , TEXTOID , TEXTOID );
1478+
1479+ return makeFuncExpr (func_oid , VOIDOID , list_make2 (c1 , c ), InvalidOid , InvalidOid , COERCE_EXPLICIT_CALL );
1480+ }
1481+
1482+ static Query *
1483+ cypher_create_vlabel_utility (ParseState * pstate , const char * label_name ) {
1484+ Query * query ;
1485+ TargetEntry * tle ;
1486+ FuncExpr * func_expr ;
1487+
1488+ query = makeNode (Query );
1489+ query -> commandType = CMD_SELECT ;
1490+ query -> targetList = NIL ;
1491+
1492+ func_expr = make_clause_create_vlabel_func_expr (label_name );
1493+
1494+ // Create the target entry
1495+ tle = makeTargetEntry ((Expr * )func_expr , pstate -> p_next_resno ++ , "create_vlabel" , false);
1496+ query -> targetList = lappend (query -> targetList , tle );
1497+
1498+ query -> rtable = pstate -> p_rtable ;
1499+ query -> jointree = makeFromExpr (pstate -> p_joinlist , NULL );
1500+ return query ;
1501+ }
1502+
14551503Oid get_session_graph_oid ()
14561504{
14571505 ScanKeyData scan_keys [1 ];
0 commit comments