Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PG Conventions] Converted single line comments to multiline #1918

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/backend/catalog/ag_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString,

static void drop_age_extension(DropStmt *stmt)
{
// Remove all graphs
/* Remove all graphs */
drop_graphs(get_graphnames());

// Remove the object access hook
/* Remove the object access hook */
object_access_hook_fini();

/*
Expand All @@ -130,7 +130,7 @@ static void drop_age_extension(DropStmt *stmt)
clear_global_Oids_GRAPHID();
}

// Check to see if the Utility Command is to drop the AGE Extension.
/* Check to see if the Utility Command is to drop the AGE Extension. */
static bool is_age_drop(PlannedStmt *pstmt)
{
ListCell *lc;
Expand Down Expand Up @@ -172,7 +172,7 @@ static void object_access(ObjectAccessType access, Oid class_id, Oid object_id,
if (prev_object_access_hook)
prev_object_access_hook(access, class_id, object_id, sub_id, arg);

// We are interested in DROP SCHEMA and DROP TABLE commands.
/* We are interested in DROP SCHEMA and DROP TABLE commands. */
if (access != OAT_DROP)
return;

Expand Down Expand Up @@ -214,7 +214,7 @@ static void object_access(ObjectAccessType access, Oid class_id, Oid object_id,

cache_data = search_label_relation_cache(object_id);

// We are interested in only tables that are labels.
/* We are interested in only tables that are labels. */
if (!cache_data)
return;

Expand Down
14 changes: 7 additions & 7 deletions src/backend/catalog/ag_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

static Oid get_graph_namespace(const char *graph_name);

// INSERT INTO ag_catalog.ag_graph VALUES (graph_name, nsp_id)
/* INSERT INTO ag_catalog.ag_graph VALUES (graph_name, nsp_id) */
void insert_graph(const Name graph_name, const Oid nsp_id)
{
Datum values[Natts_ag_graph];
Expand Down Expand Up @@ -73,7 +73,7 @@ void insert_graph(const Name graph_name, const Oid nsp_id)
table_close(ag_graph, RowExclusiveLock);
}

// DELETE FROM ag_catalog.ag_graph WHERE name = graph_name
/* DELETE FROM ag_catalog.ag_graph WHERE name = graph_name */
void delete_graph(const Name graph_name)
{
ScanKeyData scan_keys[1];
Expand Down Expand Up @@ -102,7 +102,7 @@ void delete_graph(const Name graph_name)
table_close(ag_graph, RowExclusiveLock);
}

// Function updates graph name in ag_graph table.
/* Function updates graph name in ag_graph table. */
void update_graph_name(const Name graph_name, const Name new_name)
{
ScanKeyData scan_keys[1];
Expand All @@ -114,7 +114,7 @@ void update_graph_name(const Name graph_name, const Name new_name)
bool do_replace[Natts_ag_graph];
HeapTuple new_tuple;

// open and scan ag_graph for graph name
/* open and scan ag_graph for graph name */
ScanKeyInit(&scan_keys[0], Anum_ag_graph_name, BTEqualStrategyNumber,
F_NAMEEQ, NameGetDatum(graph_name));

Expand All @@ -131,7 +131,7 @@ void update_graph_name(const Name graph_name, const Name new_name)
errmsg("graph \"%s\" does not exist", NameStr(*graph_name))));
}

// modify (which creates a new tuple) the current tuple's graph name
/* modify (which creates a new tuple) the current tuple's graph name */
MemSet(repl_values, 0, sizeof(repl_values));
MemSet(repl_isnull, false, sizeof(repl_isnull));
MemSet(do_replace, false, sizeof(do_replace));
Expand All @@ -143,10 +143,10 @@ void update_graph_name(const Name graph_name, const Name new_name)
new_tuple = heap_modify_tuple(cur_tuple, RelationGetDescr(ag_graph),
repl_values, repl_isnull, do_replace);

// update the current tuple with the new tuple
/* update the current tuple with the new tuple */
CatalogTupleUpdate(ag_graph, &cur_tuple->t_self, new_tuple);

// end scan and close ag_graph
/* end scan and close ag_graph */
systable_endscan(scan_desc);
table_close(ag_graph, RowExclusiveLock);
}
Expand Down
10 changes: 5 additions & 5 deletions src/backend/catalog/ag_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void insert_label(const char *label_name, Oid graph_oid, int32 label_id,
table_close(ag_label, RowExclusiveLock);
}

// DELETE FROM ag_catalog.ag_label WHERE relation = relation
/* DELETE FROM ag_catalog.ag_label WHERE relation = relation */
void delete_label(Oid relation)
{
ScanKeyData scan_keys[1];
Expand Down Expand Up @@ -290,13 +290,13 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
TupleTableSlot *slot;
ResultRelInfo *resultRelInfo;

// setup scan keys to get all edges for the given graph oid
/* setup scan keys to get all edges for the given graph oid */
ScanKeyInit(&scan_keys[1], Anum_ag_label_graph, BTEqualStrategyNumber,
F_OIDEQ, ObjectIdGetDatum(graph_oid));
ScanKeyInit(&scan_keys[0], Anum_ag_label_kind, BTEqualStrategyNumber,
F_CHAREQ, CharGetDatum(LABEL_TYPE_EDGE));

// setup the table to be scanned
/* setup the table to be scanned */
ag_label = table_open(ag_label_relation_id(), RowExclusiveLock);
scan_desc = table_beginscan(ag_label, estate->es_snapshot, 2, scan_keys);

Expand All @@ -307,7 +307,7 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
estate, RelationGetDescr(resultRelInfo->ri_RelationDesc),
&TTSOpsHeapTuple);

// scan through the results and get all the label names.
/* scan through the results and get all the label names. */
while(true)
{
Name label;
Expand All @@ -316,7 +316,7 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)

tuple = heap_getnext(scan_desc, ForwardScanDirection);

// no more labels to process
/* no more labels to process */
if (!HeapTupleIsValid(tuple))
break;

Expand Down
42 changes: 21 additions & 21 deletions src/backend/commands/graph_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +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 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")));
}

//gets graph name as function argument
/* 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)
/* 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
/* graph name must be unique, a graph with the same name should not exist */
if (graph_exists(graph_name_str))
{
ereport(ERROR,
Expand All @@ -94,21 +94,21 @@ Datum create_graph(PG_FUNCTION_ARGS)

nsp_id = create_schema_for_graph(graph_name);

//inserts the graph info into the relation which has all the other existing graphs info
/* 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.
/* Increment the Command counter before create the generic labels. */
CommandCounterIncrement();

//Create the default label tables
/* Create the default label tables */
graph = graph_name->data;
create_label(graph, AG_DEFAULT_LABEL_VERTEX, LABEL_TYPE_VERTEX, NIL);
create_label(graph, AG_DEFAULT_LABEL_EDGE, LABEL_TYPE_EDGE, NIL);

ereport(NOTICE,
(errmsg("graph \"%s\" has been created", NameStr(*graph_name))));

//according to postgres specification of c-language functions if function returns void this is the syntax
/* according to postgres specification of c-language functions if function returns void this is the syntax */
PG_RETURN_VOID();
}

Expand Down Expand Up @@ -157,7 +157,7 @@ static Oid create_schema_for_graph(const Name graph_name)
schema_stmt->if_not_exists = false;
nsp_id = CreateSchemaCommand(schema_stmt,
"(generated CREATE SCHEMA command)", -1, -1);
// CommandCounterIncrement() is called in CreateSchemaCommand()
/* CommandCounterIncrement() is called in CreateSchemaCommand() */

return nsp_id;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ static void drop_schema_for_graph(char *graph_name_str, const bool cascade)
* so the event triggers will not be fired.
*/

// DROP SEQUENCE `graph_name_str`.`LABEL_ID_SEQ_NAME`
/* DROP SEQUENCE `graph_name_str`.`LABEL_ID_SEQ_NAME` */
drop_stmt = makeNode(DropStmt);
schema_name = makeString(get_graph_namespace_name(graph_name_str));
label_id_seq_name = list_make2(schema_name, makeString(LABEL_ID_SEQ_NAME));
Expand All @@ -218,28 +218,28 @@ static void drop_schema_for_graph(char *graph_name_str, const bool cascade)
drop_stmt->concurrent = false;

RemoveRelations(drop_stmt);
// CommandCounterIncrement() is called in RemoveRelations()
/* CommandCounterIncrement() is called in RemoveRelations() */

// DROP SCHEMA `graph_name_str` [ CASCADE ]
/* DROP SCHEMA `graph_name_str` [ CASCADE ] */
behavior = cascade ? DROP_CASCADE : DROP_RESTRICT;
remove_schema((Node *)schema_name, behavior);
// CommandCounterIncrement() is called in performDeletion()
/* CommandCounterIncrement() is called in performDeletion() */
}

// See RemoveObjects() for more details.
/* See RemoveObjects() for more details. */
static void remove_schema(Node *schema_name, DropBehavior behavior)
{
ObjectAddress address;
Relation relation;

address = get_object_address(OBJECT_SCHEMA, schema_name, &relation,
AccessExclusiveLock, false);
// since the target object is always a schema, relation is NULL
/* since the target object is always a schema, relation is NULL */
Assert(!relation);

if (!OidIsValid(address.objectId))
{
// missing_ok is always false
/* missing_ok is always false */

/*
* before calling this function, this condition is already checked in
Expand All @@ -251,7 +251,7 @@ static void remove_schema(Node *schema_name, DropBehavior behavior)
strVal(schema_name))));
}

// removeType is always OBJECT_SCHEMA
/* removeType is always OBJECT_SCHEMA */

/*
* Check permissions. Since the target object is always a schema, the
Expand All @@ -260,9 +260,9 @@ static void remove_schema(Node *schema_name, DropBehavior behavior)
check_object_ownership(GetUserId(), OBJECT_SCHEMA, address, schema_name,
NULL);

// the target schema is not temporary
/* the target schema is not temporary */

// the target object is always a schema
/* the target object is always a schema */

/*
* set PERFORM_DELETION_INTERNAL flag so that object_access_hook can ignore
Expand Down Expand Up @@ -355,7 +355,7 @@ static void rename_graph(const Name graph_name, const Name new_name)
(errmsg("graph \"%s\" renamed to \"%s\"", oldname, newname)));
}

// returns a list containing the name of every graph in the database
/* returns a list containing the name of every graph in the database */
List *get_graphnames(void)
{
TupleTableSlot *slot;
Expand Down Expand Up @@ -393,7 +393,7 @@ List *get_graphnames(void)
return graphnames;
}

// deletes all the graphs in the list.
/* deletes all the graphs in the list. */
void drop_graphs(List *graphnames)
{
ListCell *lc;
Expand Down
Loading
Loading