You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by jg...@apache.org on 2023/02/14 18:21:26 UTC
[age] 01/08: Added some comments for create_graph function (#582)
This is an automated email from the ASF dual-hosted git repository.
jgemignani pushed a commit to branch PG12
in repository https://gitbox.apache.org/repos/asf/age.git
commit f73b16f49154eade505539d2c0043859e2ec5757
Author: Hrishikesh Mallick <65...@users.noreply.github.com>
AuthorDate: Mon Jan 23 22:45:44 2023 +0530
Added some comments for create_graph function (#582)
* Added comments for create_graph function
---
src/backend/commands/graph_commands.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/backend/commands/graph_commands.c b/src/backend/commands/graph_commands.c
index 095c6ad..7df40b9 100644
--- a/src/backend/commands/graph_commands.c
+++ b/src/backend/commands/graph_commands.c
@@ -57,6 +57,7 @@ static void rename_graph(const Name graph_name, const Name new_name);
PG_FUNCTION_INFO_V1(create_graph);
+/* function that is evoked for creating a graph */
Datum create_graph(PG_FUNCTION_ARGS)
{
char *graph;
@@ -64,20 +65,26 @@ Datum create_graph(PG_FUNCTION_ARGS)
char *graph_name_str;
Oid nsp_id;
+ //if no argument is passed with the function, graph name cannot be null
if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("graph name can not be NULL")));
}
- graph_name = PG_GETARG_NAME(0);
+
+ //gets graph name as function argument
+ graph_name = PG_GETARG_NAME(0);
graph_name_str = NameStr(*graph_name);
+ //checking if the name of the graph falls under the pre-decided graph naming conventions(regex)
if (!is_valid_graph_name(graph_name_str))
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("graph name is invalid")));
}
+
+ //graph name must be unique, a graph with the same name should not exist
if (graph_exists(graph_name_str))
{
ereport(ERROR,
@@ -87,7 +94,8 @@ Datum create_graph(PG_FUNCTION_ARGS)
nsp_id = create_schema_for_graph(graph_name);
- insert_graph(graph_name, nsp_id);
+ //inserts the graph info into the relation which has all the other existing graphs info
+ insert_graph(graph_name, nsp_id);
//Increment the Command counter before create the generic labels.
CommandCounterIncrement();
@@ -100,7 +108,8 @@ Datum create_graph(PG_FUNCTION_ARGS)
ereport(NOTICE,
(errmsg("graph \"%s\" has been created", NameStr(*graph_name))));
- PG_RETURN_VOID();
+ //according to postgres specification of c-language functions if function returns void this is the syntax
+ PG_RETURN_VOID();
}
static Oid create_schema_for_graph(const Name graph_name)