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 2021/11/30 20:36:48 UTC

[incubator-age] branch master updated: Updated code for create vertex and edge labels (#136)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 21436be  Updated code for create vertex and edge labels (#136)
21436be is described below

commit 21436be4011ee8d0fd8a709ab727d37ae44a8ce3
Author: Shoaib <mu...@gmail.com>
AuthorDate: Tue Nov 30 21:36:44 2021 +0100

    Updated code for create vertex and edge labels (#136)
    
    Code now inherits tables from ag_vertex and ag_edges that was a bug in
    previous release.
---
 src/backend/commands/label_commands.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/backend/commands/label_commands.c b/src/backend/commands/label_commands.c
index f291354..66b6818 100644
--- a/src/backend/commands/label_commands.c
+++ b/src/backend/commands/label_commands.c
@@ -112,6 +112,10 @@ Datum create_vlabel(PG_FUNCTION_ARGS)
     char *graph;
     Name graph_name;
     char *graph_name_str;
+    Oid graph_oid;
+    List *parent;
+
+    RangeVar *rv;
 
     char *label;
     Name label_name;
@@ -145,8 +149,10 @@ Datum create_vlabel(PG_FUNCTION_ARGS)
                         errmsg("graph \"%s\" does not exist.", graph_name_str)));
     }
 
+    graph_oid = get_graph_oid(graph_name_str);
+
     // Check if label with the input name already exists
-    if (label_exists(label_name_str, get_graph_oid(graph_name_str)))
+    if (label_exists(label_name_str, graph_oid))
     {
         ereport(ERROR,
                 (errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -156,7 +162,12 @@ Datum create_vlabel(PG_FUNCTION_ARGS)
     //Create the default label tables
     graph = graph_name->data;
     label = label_name->data;
-    create_label(graph, label, LABEL_TYPE_VERTEX, NIL);
+
+    rv = get_label_range_var(graph, graph_oid, AG_DEFAULT_LABEL_VERTEX);
+
+    parent = list_make1(rv);
+
+    create_label(graph, label, LABEL_TYPE_VERTEX, parent);
 
     ereport(NOTICE,
             (errmsg("VLabel \"%s\" has been created", NameStr(*label_name))));
@@ -181,6 +192,10 @@ Datum create_elabel(PG_FUNCTION_ARGS)
     char *graph;
     Name graph_name;
     char *graph_name_str;
+    Oid graph_oid;
+    List *parent;
+
+    RangeVar *rv;
 
     char *label;
     Name label_name;
@@ -214,8 +229,10 @@ Datum create_elabel(PG_FUNCTION_ARGS)
                         errmsg("graph \"%s\" does not exist.", graph_name_str)));
     }
 
+    graph_oid = get_graph_oid(graph_name_str);
+
     // Check if label with the input name already exists
-    if (label_exists(label_name_str, get_graph_oid(graph_name_str)))
+    if (label_exists(label_name_str, graph_oid))
     {
         ereport(ERROR,
                 (errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -225,7 +242,11 @@ Datum create_elabel(PG_FUNCTION_ARGS)
     //Create the default label tables
     graph = graph_name->data;
     label = label_name->data;
-    create_label(graph, label, LABEL_TYPE_EDGE, NIL);
+
+    rv = get_label_range_var(graph, graph_oid, AG_DEFAULT_LABEL_EDGE);
+
+    parent = list_make1(rv);
+    create_label(graph, label, LABEL_TYPE_EDGE, parent);
 
     ereport(NOTICE,
             (errmsg("ELabel \"%s\" has been created", NameStr(*label_name))));