From 80ea5a3301604eee14b02c7bf87bc3f2bafda8c7 Mon Sep 17 00:00:00 2001 From: Umar Hayat Date: Sat, 8 Jun 2024 16:56:14 +0900 Subject: [PATCH] Converted single line comments to multiline Converted all single line comments in C file to multiline comments based PostgreSQL coding conventions --- src/backend/catalog/ag_catalog.c | 10 +- src/backend/catalog/ag_graph.c | 14 +- src/backend/catalog/ag_label.c | 10 +- src/backend/commands/graph_commands.c | 42 +-- src/backend/commands/label_commands.c | 139 +++++----- src/backend/executor/cypher_create.c | 50 ++-- src/backend/executor/cypher_delete.c | 22 +- src/backend/executor/cypher_merge.c | 34 +-- src/backend/executor/cypher_set.c | 28 +- src/backend/executor/cypher_utils.c | 12 +- src/backend/nodes/ag_nodes.c | 4 +- src/backend/nodes/cypher_copyfuncs.c | 26 +- src/backend/nodes/cypher_outfuncs.c | 70 ++--- src/backend/nodes/cypher_readfuncs.c | 34 +-- src/backend/optimizer/cypher_createplan.c | 17 +- src/backend/optimizer/cypher_pathnode.c | 44 ++-- src/backend/optimizer/cypher_paths.c | 40 +-- src/backend/parser/ag_scanner.l | 68 ++--- src/backend/parser/cypher_analyze.c | 28 +- src/backend/parser/cypher_clause.c | 255 ++++++++++--------- src/backend/parser/cypher_expr.c | 26 +- src/backend/parser/cypher_gram.y | 54 ++-- src/backend/parser/cypher_item.c | 48 ++-- src/backend/parser/cypher_keywords.c | 6 +- src/backend/parser/cypher_parse_node.c | 2 +- src/backend/parser/cypher_transform_entity.c | 4 +- src/backend/utils/adt/agtype.c | 56 ++-- src/backend/utils/adt/agtype_ext.c | 2 +- src/backend/utils/adt/agtype_ops.c | 6 +- src/backend/utils/adt/agtype_raw.c | 34 +-- src/backend/utils/adt/agtype_util.c | 4 +- src/backend/utils/adt/graphid.c | 10 +- src/backend/utils/ag_func.c | 4 +- src/backend/utils/cache/ag_cache.c | 120 ++++----- src/backend/utils/graph_generation.c | 28 +- src/backend/utils/load/ag_load_edges.c | 4 +- src/backend/utils/load/ag_load_labels.c | 2 +- src/backend/utils/load/age_load.c | 4 +- src/backend/utils/load/libcsv.c | 3 +- src/include/executor/cypher_utils.h | 2 +- src/include/nodes/ag_nodes.h | 30 +-- src/include/nodes/cypher_copyfuncs.h | 8 +- src/include/nodes/cypher_nodes.h | 66 ++--- src/include/nodes/cypher_outfuncs.h | 26 +- src/include/nodes/cypher_readfuncs.h | 6 +- src/include/parser/ag_scanner.h | 2 +- src/include/parser/cypher_clause.h | 4 +- src/include/parser/cypher_gram.h | 4 +- src/include/parser/cypher_parse_node.h | 6 +- src/include/parser/cypher_transform_entity.h | 4 +- src/include/utils/ag_cache.h | 6 +- src/include/utils/graphid.h | 3 +- src/include/utils/load/ag_load_edges.h | 2 +- src/include/utils/load/ag_load_labels.h | 2 +- src/include/utils/load/age_load.h | 2 +- src/include/utils/load/csv.h | 6 +- 56 files changed, 781 insertions(+), 762 deletions(-) diff --git a/src/backend/catalog/ag_catalog.c b/src/backend/catalog/ag_catalog.c index 7b8a96c13..9c070fc6e 100644 --- a/src/backend/catalog/ag_catalog.c +++ b/src/backend/catalog/ag_catalog.c @@ -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(); /* @@ -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; @@ -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; @@ -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; diff --git a/src/backend/catalog/ag_graph.c b/src/backend/catalog/ag_graph.c index 7594eea59..d03e08126 100644 --- a/src/backend/catalog/ag_graph.c +++ b/src/backend/catalog/ag_graph.c @@ -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]; @@ -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]; @@ -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]; @@ -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)); @@ -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)); @@ -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); } diff --git a/src/backend/catalog/ag_label.c b/src/backend/catalog/ag_label.c index 563d53489..346cb85dc 100644 --- a/src/backend/catalog/ag_label.c +++ b/src/backend/catalog/ag_label.c @@ -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]; @@ -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); @@ -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; @@ -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; diff --git a/src/backend/commands/graph_commands.c b/src/backend/commands/graph_commands.c index 2d70e65a5..df16ad152 100644 --- a/src/backend/commands/graph_commands.c +++ b/src/backend/commands/graph_commands.c @@ -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, @@ -94,13 +94,13 @@ 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); @@ -108,7 +108,7 @@ Datum create_graph(PG_FUNCTION_ARGS) 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(); } @@ -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; } @@ -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)); @@ -218,15 +218,15 @@ 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; @@ -234,12 +234,12 @@ static void remove_schema(Node *schema_name, DropBehavior behavior) 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 @@ -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 @@ -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 @@ -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; @@ -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; diff --git a/src/backend/commands/label_commands.c b/src/backend/commands/label_commands.c index 80da6b020..9f051060f 100644 --- a/src/backend/commands/label_commands.c +++ b/src/backend/commands/label_commands.c @@ -65,7 +65,7 @@ static void create_table_for_label(char *graph_name, char *label_name, char *seq_name, char label_type, List *parents); -// common +/* common */ static List *create_edge_table_elements(char *graph_name, char *label_name, char *schema_name, char *rel_name, char *seq_name); @@ -87,7 +87,7 @@ static void change_label_id_default(char *graph_name, char *label_name, char *schema_name, char *seq_name, Oid relid); -// drop +/* drop */ static void remove_relation(List *qname); static void range_var_callback_for_remove_relation(const RangeVar *rel, Oid rel_oid, @@ -122,14 +122,14 @@ Datum create_vlabel(PG_FUNCTION_ARGS) Name label_name; char *label_name_str; - // checking if user has not provided the graph name + /* checking if user has not provided the graph name */ if (PG_ARGISNULL(0)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("graph name must not be NULL"))); } - // checking if user has not provided the label name + /* checking if user has not provided the label name */ if (PG_ARGISNULL(1)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -142,7 +142,7 @@ Datum create_vlabel(PG_FUNCTION_ARGS) graph_name_str = NameStr(*graph_name); label_name_str = NameStr(*label_name); - // Check if graph does not exist + /* Check if graph does not exist */ if (!graph_exists(graph_name_str)) { ereport(ERROR, @@ -152,7 +152,7 @@ Datum create_vlabel(PG_FUNCTION_ARGS) graph_oid = get_graph_oid(graph_name_str); - // Check if label with the input name already exists + /* Check if label with the input name already exists */ if (label_exists(label_name_str, graph_oid)) { ereport(ERROR, @@ -160,7 +160,7 @@ Datum create_vlabel(PG_FUNCTION_ARGS) errmsg("label \"%s\" already exists", label_name_str))); } - //Create the default label tables + /* Create the default label tables */ graph = graph_name->data; label = label_name->data; @@ -202,14 +202,14 @@ Datum create_elabel(PG_FUNCTION_ARGS) Name label_name; char *label_name_str; - // checking if user has not provided the graph name + /* checking if user has not provided the graph name */ if (PG_ARGISNULL(0)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("graph name must not be NULL"))); } - // checking if user has not provided the label name + /* checking if user has not provided the label name */ if (PG_ARGISNULL(1)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -222,7 +222,7 @@ Datum create_elabel(PG_FUNCTION_ARGS) graph_name_str = NameStr(*graph_name); label_name_str = NameStr(*label_name); - // Check if graph does not exist + /* Check if graph does not exist */ if (!graph_exists(graph_name_str)) { ereport(ERROR, @@ -232,7 +232,7 @@ Datum create_elabel(PG_FUNCTION_ARGS) graph_oid = get_graph_oid(graph_name_str); - // Check if label with the input name already exists + /* Check if label with the input name already exists */ if (label_exists(label_name_str, graph_oid)) { ereport(ERROR, @@ -240,7 +240,7 @@ Datum create_elabel(PG_FUNCTION_ARGS) errmsg("label \"%s\" already exists", label_name_str))); } - //Create the default label tables + /* Create the default label tables */ graph = graph_name->data; label = label_name->data; @@ -288,29 +288,29 @@ void create_label(char *graph_name, char *label_name, char label_type, graph_oid = cache_data->oid; nsp_id = cache_data->namespace; - // create a sequence for the new label to generate unique IDs for vertices + /* create a sequence for the new label to generate unique IDs for vertices */ schema_name = get_namespace_name(nsp_id); rel_name = gen_label_relation_name(label_name); seq_name = ChooseRelationName(rel_name, "id", "seq", nsp_id, false); seq_range_var = makeRangeVar(schema_name, seq_name, -1); create_sequence_for_label(seq_range_var); - // create a table for the new label + /* create a table for the new label */ create_table_for_label(graph_name, label_name, schema_name, rel_name, seq_name, label_type, parents); - // record the new label in ag_label + /* record the new label in ag_label */ relation_id = get_relname_relid(rel_name, nsp_id); - // If a label has parents, switch the parents id default, with its own. + /* If a label has parents, switch the parents id default, with its own. */ if (list_length(parents) != 0) change_label_id_default(graph_name, label_name, schema_name, seq_name, relation_id); - // associate the sequence with the "id" column + /* associate the sequence with the "id" column */ alter_sequence_owned_by_for_label(seq_range_var, rel_name); - // get a new "id" for the new label + /* get a new "id" for the new label */ label_id = get_new_label_id(graph_oid, nsp_id); insert_label(label_name, graph_oid, label_id, label_type, @@ -319,12 +319,14 @@ void create_label(char *graph_name, char *label_name, char label_type, CommandCounterIncrement(); } -// CREATE TABLE `schema_name`.`rel_name` ( -// "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), -// "start_id" graphid NOT NULL note: only for edge labels -// "end_id" graphid NOT NULL note: only for edge labels -// "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() -// ) +/* + * CREATE TABLE `schema_name`.`rel_name` ( + * "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), + * "start_id" graphid NOT NULL note: only for edge labels + * "end_id" graphid NOT NULL note: only for edge labels + * "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() + * ) + */ static void create_table_for_label(char *graph_name, char *label_name, char *schema_name, char *rel_name, char *seq_name, char label_type, @@ -335,7 +337,7 @@ static void create_table_for_label(char *graph_name, char *label_name, create_stmt = makeNode(CreateStmt); - // relpersistence is set to RELPERSISTENCE_PERMANENT by makeRangeVar() + /* relpersistence is set to RELPERSISTENCE_PERMANENT by makeRangeVar() */ create_stmt->relation = makeRangeVar(schema_name, rel_name, -1); /* @@ -374,15 +376,17 @@ static void create_table_for_label(char *graph_name, char *label_name, ProcessUtility(wrapper, "(generated CREATE TABLE command)", false, PROCESS_UTILITY_SUBCOMMAND, NULL, NULL, None_Receiver, NULL); - // CommandCounterIncrement() is called in ProcessUtility() + /* CommandCounterIncrement() is called in ProcessUtility() */ } -// CREATE TABLE `schema_name`.`rel_name` ( -// "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), -// "start_id" graphid NOT NULL -// "end_id" graphid NOT NULL -// "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() -// ) +/* + * CREATE TABLE `schema_name`.`rel_name` ( + * "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), + * "start_id" graphid NOT NULL + * "end_id" graphid NOT NULL + * "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() + * ) + */ static List *create_edge_table_elements(char *graph_name, char *label_name, char *schema_name, char *rel_name, char *seq_name) @@ -392,22 +396,22 @@ static List *create_edge_table_elements(char *graph_name, char *label_name, ColumnDef *end_id; ColumnDef *props; - // "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...) + /* "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...) */ id = makeColumnDef(AG_EDGE_COLNAME_ID, GRAPHIDOID, -1, InvalidOid); id->constraints = list_make2(build_pk_constraint(), build_id_default(graph_name, label_name, schema_name, seq_name)); - // "start_id" graphid NOT NULL + /* "start_id" graphid NOT NULL */ start_id = makeColumnDef(AG_EDGE_COLNAME_START_ID, GRAPHIDOID, -1, InvalidOid); start_id->constraints = list_make1(build_not_null_constraint()); - // "end_id" graphid NOT NULL + /* "end_id" graphid NOT NULL */ end_id = makeColumnDef(AG_EDGE_COLNAME_END_ID, GRAPHIDOID, -1, InvalidOid); end_id->constraints = list_make1(build_not_null_constraint()); - // "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() + /* "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() */ props = makeColumnDef(AG_EDGE_COLNAME_PROPERTIES, AGTYPEOID, -1, InvalidOid); props->constraints = list_make2(build_not_null_constraint(), @@ -416,10 +420,12 @@ static List *create_edge_table_elements(char *graph_name, char *label_name, return list_make4(id, start_id, end_id, props); } -// CREATE TABLE `schema_name`.`rel_name` ( -// "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), -// "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() -// ) +/* + * CREATE TABLE `schema_name`.`rel_name` ( + * "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...), + * "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() + * ) + */ static List *create_vertex_table_elements(char *graph_name, char *label_name, char *schema_name, char *rel_name, char *seq_name) @@ -427,13 +433,13 @@ static List *create_vertex_table_elements(char *graph_name, char *label_name, ColumnDef *id; ColumnDef *props; - // "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...) + /* "id" graphid PRIMARY KEY DEFAULT "ag_catalog"."_graphid"(...) */ id = makeColumnDef(AG_VERTEX_COLNAME_ID, GRAPHIDOID, -1, InvalidOid); id->constraints = list_make2(build_pk_constraint(), build_id_default(graph_name, label_name, schema_name, seq_name)); - // "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() + /* "properties" agtype NOT NULL DEFAULT "ag_catalog"."agtype_build_map"() */ props = makeColumnDef(AG_VERTEX_COLNAME_PROPERTIES, AGTYPEOID, -1, InvalidOid); props->constraints = list_make2(build_not_null_constraint(), @@ -442,12 +448,13 @@ static List *create_vertex_table_elements(char *graph_name, char *label_name, return list_make2(id, props); } -// CREATE SEQUENCE `seq_range_var` MAXVALUE `LOCAL_ID_MAX` +/* CREATE SEQUENCE `seq_range_var` MAXVALUE `LOCAL_ID_MAX` */ static void create_sequence_for_label(RangeVar *seq_range_var) { ParseState *pstate; CreateSeqStmt *seq_stmt; - char buf[32]; // greater than MAXINT8LEN+1 + /* greater than MAXINT8LEN+1 */ + char buf[32]; DefElem *maxvalue; pstate = make_parsestate(NULL); @@ -506,7 +513,7 @@ static FuncCall *build_id_default_func_expr(char *graph_name, char *label_name, List *graphid_func_args; FuncCall *graphid_func; - // Build a node that gets the label id + /* Build a node that gets the label id */ label_id_func_name = list_make2(makeString("ag_catalog"), makeString("_label_id")); graph_name_const = makeNode(A_Const); @@ -520,7 +527,7 @@ static FuncCall *build_id_default_func_expr(char *graph_name, char *label_name, label_id_func_args = list_make2(graph_name_const, label_name_const); label_id_func = makeFuncCall(label_id_func_name, label_id_func_args, COERCE_SQL_SYNTAX, -1); - //Build a node that will get the next val from the label's sequence + /* Build a node that will get the next val from the label's sequence */ nextval_func_name = SystemFuncName("nextval"); qualified_seq_name = quote_qualified_identifier(schema_name, seq_name); qualified_seq_name_const = makeNode(A_Const); @@ -567,7 +574,7 @@ static Constraint *build_id_default(char *graph_name, char *label_name, return id_default; } -// NOT NULL +/* NOT NULL */ static Constraint *build_not_null_constraint(void) { Constraint *not_null; @@ -579,14 +586,14 @@ static Constraint *build_not_null_constraint(void) return not_null; } -// DEFAULT "ag_catalog"."agtype_build_map"() +/* DEFAULT "ag_catalog"."agtype_build_map"() */ static Constraint *build_properties_default(void) { List *func_name; FuncCall *func; Constraint *props_default; - // "ag_catalog"."agtype_build_map"() + /* "ag_catalog"."agtype_build_map"() */ func_name = list_make2(makeString("ag_catalog"), makeString("agtype_build_map")); func = makeFuncCall(func_name, NIL, COERCE_SQL_SYNTAX, -1); @@ -643,7 +650,7 @@ static void change_label_id_default(char *graph_name, char *label_name, CommandCounterIncrement(); } -// CREATE SEQUENCE `seq_range_var` OWNED BY `schema_name`.`rel_name`."id" +/* CREATE SEQUENCE `seq_range_var` OWNED BY `schema_name`.`rel_name`."id" */ static void alter_sequence_owned_by_for_label(RangeVar *seq_range_var, char *rel_name) { @@ -675,7 +682,7 @@ static int32 get_new_label_id(Oid graph_oid, Oid nsp_id) Oid seq_id; int cnt; - // get the OID of the sequence + /* get the OID of the sequence */ seq_id = get_relname_relid(LABEL_ID_SEQ_NAME, nsp_id); if (!OidIsValid(seq_id)) { @@ -688,7 +695,7 @@ static int32 get_new_label_id(Oid graph_oid, Oid nsp_id) { int32 label_id; - // the data type of the sequence is integer (int4) + /* the data type of the sequence is integer (int4) */ label_id = (int32) nextval_internal(seq_id, true); Assert(label_id_is_valid(label_id)); if (!label_id_exists(graph_oid, label_id)) @@ -785,9 +792,9 @@ Datum drop_label(PG_FUNCTION_ARGS) qname = list_make2(makeString(schema_name), makeString(rel_name)); remove_relation(qname); - // CommandCounterIncrement() is called in performDeletion() + /* CommandCounterIncrement() is called in performDeletion() */ - // delete_label() will be called in object_access() + /* delete_label() will be called in object_access() */ ereport(NOTICE, (errmsg("label \"%s\".\"%s\" has been dropped", graph_name_str, label_name_str))); @@ -795,7 +802,7 @@ Datum drop_label(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } -// See RemoveRelations() for more details. +/* See RemoveRelations() for more details. */ static void remove_relation(List *qname) { RangeVar *rel; @@ -804,9 +811,9 @@ static void remove_relation(List *qname) Assert(list_length(qname) == 2); - // concurrent is false so lockmode is AccessExclusiveLock + /* concurrent is false so lockmode is AccessExclusiveLock */ - // relkind is RELKIND_RELATION + /* relkind is RELKIND_RELATION */ AcceptInvalidationMessages(); @@ -828,7 +835,7 @@ static void remove_relation(List *qname) rel->schemaname, rel->relname))); } - // concurrent is false + /* concurrent is false */ ObjectAddressSet(address, RelationRelationId, rel_oid); @@ -839,7 +846,7 @@ static void remove_relation(List *qname) performDeletion(&address, DROP_RESTRICT, PERFORM_DELETION_INTERNAL); } -// See RangeVarCallbackForDropRelation() for more details. +/* See RangeVarCallbackForDropRelation() for more details. */ static void range_var_callback_for_remove_relation(const RangeVar *rel, Oid rel_oid, Oid odl_rel_oid, @@ -851,16 +858,16 @@ static void range_var_callback_for_remove_relation(const RangeVar *rel, * always false. See RemoveRelations() for more details. */ - // heapOid is always InvalidOid + /* heapOid is always InvalidOid */ - // partParentOid is always InvalidOid + /* partParentOid is always InvalidOid */ if (!OidIsValid(rel_oid)) return; - // classform->relkind is always RELKIND_RELATION + /* classform->relkind is always RELKIND_RELATION */ - // relkind == expected_relkind + /* relkind == expected_relkind */ if (!object_ownercheck(rel_oid, get_rel_namespace(rel_oid), GetUserId())) { @@ -869,9 +876,9 @@ static void range_var_callback_for_remove_relation(const RangeVar *rel, rel->relname); } - // the target relation is not system class + /* the target relation is not system class */ - // relkind is always RELKIND_RELATION + /* relkind is always RELKIND_RELATION */ - // is_partition is false + /* is_partition is false */ } diff --git a/src/backend/executor/cypher_create.c b/src/backend/executor/cypher_create.c index b85d1b872..2091ea29c 100644 --- a/src/backend/executor/cypher_create.c +++ b/src/backend/executor/cypher_create.c @@ -93,19 +93,19 @@ static void begin_cypher_create(CustomScanState *node, EState *estate, if (!CYPHER_TARGET_NODE_INSERT_ENTITY(cypher_node->flags)) continue; - // Open relation and acquire a row exclusive lock. + /* Open relation and acquire a row exclusive lock. */ rel = table_open(cypher_node->relid, RowExclusiveLock); - // Initialize resultRelInfo for the vertex + /* Initialize resultRelInfo for the vertex */ cypher_node->resultRelInfo = makeNode(ResultRelInfo); InitResultRelInfo(cypher_node->resultRelInfo, rel, list_length(estate->es_range_table), NULL, estate->es_instrument); - // Open all indexes for the relation + /* Open all indexes for the relation */ ExecOpenIndices(cypher_node->resultRelInfo, false); - // Setup the relation's tuple slot + /* Setup the relation's tuple slot */ cypher_node->elemTupleSlot = table_slot_create( rel, &estate->es_tupleTable); @@ -256,7 +256,7 @@ static void end_cypher_create(CustomScanState *node) (cypher_create_custom_scan_state *)node; ListCell *lc; - // increment the command counter + /* increment the command counter */ CommandCounterIncrement(); ExecEndNode(node->ss.ps.lefttree); @@ -276,10 +276,10 @@ static void end_cypher_create(CustomScanState *node) continue; } - // close all indices for the node + /* close all indices for the node */ ExecCloseIndices(cypher_node->resultRelInfo); - // close the relation itself + /* close the relation itself */ table_close(cypher_node->resultRelInfo->ri_RelationDesc, RowExclusiveLock); } @@ -303,7 +303,7 @@ Node *create_cypher_create_plan_state(CustomScan *cscan) cypher_css->cs = cscan; - // get the serialized data structure from the Const and deserialize it. + /* get the serialized data structure from the Const and deserialize it. */ c = linitial(cscan->custom_private); serialized_data = (char *)c->constvalue; target_nodes = stringToNode(serialized_data); @@ -354,13 +354,13 @@ static void create_edge(cypher_create_custom_scan_state *css, */ if (node->dir == CYPHER_REL_DIR_RIGHT) { - // create pattern (prev_vertex)-[edge]->(next_vertex) + /* create pattern (prev_vertex)-[edge]->(next_vertex) */ start_id = prev_vertex_id; end_id = next_vertex_id; } else if (node->dir == CYPHER_REL_DIR_LEFT) { - // create pattern (prev_vertex)<-[edge]-(next_vertex) + /* create pattern (prev_vertex)<-[edge]-(next_vertex) */ start_id = next_vertex_id; end_id = prev_vertex_id; } @@ -385,26 +385,26 @@ static void create_edge(cypher_create_custom_scan_state *css, ExecClearTuple(elemTupleSlot); - // Graph Id for the edge + /* Graph Id for the edge */ id = ExecEvalExpr(node->id_expr_state, econtext, &isNull); elemTupleSlot->tts_values[edge_tuple_id] = id; elemTupleSlot->tts_isnull[edge_tuple_id] = isNull; - // Graph id for the starting vertex + /* Graph id for the starting vertex */ elemTupleSlot->tts_values[edge_tuple_start_id] = start_id; elemTupleSlot->tts_isnull[edge_tuple_start_id] = false; - // Graph id for the ending vertex + /* Graph id for the ending vertex */ elemTupleSlot->tts_values[edge_tuple_end_id] = end_id; elemTupleSlot->tts_isnull[edge_tuple_end_id] = false; - // Edge's properties map + /* Edge's properties map */ elemTupleSlot->tts_values[edge_tuple_properties] = scanTupleSlot->tts_values[node->prop_attr_num]; elemTupleSlot->tts_isnull[edge_tuple_properties] = scanTupleSlot->tts_isnull[node->prop_attr_num]; - // Insert the new edge + /* Insert the new edge */ insert_entity_tuple(resultRelInfo, elemTupleSlot, estate); /* restore the old result relation info */ @@ -480,18 +480,18 @@ static Datum create_vertex(cypher_create_custom_scan_state *css, ExecClearTuple(elemTupleSlot); - // get the next graphid for this vertex. + /* get the next graphid for this vertex. */ id = ExecEvalExpr(node->id_expr_state, econtext, &isNull); elemTupleSlot->tts_values[vertex_tuple_id] = id; elemTupleSlot->tts_isnull[vertex_tuple_id] = isNull; - // get the properties for this vertex + /* get the properties for this vertex */ elemTupleSlot->tts_values[vertex_tuple_properties] = scanTupleSlot->tts_values[node->prop_attr_num]; elemTupleSlot->tts_isnull[vertex_tuple_properties] = scanTupleSlot->tts_isnull[node->prop_attr_num]; - // Insert the new vertex + /* Insert the new vertex */ insert_entity_tuple(resultRelInfo, elemTupleSlot, estate); /* restore the old result relation info */ @@ -512,11 +512,11 @@ static Datum create_vertex(cypher_create_custom_scan_state *css, ps = css->css.ss.ps.lefttree; scantuple = ps->ps_ExprContext->ecxt_scantuple; - // make the vertex agtype + /* make the vertex agtype */ result = make_vertex(id, CStringGetDatum(node->label_name), scanTupleSlot->tts_values[node->prop_attr_num]); - // append to the path list + /* append to the path list */ if (CYPHER_TARGET_NODE_IN_PATH(node->flags)) { css->path_values = lappend(css->path_values, @@ -545,10 +545,10 @@ static Datum create_vertex(cypher_create_custom_scan_state *css, ps = css->css.ss.ps.lefttree; scantuple = ps->ps_ExprContext->ecxt_scantuple; - // get the vertex agtype in the scanTupleSlot + /* get the vertex agtype in the scanTupleSlot */ a = DATUM_GET_AGTYPE_P(scantuple->tts_values[node->tuple_position - 1]); - // Convert to an agtype value + /* Convert to an agtype value */ v = get_ith_agtype_value_from_container(&a->root, 0); if (v->type != AGTV_VERTEX) @@ -558,10 +558,10 @@ static Datum create_vertex(cypher_create_custom_scan_state *css, errmsg("agtype must resolve to a vertex"))); } - // extract the id agtype field + /* extract the id agtype field */ id_value = GET_AGTYPE_VALUE_OBJECT_VALUE(v, "id"); - // extract the graphid and cast to a Datum + /* extract the graphid and cast to a Datum */ id = GRAPHID_GET_DATUM(id_value->val.int_value); /* @@ -594,7 +594,7 @@ static Datum create_vertex(cypher_create_custom_scan_state *css, } } - // If the path continues, create the next edge, passing the vertex's id. + /* If the path continues, create the next edge, passing the vertex's id. */ if (next != NULL) { create_edge(css, lfirst(next), id, lnext(list, next), list); diff --git a/src/backend/executor/cypher_delete.c b/src/backend/executor/cypher_delete.c index 3c1457f9f..6bb869833 100644 --- a/src/backend/executor/cypher_delete.c +++ b/src/backend/executor/cypher_delete.c @@ -71,14 +71,14 @@ static void begin_cypher_delete(CustomScanState *node, EState *estate, Assert(list_length(css->cs->custom_plans) == 1); - // setup child + /* setup child */ subplan = linitial(css->cs->custom_plans); node->ss.ps.lefttree = ExecInitNode(subplan, estate, eflags); - // setup expr context + /* setup expr context */ ExecAssignExprContext(estate, &node->ss.ps); - // setup scan tuple slot and projection info + /* setup scan tuple slot and projection info */ ExecInitScanTupleSlot(estate, &node->ss, ExecGetResultType(node->ss.ps.lefttree), &TTSOpsHeapTuple); @@ -101,7 +101,7 @@ static void begin_cypher_delete(CustomScanState *node, EState *estate, MemSet(&hashctl, 0, sizeof(hashctl)); hashctl.keysize = sizeof(graphid); hashctl.entrysize = - sizeof(graphid); // entries are not used, but entrysize must >= keysize + sizeof(graphid); /* entries are not used, but entrysize must >= keysize */ hashctl.hash = tag_hash; css->vertex_id_htab = hash_create(DELETE_VERTEX_HTAB_NAME, DELETE_VERTEX_HTAB_SIZE, &hashctl, @@ -143,7 +143,7 @@ static TupleTableSlot *exec_cypher_delete(CustomScanState *node) */ while(true) { - //Process the subtree first + /* Process the subtree first */ Decrement_Estate_CommandId(estate) slot = ExecProcNode(node->ss.ps.lefttree); Increment_Estate_CommandId(estate) @@ -151,7 +151,7 @@ static TupleTableSlot *exec_cypher_delete(CustomScanState *node) if (TupIsNull(slot)) break; - // setup the scantuple that the process_delete_list needs + /* setup the scantuple that the process_delete_list needs */ econtext->ecxt_scantuple = node->ss.ps.lefttree->ps_ProjInfo->pi_exprContext->ecxt_scantuple; @@ -162,7 +162,7 @@ static TupleTableSlot *exec_cypher_delete(CustomScanState *node) } else { - //Process the subtree first + /* Process the subtree first */ Decrement_Estate_CommandId(estate) slot = ExecProcNode(node->ss.ps.lefttree); Increment_Estate_CommandId(estate) @@ -170,7 +170,7 @@ static TupleTableSlot *exec_cypher_delete(CustomScanState *node) if (TupIsNull(slot)) return NULL; - // setup the scantuple that the process_delete_list needs + /* setup the scantuple that the process_delete_list needs */ econtext->ecxt_scantuple = node->ss.ps.lefttree->ps_ProjInfo->pi_exprContext->ecxt_scantuple; @@ -226,7 +226,7 @@ Node *create_cypher_delete_plan_state(CustomScan *cscan) cypher_css->cs = cscan; - // get the serialized data structure from the Const and deserialize it. + /* get the serialized data structure from the Const and deserialize it. */ c = linitial(cscan->custom_private); serialized_data = (char *)c->constvalue; delete_data = stringToNode(serialized_data); @@ -256,7 +256,7 @@ static agtype_value *extract_entity(CustomScanState *node, tupleDescriptor = scanTupleSlot->tts_tupleDescriptor; - // type checking, make sure the entity is an agtype vertex or edge + /* type checking, make sure the entity is an agtype vertex or edge */ if (tupleDescriptor->attrs[entity_position -1].atttypid != AGTYPEOID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("DELETE clause can only delete agtype"))); @@ -285,7 +285,7 @@ static void delete_entity(EState *estate, ResultRelInfo *resultRelInfo, TM_Result delete_result; Buffer buffer; - // Find the physical tuple, this variable is coming from + /* Find the physical tuple, this variable is coming from */ saved_resultRels = estate->es_result_relations; estate->es_result_relations = &resultRelInfo; diff --git a/src/backend/executor/cypher_merge.c b/src/backend/executor/cypher_merge.c index 18044cd20..29ab1191f 100644 --- a/src/backend/executor/cypher_merge.c +++ b/src/backend/executor/cypher_merge.c @@ -108,7 +108,7 @@ static void begin_cypher_merge(CustomScanState *node, EState *estate, Assert(list_length(css->cs->custom_plans) == 1); - // initialize the subplan + /* initialize the subplan */ subplan = linitial(css->cs->custom_plans); node->ss.ps.lefttree = ExecInitNode(subplan, estate, eflags); @@ -151,19 +151,19 @@ static void begin_cypher_merge(CustomScanState *node, EState *estate, continue; } - // Open relation and acquire a row exclusive lock. + /* Open relation and acquire a row exclusive lock. */ rel = table_open(cypher_node->relid, RowExclusiveLock); - // Initialize resultRelInfo for the vertex + /* Initialize resultRelInfo for the vertex */ cypher_node->resultRelInfo = makeNode(ResultRelInfo); InitResultRelInfo(cypher_node->resultRelInfo, rel, list_length(estate->es_range_table), NULL, estate->es_instrument); - // Open all indexes for the relation + /* Open all indexes for the relation */ ExecOpenIndices(cypher_node->resultRelInfo, false); - // Setup the relation's tuple slot + /* Setup the relation's tuple slot */ cypher_node->elemTupleSlot = ExecInitExtraTupleSlot( estate, RelationGetDescr(cypher_node->resultRelInfo->ri_RelationDesc), @@ -814,10 +814,10 @@ static TupleTableSlot *exec_cypher_merge(CustomScanState *node) /* setup the scantuple that the process_path needs */ econtext->ecxt_scantuple = sss->ss.ss_ScanTupleSlot; - // create the path + /* create the path */ process_path(css, NULL, true); - // mark the create_new_path flag to true. + /* mark the create_new_path flag to true. */ css->created_new_path = true; /* @@ -826,7 +826,7 @@ static TupleTableSlot *exec_cypher_merge(CustomScanState *node) */ mark_tts_isnull(econtext->ecxt_scantuple); - // store the heap tuble + /* store the heap tuble */ ExecStoreVirtualTuple(econtext->ecxt_scantuple); /* @@ -836,7 +836,7 @@ static TupleTableSlot *exec_cypher_merge(CustomScanState *node) sss->ss.ps.ps_ProjInfo->pi_exprContext->ecxt_scantuple = econtext->ecxt_scantuple; - // assign this to be our scantuple + /* assign this to be our scantuple */ econtext->ecxt_scantuple = ExecProject(node->ss.ps.lefttree->ps_ProjInfo); /* @@ -861,7 +861,7 @@ static void end_cypher_merge(CustomScanState *node) ListCell *lc = NULL; int path_length = list_length(path->target_nodes); - // increment the command counter + /* increment the command counter */ CommandCounterIncrement(); ExecEndNode(node->ss.ps.lefttree); @@ -875,10 +875,10 @@ static void end_cypher_merge(CustomScanState *node) continue; } - // close all indices for the node + /* close all indices for the node */ ExecCloseIndices(cypher_node->resultRelInfo); - // close the relation itself + /* close the relation itself */ table_close(cypher_node->resultRelInfo->ri_RelationDesc, RowExclusiveLock); } @@ -931,7 +931,7 @@ Node *create_cypher_merge_plan_state(CustomScan *cscan) cypher_css->cs = cscan; - // get the serialized data structure from the Const and deserialize it. + /* get the serialized data structure from the Const and deserialize it. */ c = linitial(cscan->custom_private); serialized_data = (char *)c->constvalue; merge_information = stringToNode(serialized_data); @@ -1291,13 +1291,13 @@ static void merge_edge(cypher_merge_custom_scan_state *css, */ if (node->dir == CYPHER_REL_DIR_RIGHT || node->dir == CYPHER_REL_DIR_NONE) { - // create pattern (prev_vertex)-[edge]->(next_vertex) + /* create pattern (prev_vertex)-[edge]->(next_vertex) */ start_id = prev_vertex_id; end_id = next_vertex_id; } else if (node->dir == CYPHER_REL_DIR_LEFT) { - // create pattern (prev_vertex)<-[edge]-(next_vertex) + /* create pattern (prev_vertex)<-[edge]-(next_vertex) */ start_id = next_vertex_id; end_id = prev_vertex_id; } @@ -1423,14 +1423,14 @@ static void merge_edge(cypher_merge_custom_scan_state *css, result = make_edge(id, start_id, end_id, CStringGetDatum(node->label_name), prop); - // add the Datum to the list of entities for creating the path variable + /* add the Datum to the list of entities for creating the path variable */ if (CYPHER_TARGET_NODE_IN_PATH(node->flags)) { prev_path = lappend(prev_path, DatumGetPointer(result)); css->path_values = list_concat(prev_path, css->path_values); } - // Add the entity to the TupleTableSlot if necessary + /* Add the entity to the TupleTableSlot if necessary */ if (CYPHER_TARGET_NODE_IS_VARIABLE(node->flags)) { TupleTableSlot *scantuple = econtext->ecxt_scantuple; diff --git a/src/backend/executor/cypher_set.c b/src/backend/executor/cypher_set.c index 611b6792c..f8a04d24b 100644 --- a/src/backend/executor/cypher_set.c +++ b/src/backend/executor/cypher_set.c @@ -118,7 +118,7 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo, tuple = ExecFetchSlotHeapTuple(elemTupleSlot, true, NULL); tuple->t_self = old_tuple->t_self; - // Check the constraints of the tuple + /* Check the constraints of the tuple */ tuple->t_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc); if (resultRelInfo->ri_RelationDesc->rd_att->constr != NULL) { @@ -153,7 +153,7 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo, errmsg("Entity failed to be updated: %i", result))); } - // Insert index entries for the tuple + /* Insert index entries for the tuple */ if (resultRelInfo->ri_NumIndices > 0 && update_indexes != TU_None) { ExecInsertIndexTuples(resultRelInfo, elemTupleSlot, estate, false, false, NULL, NIL, @@ -252,21 +252,21 @@ static agtype_value *replace_entity_in_path(agtype_value *path, parsed_agtype_value = push_agtype_value(&parse_state, tok, tok < WAGT_BEGIN_ARRAY ? r : NULL); - // Iterate through the path, replace entities as necessary. + /* Iterate through the path, replace entities as necessary. */ for (i = 0; i < path->val.array.num_elems; i++) { agtype_value *id, *elem; elem = &path->val.array.elems[i]; - // something unexpected happened, throw an error. + /* something unexpected happened, throw an error. */ if (elem->type != AGTV_VERTEX && elem->type != AGTV_EDGE) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("unsupported agtype found in a path"))); } - // extract the id field + /* extract the id field */ id = GET_AGTYPE_VALUE_OBJECT_VALUE(elem, "id"); /* @@ -309,13 +309,13 @@ static void update_all_paths(CustomScanState *node, graphid id, agtype *original_entity; agtype_value *original_entity_value; - // skip nulls + /* skip nulls */ if (scanTupleSlot->tts_tupleDescriptor->attrs[i].atttypid != AGTYPEOID) { continue; } - // skip non agtype values + /* skip non agtype values */ if (scanTupleSlot->tts_isnull[i]) { continue; @@ -323,7 +323,7 @@ static void update_all_paths(CustomScanState *node, graphid id, original_entity = DATUM_GET_AGTYPE_P(scanTupleSlot->tts_values[i]); - // if the value is not a scalar type, its not a path + /* if the value is not a scalar type, its not a path */ if (!AGTYPE_CONTAINER_IS_SCALAR(&original_entity->root)) { continue; @@ -331,13 +331,13 @@ static void update_all_paths(CustomScanState *node, graphid id, original_entity_value = get_ith_agtype_value_from_container(&original_entity->root, 0); - // we found a path + /* we found a path */ if (original_entity_value->type == AGTV_PATH) { - // check if the path contains the entity. + /* check if the path contains the entity. */ if (check_path(original_entity_value, id)) { - // the path does contain the entity replace with the new entity. + /* the path does contain the entity replace with the new entity. */ agtype_value *new_path = replace_entity_in_path(original_entity_value, id, updated_entity); scanTupleSlot->tts_values[i] = AGTYPE_P_GET_DATUM(agtype_value_to_agtype(new_path)); @@ -471,7 +471,7 @@ static void process_update_list(CustomScanState *node) new_property_value = DATUM_GET_AGTYPE_P(scanTupleSlot->tts_values[update_item->prop_position - 1]); } - // Alter the properties Agtype value. + /* Alter the properties Agtype value. */ if (update_item->prop_name != NULL && strcmp(update_item->prop_name, "") != 0) { @@ -609,7 +609,7 @@ static TupleTableSlot *exec_cypher_set(CustomScanState *node) saved_resultRels = estate->es_result_relations; - //Process the subtree first + /* Process the subtree first */ Decrement_Estate_CommandId(estate); slot = ExecProcNode(node->ss.ps.lefttree); Increment_Estate_CommandId(estate); @@ -672,7 +672,7 @@ Node *create_cypher_set_plan_state(CustomScan *cscan) cypher_css->cs = cscan; - // get the serialized data structure from the Const and deserialize it. + /* get the serialized data structure from the Const and deserialize it. */ c = linitial(cscan->custom_private); serialized_data = (char *)c->constvalue; set_list = stringToNode(serialized_data); diff --git a/src/backend/executor/cypher_utils.c b/src/backend/executor/cypher_utils.c index e7a33f4f3..c8d568831 100644 --- a/src/backend/executor/cypher_utils.c +++ b/src/backend/executor/cypher_utils.c @@ -96,13 +96,13 @@ ResultRelInfo *create_entity_result_rel_info(EState *estate, char *graph_name, return resultRelInfo; } -// close the result_rel_info and close all the indices +/* close the result_rel_info and close all the indices */ void destroy_entity_result_rel_info(ResultRelInfo *result_rel_info) { - // close the indices + /* close the indices */ ExecCloseIndices(result_rel_info); - // close the rel + /* close the rel */ table_close(result_rel_info->ri_RelationDesc, RowExclusiveLock); } @@ -193,7 +193,7 @@ bool entity_exists(EState *estate, Oid graph_oid, graphid id) */ label = search_label_graph_oid_cache(graph_oid, GET_LABEL_ID(id)); - // Setup the scan key to be the graphid + /* Setup the scan key to be the graphid */ ScanKeyInit(&scan_keys[0], 1, BTEqualStrategyNumber, F_GRAPHIDEQ, GRAPHID_GET_DATUM(id)); @@ -255,11 +255,11 @@ HeapTuple insert_entity_tuple_cid(ResultRelInfo *resultRelInfo, ExecConstraints(resultRelInfo, elemTupleSlot, estate); } - // Insert the tuple normally + /* Insert the tuple normally */ table_tuple_insert(resultRelInfo->ri_RelationDesc, elemTupleSlot, cid, 0, NULL); - // Insert index entries for the tuple + /* Insert index entries for the tuple */ if (resultRelInfo->ri_NumIndices > 0) { ExecInsertIndexTuples(resultRelInfo, elemTupleSlot, estate, diff --git a/src/backend/nodes/ag_nodes.c b/src/backend/nodes/ag_nodes.c index 858ca5a51..e20670b2b 100644 --- a/src/backend/nodes/ag_nodes.c +++ b/src/backend/nodes/ag_nodes.c @@ -27,7 +27,7 @@ static bool equal_ag_node(const ExtensibleNode *a, const ExtensibleNode *b); -// This list must match ag_node_tag. +/* This list must match ag_node_tag. */ const char *node_names[] = { "ag_node_invalid", "cypher_return", @@ -96,7 +96,7 @@ const char *node_names[] = { CppConcat(read_, type) \ } -// This list must match ag_node_tag. +/* This list must match ag_node_tag. */ const ExtensibleNodeMethods node_methods[] = { DEFINE_NODE_METHODS(cypher_return), DEFINE_NODE_METHODS(cypher_with), diff --git a/src/backend/nodes/cypher_copyfuncs.c b/src/backend/nodes/cypher_copyfuncs.c index 9453bb52b..56895ee06 100644 --- a/src/backend/nodes/cypher_copyfuncs.c +++ b/src/backend/nodes/cypher_copyfuncs.c @@ -33,7 +33,7 @@ * named 'extended_newnode' and 'extended_from'. */ -// Declare the local fields needed to copy extensible nodes +/* Declare the local fields needed to copy extensible nodes */ #define COPY_LOCALS(nodeTypeName) \ nodeTypeName *extended_newnode = (nodeTypeName *)newnode; \ nodeTypeName *extended_from = (nodeTypeName *)from; \ @@ -41,19 +41,19 @@ Assert(is_ag_node(from, nodeTypeName)); -// Copy a simple scalar field (int, float, bool, enum, etc) +/* Copy a simple scalar field (int, float, bool, enum, etc) */ #define COPY_SCALAR_FIELD(fldname) \ (extended_newnode->fldname = extended_from->fldname) -// Copy a field that is a pointer to some kind of Node or Node tree +/* Copy a field that is a pointer to some kind of Node or Node tree */ #define COPY_NODE_FIELD(fldname) \ (extended_newnode->fldname = copyObject(extended_from->fldname)) -// Copy a field that is a pointer to a Bitmapset +/* Copy a field that is a pointer to a Bitmapset */ #define COPY_BITMAPSET_FIELD(fldname) \ (extended_newnode->fldname = bms_copy(extended_from->fldname)) -// Copy a field that is a pointer to a C string, or perhaps NULL +/* Copy a field that is a pointer to a C string, or perhaps NULL */ #define COPY_STRING_FIELD(fldname) \ (extended_newnode->fldname = extended_from->fldname ? \ pstrdup(extended_from->fldname) : (char *) NULL) @@ -68,7 +68,7 @@ void copy_ag_node(ExtensibleNode *newnode, ereport(ERROR, (errmsg("unexpected copyObject() over ag_node"))); } -// copy function for cypher_create_target_nodes +/* copy function for cypher_create_target_nodes */ void copy_cypher_create_target_nodes(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_create_target_nodes); @@ -79,7 +79,7 @@ void copy_cypher_create_target_nodes(ExtensibleNode *newnode, const ExtensibleNo COPY_NODE_FIELD(paths); } -// copy function for cypher_create_path +/* copy function for cypher_create_path */ void copy_cypher_create_path(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_create_path); @@ -89,7 +89,7 @@ void copy_cypher_create_path(ExtensibleNode *newnode, const ExtensibleNode *from COPY_NODE_FIELD(target_nodes); } -// copy function for cypher_target_node +/* copy function for cypher_target_node */ void copy_cypher_target_node(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_target_node); @@ -112,7 +112,7 @@ void copy_cypher_target_node(ExtensibleNode *newnode, const ExtensibleNode *from COPY_NODE_FIELD(elemTupleSlot); } -// copy function for cypher_update_information +/* copy function for cypher_update_information */ void copy_cypher_update_information(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_update_information); @@ -124,7 +124,7 @@ void copy_cypher_update_information(ExtensibleNode *newnode, const ExtensibleNod COPY_STRING_FIELD(clause_name); } -// copy function for cypher_update_item +/* copy function for cypher_update_item */ void copy_cypher_update_item(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_update_item); @@ -138,7 +138,7 @@ void copy_cypher_update_item(ExtensibleNode *newnode, const ExtensibleNode *from COPY_SCALAR_FIELD(is_add); } -// copy function for cypher_delete_information +/* copy function for cypher_delete_information */ void copy_cypher_delete_information(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_delete_information); @@ -150,7 +150,7 @@ void copy_cypher_delete_information(ExtensibleNode *newnode, const ExtensibleNod COPY_SCALAR_FIELD(detach); } -// copy function for cypher_delete_item +/* copy function for cypher_delete_item */ void copy_cypher_delete_item(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_delete_item); @@ -159,7 +159,7 @@ void copy_cypher_delete_item(ExtensibleNode *newnode, const ExtensibleNode *from COPY_STRING_FIELD(var_name); } -// copy function for cypher_merge_information +/* copy function for cypher_merge_information */ void copy_cypher_merge_information(ExtensibleNode *newnode, const ExtensibleNode *from) { COPY_LOCALS(cypher_merge_information); diff --git a/src/backend/nodes/cypher_outfuncs.c b/src/backend/nodes/cypher_outfuncs.c index 662d78475..ea3d3f98a 100644 --- a/src/backend/nodes/cypher_outfuncs.c +++ b/src/backend/nodes/cypher_outfuncs.c @@ -41,7 +41,7 @@ static void outChar(StringInfo str, char c); outToken(str, _node->field_name); \ } while (0) -// Write a char field (ie, one ascii character) +/* Write a char field (ie, one ascii character) */ #define WRITE_CHAR_FIELD(fldname) \ do { \ (appendStringInfo(str, " :" CppAsString(fldname) " "), \ @@ -55,7 +55,7 @@ static void outChar(StringInfo str, char c); _node->field_name ? "true" : "false"); \ } while (0) -// write an enumerated-type field as an integer code +/* write an enumerated-type field as an integer code */ #define WRITE_ENUM_FIELD(field_name, enum_type) \ do \ { \ @@ -77,14 +77,14 @@ static void outChar(StringInfo str, char c); _node->field_name); \ } while (0) -// Write an integer field (anything written as ":fldname %d") +/* Write an integer field (anything written as ":fldname %d") */ #define WRITE_INT32_FIELD(field_name) \ do { \ appendStringInfo(str, " :" CppAsString(field_name) " %d", \ _node->field_name); \ } while (0) -// Write an OID field (don't hard-wire assumption that OID is same as uint) +/* Write an OID field (don't hard-wire assumption that OID is same as uint) */ #define WRITE_OID_FIELD(fldname) \ do { \ appendStringInfo(str, " :" CppAsString(fldname) " %u", \ @@ -93,7 +93,7 @@ static void outChar(StringInfo str, char c); -// serialization function for the cypher_return ExtensibleNode. +/* serialization function for the cypher_return ExtensibleNode. */ void out_cypher_return(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_return); @@ -110,7 +110,7 @@ void out_cypher_return(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(rarg); } -// serialization function for the cypher_with ExtensibleNode. +/* serialization function for the cypher_with ExtensibleNode. */ void out_cypher_with(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_with); @@ -124,7 +124,7 @@ void out_cypher_with(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(where); } -// serialization function for the cypher_match ExtensibleNode. +/* serialization function for the cypher_match ExtensibleNode. */ void out_cypher_match(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_match); @@ -134,7 +134,7 @@ void out_cypher_match(StringInfo str, const ExtensibleNode *node) WRITE_BOOL_FIELD(optional); } -// serialization function for the cypher_create ExtensibleNode. +/* serialization function for the cypher_create ExtensibleNode. */ void out_cypher_create(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_create); @@ -142,7 +142,7 @@ void out_cypher_create(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(pattern); } -// serialization function for the cypher_set ExtensibleNode. +/* serialization function for the cypher_set ExtensibleNode. */ void out_cypher_set(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_set); @@ -151,7 +151,7 @@ void out_cypher_set(StringInfo str, const ExtensibleNode *node) WRITE_BOOL_FIELD(is_remove); } -// serialization function for the cypher_set_item ExtensibleNode. +/* serialization function for the cypher_set_item ExtensibleNode. */ void out_cypher_set_item(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_set_item); @@ -161,7 +161,7 @@ void out_cypher_set_item(StringInfo str, const ExtensibleNode *node) WRITE_BOOL_FIELD(is_add); } -// serialization function for the cypher_delete ExtensibleNode. +/* serialization function for the cypher_delete ExtensibleNode. */ void out_cypher_delete(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_delete); @@ -178,7 +178,7 @@ void out_cypher_unwind(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(collect); } -// serialization function for the cypher_delete ExtensibleNode. +/* serialization function for the cypher_delete ExtensibleNode. */ void out_cypher_merge(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_merge); @@ -186,7 +186,7 @@ void out_cypher_merge(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(path); } -// serialization function for the cypher_path ExtensibleNode. +/* serialization function for the cypher_path ExtensibleNode. */ void out_cypher_path(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_path); @@ -197,7 +197,7 @@ void out_cypher_path(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_node ExtensibleNode. +/* serialization function for the cypher_node ExtensibleNode. */ void out_cypher_node(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_node); @@ -210,7 +210,7 @@ void out_cypher_node(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_relationship ExtensibleNode. +/* serialization function for the cypher_relationship ExtensibleNode. */ void out_cypher_relationship(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_relationship); @@ -225,7 +225,7 @@ void out_cypher_relationship(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_bool_const ExtensibleNode. +/* serialization function for the cypher_bool_const ExtensibleNode. */ void out_cypher_bool_const(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_bool_const); @@ -234,7 +234,7 @@ void out_cypher_bool_const(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_param ExtensibleNode. +/* serialization function for the cypher_param ExtensibleNode. */ void out_cypher_param(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_param); @@ -243,7 +243,7 @@ void out_cypher_param(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_map ExtensibleNode. +/* serialization function for the cypher_map ExtensibleNode. */ void out_cypher_map(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_map); @@ -261,7 +261,7 @@ void out_cypher_map_projection(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_list ExtensibleNode. +/* serialization function for the cypher_list ExtensibleNode. */ void out_cypher_list(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_list); @@ -270,7 +270,7 @@ void out_cypher_list(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_comparison_aexpr ExtensibleNode. +/* serialization function for the cypher_comparison_aexpr ExtensibleNode. */ void out_cypher_comparison_aexpr(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_comparison_aexpr); @@ -282,7 +282,7 @@ void out_cypher_comparison_aexpr(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_comparison_boolexpr ExtensibleNode. +/* serialization function for the cypher_comparison_boolexpr ExtensibleNode. */ void out_cypher_comparison_boolexpr(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_comparison_boolexpr); @@ -292,7 +292,7 @@ void out_cypher_comparison_boolexpr(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_string_match ExtensibleNode. +/* serialization function for the cypher_string_match ExtensibleNode. */ void out_cypher_string_match(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_string_match); @@ -303,7 +303,7 @@ void out_cypher_string_match(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_typecast ExtensibleNode. +/* serialization function for the cypher_typecast ExtensibleNode. */ void out_cypher_typecast(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_typecast); @@ -313,7 +313,7 @@ void out_cypher_typecast(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_integer_const ExtensibleNode. +/* serialization function for the cypher_integer_const ExtensibleNode. */ void out_cypher_integer_const(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_integer_const); @@ -322,7 +322,7 @@ void out_cypher_integer_const(StringInfo str, const ExtensibleNode *node) WRITE_LOCATION_FIELD(location); } -// serialization function for the cypher_sub_pattern ExtensibleNode. +/* serialization function for the cypher_sub_pattern ExtensibleNode. */ void out_cypher_sub_pattern(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_sub_pattern); @@ -331,7 +331,7 @@ void out_cypher_sub_pattern(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(pattern); } -// serialization function for the cypher_sub_pattern ExtensibleNode. +/* serialization function for the cypher_sub_pattern ExtensibleNode. */ void out_cypher_sub_query(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_sub_query); @@ -340,7 +340,7 @@ void out_cypher_sub_query(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(query); } -// serialization function for the cypher_call ExtensibleNode. +/* serialization function for the cypher_call ExtensibleNode. */ void out_cypher_call(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_call); @@ -351,7 +351,7 @@ void out_cypher_call(StringInfo str, const ExtensibleNode *node) WRITE_NODE_FIELD(yield_items); } -// serialization function for the cypher_create_target_nodes ExtensibleNode. +/* serialization function for the cypher_create_target_nodes ExtensibleNode. */ void out_cypher_create_target_nodes(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_create_target_nodes); @@ -361,7 +361,7 @@ void out_cypher_create_target_nodes(StringInfo str, const ExtensibleNode *node) WRITE_INT32_FIELD(graph_oid); } -// serialization function for the cypher_create_path ExtensibleNode. +/* serialization function for the cypher_create_path ExtensibleNode. */ void out_cypher_create_path(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_create_path); @@ -371,7 +371,7 @@ void out_cypher_create_path(StringInfo str, const ExtensibleNode *node) WRITE_STRING_FIELD(var_name); } -// serialization function for the cypher_target_node ExtensibleNode. +/* serialization function for the cypher_target_node ExtensibleNode. */ void out_cypher_target_node(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_target_node); @@ -392,7 +392,7 @@ void out_cypher_target_node(StringInfo str, const ExtensibleNode *node) WRITE_INT32_FIELD(tuple_position); } -// serialization function for the cypher_update_information ExtensibleNode. +/* serialization function for the cypher_update_information ExtensibleNode. */ void out_cypher_update_information(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_update_information); @@ -404,7 +404,7 @@ void out_cypher_update_information(StringInfo str, const ExtensibleNode *node) WRITE_STRING_FIELD(clause_name); } -// serialization function for the cypher_update_item ExtensibleNode. +/* serialization function for the cypher_update_item ExtensibleNode. */ void out_cypher_update_item(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_update_item); @@ -418,7 +418,7 @@ void out_cypher_update_item(StringInfo str, const ExtensibleNode *node) WRITE_BOOL_FIELD(is_add); } -// serialization function for the cypher_delete_information ExtensibleNode. +/* serialization function for the cypher_delete_information ExtensibleNode. */ void out_cypher_delete_information(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_delete_information); @@ -430,7 +430,7 @@ void out_cypher_delete_information(StringInfo str, const ExtensibleNode *node) WRITE_BOOL_FIELD(detach); } -// serialization function for the cypher_delete_item ExtensibleNode. +/* serialization function for the cypher_delete_item ExtensibleNode. */ void out_cypher_delete_item(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_delete_item); @@ -439,7 +439,7 @@ void out_cypher_delete_item(StringInfo str, const ExtensibleNode *node) WRITE_STRING_FIELD(var_name); } -// serialization function for the cypher_merge_information ExtensibleNode. +/* serialization function for the cypher_merge_information ExtensibleNode. */ void out_cypher_merge_information(StringInfo str, const ExtensibleNode *node) { DEFINE_AG_NODE(cypher_merge_information); diff --git a/src/backend/nodes/cypher_readfuncs.c b/src/backend/nodes/cypher_readfuncs.c index 0587229f6..a58b90cbc 100644 --- a/src/backend/nodes/cypher_readfuncs.c +++ b/src/backend/nodes/cypher_readfuncs.c @@ -54,101 +54,101 @@ static char *nullable_string(const char *token, int length); * correctly. */ -// Read an integer field (anything written as ":fldname %d") +/* Read an integer field (anything written as ":fldname %d") */ #define READ_INT_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = strtol(token, 0, 10) -// Read an unsigned integer field (anything written as ":fldname %u") +/* Read an unsigned integer field (anything written as ":fldname %u") */ #define READ_UINT_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = atoui(token) -// Read an unsigned integer field (anything written using UINT64_FORMAT) +/* Read an unsigned integer field (anything written using UINT64_FORMAT) */ #define READ_UINT64_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = pg_strtouint64(token, NULL, 10) -// Read a long integer field (anything written as ":fldname %ld") +/* Read a long integer field (anything written as ":fldname %ld") */ #define READ_LONG_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = atol(token) -// Read an OID field (don't hard-wire assumption that OID is same as uint) +/* Read an OID field (don't hard-wire assumption that OID is same as uint) */ #define READ_OID_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = atooid(token) -// Read a char field (ie, one ascii character) +/* Read a char field (ie, one ascii character) */ #define READ_CHAR_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ /* avoid overhead of calling debackslash() for one char */ \ local_node->fldname = (length == 0) ? '\0' : (token[0] == '\\' ? token[1] : token[0]) -// Read an enumerated-type field that was written as an integer code +/* Read an enumerated-type field that was written as an integer code */ #define READ_ENUM_FIELD(fldname, enumtype) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = (enumtype) strtol(token, 0, 10) -// Read a float field +/* Read a float field */ #define READ_FLOAT_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = atof(token) -// Read a boolean field +/* Read a boolean field */ #define READ_BOOL_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = strtobool(token) -// Read a character-string field +/* Read a character-string field */ #define READ_STRING_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ local_node->fldname = nullable_string(token, length) -// Read a parse location field (and throw away the value, per notes above) +/* Read a parse location field (and throw away the value, per notes above) */ #define READ_LOCATION_FIELD(fldname) \ token = pg_strtok(&length); \ token = pg_strtok(&length); \ (void) token; \ local_node->fldname = -1 -// Read a Node field +/* Read a Node field */ #define READ_NODE_FIELD(fldname) \ token = pg_strtok(&length); \ (void) token; \ local_node->fldname = nodeRead(NULL, 0) -// Read a bitmapset field +/* Read a bitmapset field */ #define READ_BITMAPSET_FIELD(fldname) \ token = pg_strtok(&length); \ (void) token; \ local_node->fldname = _readBitmapset() -// Read an attribute number array +/* Read an attribute number array */ #define READ_ATTRNUMBER_ARRAY(fldname, len) \ token = pg_strtok(&length); \ local_node->fldname = readAttrNumberCols(len); -// Read an oid array +/* Read an oid array */ #define READ_OID_ARRAY(fldname, len) \ token = pg_strtok(&length); \ local_node->fldname = readOidCols(len); -// Read an int array +/* Read an int array */ #define READ_INT_ARRAY(fldname, len) \ token = pg_strtok(&length); \ local_node->fldname = readIntCols(len); -// Read a bool array +/* Read a bool array */ #define READ_BOOL_ARRAY(fldname, len) \ token = pg_strtok(&length); \ local_node->fldname = readBoolCols(len); diff --git a/src/backend/optimizer/cypher_createplan.c b/src/backend/optimizer/cypher_createplan.c index fdbcb10b7..288da05d7 100644 --- a/src/backend/optimizer/cypher_createplan.c +++ b/src/backend/optimizer/cypher_createplan.c @@ -49,7 +49,8 @@ Plan *plan_cypher_create_path(PlannerInfo *root, RelOptInfo *rel, cs->scan.plan.parallel_aware = best_path->path.parallel_aware; cs->scan.plan.parallel_safe = best_path->path.parallel_safe; - cs->scan.plan.plan_node_id = 0; // Set later in set_plan_refs + /* Set later in set_plan_refs */ + cs->scan.plan.plan_node_id = 0; cs->scan.plan.targetlist = tlist; cs->scan.plan.qual = NIL; cs->scan.plan.lefttree = NULL; @@ -91,7 +92,7 @@ Plan *plan_cypher_set_path(PlannerInfo *root, RelOptInfo *rel, cs->scan.plan.parallel_aware = best_path->path.parallel_aware; cs->scan.plan.parallel_safe = best_path->path.parallel_safe; - cs->scan.plan.plan_node_id = 0; // Set later in set_plan_refs + cs->scan.plan.plan_node_id = 0; /* Set later in set_plan_refs */ cs->scan.plan.targetlist = tlist; cs->scan.plan.qual = NIL; cs->scan.plan.lefttree = NULL; @@ -138,7 +139,7 @@ Plan *plan_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel, cs->scan.plan.parallel_aware = best_path->path.parallel_aware; cs->scan.plan.parallel_safe = best_path->path.parallel_safe; - cs->scan.plan.plan_node_id = 0; // Set later in set_plan_refs + cs->scan.plan.plan_node_id = 0; /* Set later in set_plan_refs */ /* * the scan list of the delete node, used for its ScanTupleSlot used * by its parent in the execution phase. @@ -160,10 +161,10 @@ Plan *plan_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel, cs->flags = best_path->flags; - // child plan nodes are here, Postgres processed them for us. + /* child plan nodes are here, Postgres processed them for us. */ cs->custom_plans = custom_plans; cs->custom_exprs = NIL; - // transfer delete metadata needed by the DELETE clause. + /* transfer delete metadata needed by the DELETE clause. */ cs->custom_private = best_path->custom_private; /* * the scan list of the delete node's children, used for ScanTupleSlot @@ -199,7 +200,7 @@ Plan *plan_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel, cs->scan.plan.parallel_aware = best_path->path.parallel_aware; cs->scan.plan.parallel_safe = best_path->path.parallel_safe; - cs->scan.plan.plan_node_id = 0; // Set later in set_plan_refs + cs->scan.plan.plan_node_id = 0; /* Set later in set_plan_refs */ /* * the scan list of the merge node, used for its ScanTupleSlot used * by its parent in the execution phase. @@ -221,10 +222,10 @@ Plan *plan_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel, cs->flags = best_path->flags; - // child plan nodes are here, Postgres processed them for us. + /* child plan nodes are here, Postgres processed them for us. */ cs->custom_plans = custom_plans; cs->custom_exprs = NIL; - // transfer delete metadata needed by the MERGE clause. + /* transfer delete metadata needed by the MERGE clause. */ cs->custom_private = best_path->custom_private; /* * the scan list of the merge node's children, used for ScanTupleSlot diff --git a/src/backend/optimizer/cypher_pathnode.c b/src/backend/optimizer/cypher_pathnode.c index 60ce53664..a08cd30e4 100644 --- a/src/backend/optimizer/cypher_pathnode.c +++ b/src/backend/optimizer/cypher_pathnode.c @@ -47,19 +47,19 @@ CustomPath *create_cypher_create_path(PlannerInfo *root, RelOptInfo *rel, cp->path.param_info = NULL; - // Do not allow parallel methods + /* Do not allow parallel methods */ cp->path.parallel_aware = false; cp->path.parallel_safe = false; cp->path.parallel_workers = 0; - cp->path.rows = 0; // Basic CREATE will not return rows - cp->path.startup_cost = 0; // Basic CREATE will not fetch any pages + cp->path.rows = 0; /* Basic CREATE will not return rows */ + cp->path.startup_cost = 0; /* Basic CREATE will not fetch any pages */ cp->path.total_cost = 0; - // No output ordering for basic CREATE + /* No output ordering for basic CREATE */ cp->path.pathkeys = NULL; - // Disable all custom flags for now + /* Disable all custom flags for now */ cp->flags = 0; cp->custom_paths = rel->pathlist; @@ -83,19 +83,19 @@ CustomPath *create_cypher_set_path(PlannerInfo *root, RelOptInfo *rel, cp->path.param_info = NULL; - // Do not allow parallel methods + /* Do not allow parallel methods */ cp->path.parallel_aware = false; cp->path.parallel_safe = false; cp->path.parallel_workers = 0; - cp->path.rows = 0; // Basic SET will not return rows - cp->path.startup_cost = 0; // Basic SET will not fetch any pages + cp->path.rows = 0; /* Basic SET will not return rows */ + cp->path.startup_cost = 0; /* Basic SET will not fetch any pages */ cp->path.total_cost = 0; - // No output ordering for basic SET + /* No output ordering for basic SET */ cp->path.pathkeys = NULL; - // Disable all custom flags for now + /* Disable all custom flags for now */ cp->flags = 0; cp->custom_paths = rel->pathlist; @@ -123,7 +123,7 @@ CustomPath *create_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel, cp->path.param_info = NULL; - // Do not allow parallel methods + /* Do not allow parallel methods */ cp->path.parallel_aware = false; cp->path.parallel_safe = false; cp->path.parallel_workers = 0; @@ -132,17 +132,17 @@ CustomPath *create_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel, cp->path.startup_cost = 0; cp->path.total_cost = 0; - // No output ordering for basic SET + /* No output ordering for basic SET */ cp->path.pathkeys = NULL; - // Disable all custom flags for now + /* Disable all custom flags for now */ cp->flags = 0; - // Make the original paths the children of the new path + /* Make the original paths the children of the new path */ cp->custom_paths = rel->pathlist; - // Store the metadata Delete will need in the execution phase. + /* Store the metadata Delete will need in the execution phase. */ cp->custom_private = custom_private; - // Tells Postgres how to turn this path to the correct CustomScan + /* Tells Postgres how to turn this path to the correct CustomScan */ cp->methods = &cypher_delete_path_methods; return cp; @@ -166,7 +166,7 @@ CustomPath *create_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel, cp->path.param_info = NULL; - // Do not allow parallel methods + /* Do not allow parallel methods */ cp->path.parallel_aware = false; cp->path.parallel_safe = false; cp->path.parallel_workers = 0; @@ -175,17 +175,17 @@ CustomPath *create_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel, cp->path.startup_cost = 0; cp->path.total_cost = 0; - // No output ordering for basic SET + /* No output ordering for basic SET */ cp->path.pathkeys = NULL; - // Disable all custom flags for now + /* Disable all custom flags for now */ cp->flags = 0; - // Make the original paths the children of the new path + /* Make the original paths the children of the new path */ cp->custom_paths = rel->pathlist; - // Store the metadata Delete will need in the execution phase. + /* Store the metadata Delete will need in the execution phase. */ cp->custom_private = custom_private; - // Tells Postgres how to turn this path to the correct CustomScan + /* Tells Postgres how to turn this path to the correct CustomScan */ cp->methods = &cypher_merge_path_methods; return cp; diff --git a/src/backend/optimizer/cypher_paths.c b/src/backend/optimizer/cypher_paths.c index 519501ba0..6c4fd7e07 100644 --- a/src/backend/optimizer/cypher_paths.c +++ b/src/backend/optimizer/cypher_paths.c @@ -97,18 +97,18 @@ static cypher_clause_kind get_cypher_clause_kind(RangeTblEntry *rte) TargetEntry *te; FuncExpr *fe; - // If it's not a subquery, it's not a Cypher clause. + /* If it's not a subquery, it's not a Cypher clause. */ if (rte->rtekind != RTE_SUBQUERY) return CYPHER_CLAUSE_NONE; - // Make sure the targetList isn't NULL. NULL means potential EXIST subclause + /* Make sure the targetList isn't NULL. NULL means potential EXIST subclause */ if (rte->subquery->targetList == NULL) return CYPHER_CLAUSE_NONE; - // A Cypher clause function is always the last entry. + /* A Cypher clause function is always the last entry. */ te = llast(rte->subquery->targetList); - // If the last entry is not a FuncExpr, it's not a Cypher clause. + /* If the last entry is not a FuncExpr, it's not a Cypher clause. */ if (!IsA(te->expr, FuncExpr)) return CYPHER_CLAUSE_NONE; @@ -126,7 +126,7 @@ static cypher_clause_kind get_cypher_clause_kind(RangeTblEntry *rte) return CYPHER_CLAUSE_NONE; } -// replace all possible paths with our CustomPath +/* replace all possible paths with our CustomPath */ static void handle_cypher_delete_clause(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte) { @@ -135,15 +135,15 @@ static void handle_cypher_delete_clause(PlannerInfo *root, RelOptInfo *rel, List *custom_private; CustomPath *cp; - // Add the pattern to the CustomPath + /* Add the pattern to the CustomPath */ te = (TargetEntry *)llast(rte->subquery->targetList); fe = (FuncExpr *)te->expr; - // pass the const that holds the data structure to the path. + /* pass the const that holds the data structure to the path. */ custom_private = fe->args; cp = create_cypher_delete_path(root, rel, custom_private); - // Discard any preexisting paths + /* Discard any preexisting paths */ rel->pathlist = NIL; rel->partial_pathlist = NIL; @@ -163,23 +163,23 @@ static void handle_cypher_create_clause(PlannerInfo *root, RelOptInfo *rel, List *custom_private; CustomPath *cp; - // Add the pattern to the CustomPath + /* Add the pattern to the CustomPath */ te = (TargetEntry *)llast(rte->subquery->targetList); fe = (FuncExpr *)te->expr; - // pass the const that holds the data structure to the path. + /* pass the const that holds the data structure to the path. */ custom_private = fe->args; cp = create_cypher_create_path(root, rel, custom_private); - // Discard any preexisting paths, they should be under the cp path + /* Discard any preexisting paths, they should be under the cp path */ rel->pathlist = NIL; rel->partial_pathlist = NIL; - // Add the new path to the rel. + /* Add the new path to the rel. */ add_path(rel, (Path *)cp); } -// replace all possible paths with our CustomPath +/* replace all possible paths with our CustomPath */ static void handle_cypher_set_clause(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte) { @@ -188,22 +188,22 @@ static void handle_cypher_set_clause(PlannerInfo *root, RelOptInfo *rel, List *custom_private; CustomPath *cp; - // Add the pattern to the CustomPath + /* Add the pattern to the CustomPath */ te = (TargetEntry *)llast(rte->subquery->targetList); fe = (FuncExpr *)te->expr; - // pass the const that holds the data structure to the path. + /* pass the const that holds the data structure to the path. */ custom_private = fe->args; cp = create_cypher_set_path(root, rel, custom_private); - // Discard any preexisting paths + /* Discard any preexisting paths */ rel->pathlist = NIL; rel->partial_pathlist = NIL; add_path(rel, (Path *)cp); } -// replace all possible paths with our CustomPath +/* replace all possible paths with our CustomPath */ static void handle_cypher_merge_clause(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte) { @@ -212,15 +212,15 @@ static void handle_cypher_merge_clause(PlannerInfo *root, RelOptInfo *rel, List *custom_private; CustomPath *cp; - // Add the pattern to the CustomPath + /* Add the pattern to the CustomPath */ te = (TargetEntry *)llast(rte->subquery->targetList); fe = (FuncExpr *)te->expr; - // pass the const that holds the data structure to the path. + /* pass the const that holds the data structure to the path. */ custom_private = fe->args; cp = create_cypher_merge_path(root, rel, custom_private); - // Discard any preexisting paths + /* Discard any preexisting paths */ rel->pathlist = NIL; rel->partial_pathlist = NIL; diff --git a/src/backend/parser/ag_scanner.l b/src/backend/parser/ag_scanner.l index a71d17c6c..256e662dc 100644 --- a/src/backend/parser/ag_scanner.l +++ b/src/backend/parser/ag_scanner.l @@ -271,11 +271,11 @@ typedef struct ag_yy_extra */ strbuf literal_buf; - // for Unicode surrogate pair + /* for Unicode surrogate pair */ pg_wchar high_surrogate; int start_cond; - // for the location of the current token and the actual position of it + /* for the location of the current token and the actual position of it */ const char *scan_buf; int last_loc; } ag_yy_extra; @@ -326,22 +326,22 @@ static int _scan_errposition(const int location, const ag_yy_extra *extra); %% %{ -// This is used in the actions below. +/* This is used in the actions below. */ ag_token token; %} {whitespace} { - // ignore + /* ignore */ } {mlcstart} { - // update location in case of unterminated comment + /* update location in case of unterminated comment */ update_location(); BEGIN(mlcomment); } {mlcchars} { - // ignore + /* ignore */ } {mlcstop} { @@ -355,7 +355,7 @@ ag_token token; } {slcomment} { - // ignore + /* ignore */ } {digitseq} | @@ -383,12 +383,12 @@ ag_token token; } {decimalfail} { - // return dot_dot back to the input stream + /* return dot_dot back to the input stream */ yyless(yyleng - 2); update_location(); - // consume digitseq + /* consume digitseq */ integer_literal_to_token(yytext, &token, &yyextra); token.location = get_location(); return token; @@ -440,7 +440,7 @@ ag_token token; c = '\t'; break; default: - // '"', '\'', '/', and '\\' + /* '"', '\'', '/', and '\\' */ c = yytext[1]; break; } @@ -471,11 +471,11 @@ ag_token token; {esunicode} { pg_wchar c; - // It is unnecessary to check endptr and errno here. + /* It is unnecessary to check endptr and errno here. */ c = strtoul(yytext + 2, NULL, 16); if (c > 0x10FFFF) { - // c is greater than the maximum value of a Unicode code point. + /* c is greater than the maximum value of a Unicode code point. */ update_location(); ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), @@ -517,7 +517,7 @@ ag_token token; } else if (c > 0) { - // c is an ASCII character. + /* c is an ASCII character. */ strbuf_append_char(&yyextra.literal_buf, (char)c); } else @@ -542,7 +542,7 @@ ag_token token; if (is_low_surrogate(c)) { c = surrogate_pair_to_codepoint(yyextra.high_surrogate, c); - // 0x010000 <= c <= 0x10FFFF always holds for surrogate pairs. + /* 0x010000 <= c <= 0x10FFFF always holds for surrogate pairs. */ strbuf_append_codepoint(&yyextra.literal_buf, c); BEGIN(yyextra.start_cond); } @@ -789,7 +789,7 @@ void *ag_yyalloc(yy_size_t size, yyscan_t yyscanner) void *ag_yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner) { - // see realloc(3) + /* see realloc(3) */ if (ptr) { if (size == 0) @@ -855,7 +855,7 @@ static void strbuf_append_codepoint(strbuf *sb, const pg_wchar c) */ static void strbuf_ensure_capacity(strbuf *sb, int len) { - // consider additional 1 byte for the last '\0' character + /* consider additional 1 byte for the last '\0' character */ if (len < sb->capacity) return; @@ -898,7 +898,7 @@ static void integer_literal_to_token(const char *s, ag_token *token, _scan_errposition(extra->last_loc, extra))); } - // Treat it as a decimal if it is too large to be an "int" value. + /* Treat it as a decimal if it is too large to be an "int" value. */ if (errno == ERANGE) { /* @@ -939,7 +939,7 @@ static void integer_literal_to_token(const char *s, ag_token *token, */ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) { - // constants for each base + /* constants for each base */ int ndigits_per_word; int nbits_per_digit; uint32 (*digit_value)(const char); @@ -967,7 +967,7 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) int nremainders; int i; - // set constants for each base + /* set constants for each base */ switch (base) { case 16: @@ -1019,27 +1019,27 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) return; } - // skip leading zeros + /* skip leading zeros */ while (*numstr == '0') numstr++; - // number of digits in "numstr" + /* number of digits in "numstr" */ ndigits = strlen(numstr); Assert(ndigits > 0); - // prepare "words" to store "numstr" in two's complement representation + /* prepare "words" to store "numstr" in two's complement representation */ nwords = (ndigits + (ndigits_per_word - 1)) / ndigits_per_word; words = palloc(sizeof(*words) * nwords); digitp = numstr; word_i = 0; - // number of digits for the first word + /* number of digits for the first word */ ndigits_word0 = ndigits % ndigits_per_word; if (ndigits_word0 == 0) ndigits_word0 = ndigits_per_word; - // fill the first word + /* fill the first word */ word = digit_value(*digitp++); for (i = 1; i < ndigits_word0; i++) { @@ -1048,7 +1048,7 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) } words[word_i++] = word; - // fill the rest of "words" + /* fill the rest of "words" */ while (word_i < nwords) { word = digit_value(*digitp++); @@ -1060,18 +1060,18 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) words[word_i++] = word; } - // At most "ndivisions" divisions are needed to eliminate 1 word. + /* At most "ndivisions" divisions are needed to eliminate 1 word. */ remainders = palloc(sizeof(*remainders) * (ndivisions * nwords)); nremainders = 0; word_i = 0; - // repeat dividing "words" by "divisor" until the quotient becomes 0 + /* repeat dividing "words" by "divisor" until the quotient becomes 0 */ while (word_i < nwords) { uint64 r; r = 0; - // divide "words" by "divisor" + /* divide "words" by "divisor" */ for (i = word_i; i < nwords; i++) { uint64 d; @@ -1086,7 +1086,7 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) words[i] = (uint32)q; } - // collect the remainder to build the result + /* collect the remainder to build the result */ remainders[nremainders++] = (uint32)r; /* @@ -1097,7 +1097,7 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) word_i++; } - // convert the collected remainders to a string, starting from the last one + /* convert the collected remainders to a string, starting from the last one */ for (i = nremainders - 1; i >= 0; i--) { char buf[NDIGITS_PER_REMAINDER]; @@ -1109,7 +1109,7 @@ static void _numstr_to_decimal(const char *numstr, const int base, strbuf *sb) for (tmp = remainders[i]; tmp > 0; tmp /= 10) buf[--buf_i] = '0' + (char)(tmp % 10); - // leading zeros for intermediate digits + /* leading zeros for intermediate digits */ if (i < nremainders - 1) { while (buf_i > 0) @@ -1165,11 +1165,11 @@ static int _scan_errposition(const int location, const ag_yy_extra *extra) { int pos; - // no-op if location is unknown + /* no-op if location is unknown */ if (location < 0) return 0; - // convert byte offset to number of characters + /* convert byte offset to number of characters */ pos = pg_mbstrlen_with_len(extra->scan_buf, location) + 1; return errposition(pos); @@ -1183,7 +1183,7 @@ ag_scanner_t ag_scanner_create(const char *s) ag_yy_extra extra; int ret; - // The last two YY_END_OF_BUFFER_CHAR are required by flex. + /* The last two YY_END_OF_BUFFER_CHAR are required by flex. */ len = strlen(s); buf = palloc(len + 2); memcpy(buf, s, len); diff --git a/src/backend/parser/cypher_analyze.c b/src/backend/parser/cypher_analyze.c index 4a853886b..f0f60f638 100644 --- a/src/backend/parser/cypher_analyze.c +++ b/src/backend/parser/cypher_analyze.c @@ -118,7 +118,7 @@ static void post_parse_analyze(ParseState *pstate, Query *query, JumbleState *js } } -// find cypher() calls in FROM clauses and convert them to SELECT subqueries +/* find cypher() calls in FROM clauses and convert them to SELECT subqueries */ static bool convert_cypher_walker(Node *node, ParseState *pstate) { if (!node) @@ -131,7 +131,7 @@ static bool convert_cypher_walker(Node *node, ParseState *pstate) switch (rte->rtekind) { case RTE_SUBQUERY: - // traverse other RTE_SUBQUERYs + /* traverse other RTE_SUBQUERYs */ return convert_cypher_walker((Node *)rte->subquery, pstate); case RTE_FUNCTION: if (is_rte_cypher(rte)) @@ -361,7 +361,7 @@ static bool is_func_cypher(FuncExpr *funcexpr) return is_oid_ag_func(funcexpr->funcid, "cypher"); } -// convert cypher() call to SELECT subquery in-place +/* convert cypher() call to SELECT subquery in-place */ static void convert_cypher_to_subquery(RangeTblEntry *rte, ParseState *pstate) { RangeTblFunction *rtfunc = linitial(rte->functions); @@ -591,8 +591,8 @@ static void convert_cypher_to_subquery(RangeTblEntry *rte, ParseState *pstate) Assert(pstate->p_expr_kind == EXPR_KIND_NONE); pstate->p_expr_kind = EXPR_KIND_FROM_SUBSELECT; - // transformRangeFunction() always sets p_lateral_active to true. - // FYI, rte is RTE_FUNCTION and is being converted to RTE_SUBQUERY here. + /* transformRangeFunction() always sets p_lateral_active to true. */ + /* FYI, rte is RTE_FUNCTION and is being converted to RTE_SUBQUERY here. */ pstate->p_lateral_active = true; /* @@ -603,7 +603,7 @@ static void convert_cypher_to_subquery(RangeTblEntry *rte, ParseState *pstate) if (is_ag_node(llast(stmt), cypher_create) || is_ag_node(llast(stmt), cypher_set) || is_ag_node(llast(stmt), cypher_delete) || is_ag_node(llast(stmt), cypher_merge)) { - // column definition list must be ... AS relname(colname agtype) ... + /* column definition list must be ... AS relname(colname agtype) ... */ if (!(rtfunc->funccolcount == 1 && linitial_oid(rtfunc->funccoltypes) == AGTYPEOID)) { @@ -627,10 +627,10 @@ static void convert_cypher_to_subquery(RangeTblEntry *rte, ParseState *pstate) pstate->p_lateral_active = false; pstate->p_expr_kind = EXPR_KIND_NONE; - // rte->functions and rte->funcordinality are kept for debugging. - // rte->alias, rte->eref, and rte->lateral need to be the same. - // rte->inh is always false for both RTE_FUNCTION and RTE_SUBQUERY. - // rte->inFromCl is always true for RTE_FUNCTION. + /* rte->functions and rte->funcordinality are kept for debugging. */ + /* rte->alias, rte->eref, and rte->lateral need to be the same. */ + /* rte->inh is always false for both RTE_FUNCTION and RTE_SUBQUERY. */ + /* rte->inFromCl is always true for RTE_FUNCTION. */ rte->rtekind = RTE_SUBQUERY; rte->subquery = query; } @@ -1193,7 +1193,7 @@ static Query *analyze_cypher_and_coerce(List *stmt, RangeTblFunction *rtfunc, pstate->p_lateral_active = false; pstate->p_expr_kind = EXPR_KIND_NONE; - // ALIAS Syntax makes `RESJUNK`. So, It must be skipping. + /* ALIAS Syntax makes `RESJUNK`. So, It must be skipping. */ foreach(lt, subquery->targetList) { TargetEntry *te = lfirst(lt); @@ -1203,7 +1203,7 @@ static Query *analyze_cypher_and_coerce(List *stmt, RangeTblFunction *rtfunc, } } - // check the number of attributes first + /* check the number of attributes first */ if (attr_count != rtfunc->funccolcount) { ereport(ERROR, @@ -1216,7 +1216,7 @@ static Query *analyze_cypher_and_coerce(List *stmt, RangeTblFunction *rtfunc, lateral, true); rtindex = list_length(pstate->p_rtable); - // rte is the only RangeTblEntry in pstate + /* rte is the only RangeTblEntry in pstate */ if (rtindex !=1 ) { ereport(ERROR, @@ -1230,7 +1230,7 @@ static Query *analyze_cypher_and_coerce(List *stmt, RangeTblFunction *rtfunc, markTargetListOrigins(pstate, query->targetList); - // do the type coercion for each target entry + /* do the type coercion for each target entry */ lc1 = list_head(rtfunc->funccolnames); lc2 = list_head(rtfunc->funccoltypes); lc3 = list_head(rtfunc->funccoltypmods); diff --git a/src/backend/parser/cypher_clause.c b/src/backend/parser/cypher_clause.c index d2df8fc86..dfd3fedfd 100644 --- a/src/backend/parser/cypher_clause.c +++ b/src/backend/parser/cypher_clause.c @@ -93,7 +93,7 @@ typedef Query *(*transform_method)(cypher_parsestate *cpstate, cypher_clause *clause); -// projection +/* projection */ static Query *transform_cypher_return(cypher_parsestate *cpstate, cypher_clause *clause); static List *transform_cypher_order_by(cypher_parsestate *cpstate, @@ -111,7 +111,7 @@ static Query *transform_cypher_clause_with_where(cypher_parsestate *cpstate, transform_method transform, cypher_clause *clause, Node *where); -// match clause +/* match clause */ static Query *transform_cypher_match(cypher_parsestate *cpstate, cypher_clause *clause); static Query *transform_cypher_match_pattern(cypher_parsestate *cpstate, @@ -175,7 +175,7 @@ static TargetEntry *findTarget(List *targetList, char *resname); static transform_entity *transform_VLE_edge_entity(cypher_parsestate *cpstate, cypher_relationship *rel, Query *query); -// create clause +/* create clause */ static Query *transform_cypher_create(cypher_parsestate *cpstate, cypher_clause *clause); static List *transform_cypher_create_pattern(cypher_parsestate *cpstate, @@ -211,7 +211,7 @@ static Query *transform_cypher_sub_pattern(cypher_parsestate *cpstate, cypher_clause *clause); static Query *transform_cypher_sub_query(cypher_parsestate *cpstate, cypher_clause *clause); -// set and remove clause +/* set and remove clause */ static Query *transform_cypher_set(cypher_parsestate *cpstate, cypher_clause *clause); static cypher_update_information *transform_cypher_set_item_list(cypher_parsestate *cpstate, @@ -220,13 +220,13 @@ static cypher_update_information *transform_cypher_set_item_list(cypher_parsesta static cypher_update_information *transform_cypher_remove_item_list(cypher_parsestate *cpstate, List *remove_item_list, Query *query); -// delete +/* delete */ static Query *transform_cypher_delete(cypher_parsestate *cpstate, cypher_clause *clause); static List *transform_cypher_delete_item_list(cypher_parsestate *cpstate, List *delete_item_list, Query *query); -//set operators +/* set operators */ static cypher_clause *make_cypher_clause(List *stmt); static Query *transform_cypher_union(cypher_parsestate *cpstate, @@ -245,10 +245,10 @@ Query *cypher_parse_sub_analyze_union(cypher_clause *clause, static void get_res_cols(ParseState *pstate, ParseNamespaceItem *l_pnsi, ParseNamespaceItem *r_pnsi, List **res_colnames, List **res_colvars); -// unwind +/* unwind */ static Query *transform_cypher_unwind(cypher_parsestate *cpstate, cypher_clause *clause); -// merge +/* merge */ static Query *transform_cypher_merge(cypher_parsestate *cpstate, cypher_clause *clause); static cypher_create_path * @@ -278,13 +278,13 @@ static cypher_target_node *get_referenced_variable(ParseState *pstate, Node *node, List *transformed_path); -//call...[yield] +/* call...[yield] */ static Query *transform_cypher_call_stmt(cypher_parsestate *cpstate, cypher_clause *clause); static Query *transform_cypher_call_subquery(cypher_parsestate *cpstate, cypher_clause *clause); -// transform +/* transform */ #define PREV_CYPHER_CLAUSE_ALIAS AGE_DEFAULT_ALIAS_PREFIX"previous_cypher_clause" #define CYPHER_OPT_RIGHT_ALIAS AGE_DEFAULT_ALIAS_PREFIX"cypher_optional_right" #define transform_prev_cypher_clause(cpstate, prev_clause, add_rte_to_query) \ @@ -348,7 +348,7 @@ Query *transform_cypher_clause(cypher_parsestate *cpstate, Node *self = clause->self; Query *result; - // examine the type of clause and call the transform logic for it + /* examine the type of clause and call the transform logic for it */ if (is_ag_node(self, cypher_return)) { cypher_return *n = (cypher_return *) self; @@ -1066,7 +1066,7 @@ transform_cypher_union_tree(cypher_parsestate *cpstate, cypher_clause *clause, } return (Node *)op; - }//end else (is not leaf) + }/* end else (is not leaf) */ } /* @@ -1081,9 +1081,11 @@ static Query *transform_cypher_call_stmt(cypher_parsestate *cpstate, ParseState *pstate = (ParseState *)cpstate; cypher_call *self = (cypher_call *)clause->self; - if (!clause->prev && !clause->next) /* CALL [YIELD] -- the most simple call */ + /* CALL [YIELD] -- the most simple call */ + if (!clause->prev && !clause->next) { - if (self->where) /* Error check for WHERE clause after YIELD without RETURN */ + /* Error check for WHERE clause after YIELD without RETURN */ + if (self->where) { Assert(self->yield_items); @@ -1167,7 +1169,8 @@ static Query *transform_cypher_call_subquery(cypher_parsestate *cpstate, colName, false); - if (self->yield_items) /* if there are yield items, we need to check them */ + /* if there are yield items, we need to check them */ + if (self->yield_items) { List *yield_targetList; ListCell *lc; @@ -1324,7 +1327,7 @@ static Query *transform_cypher_delete(cypher_parsestate *cpstate, func_expr = make_clause_func_expr(DELETE_CLAUSE_FUNCTION_NAME, (Node *)delete_data); - // Create the target entry + /* Create the target entry */ tle = makeTargetEntry((Expr *)func_expr, pstate->p_next_resno++, AGE_VARNAME_DELETE_CLAUSE, false); query->targetList = lappend(query->targetList, tle); @@ -1368,7 +1371,7 @@ static Query *transform_cypher_unwind(cypher_parsestate *cpstate, pnsi = transform_prev_cypher_clause(cpstate, clause->prev, true); rtindex = list_length(pstate->p_rtable); - // rte is the first RangeTblEntry in pstate + /* rte is the first RangeTblEntry in pstate */ if (rtindex != 1) { ereport(ERROR, @@ -1556,7 +1559,7 @@ static Query *transform_cypher_set(cypher_parsestate *cpstate, func_expr = make_clause_func_expr(SET_CLAUSE_FUNCTION_NAME, (Node *)set_items_target_list); - // Create the target entry + /* Create the target entry */ tle = makeTargetEntry((Expr *)func_expr, pstate->p_next_resno++, AGE_VARNAME_SET_CLAUSE, false); query->targetList = lappend(query->targetList, tle); @@ -1618,7 +1621,7 @@ cypher_update_information *transform_cypher_remove_item_list( ind = (A_Indirection *)set_item->prop; - // extract variable name + /* extract variable name */ if (!IsA(ind->arg, ColumnRef)) { ereport(ERROR, @@ -1648,7 +1651,7 @@ cypher_update_information *transform_cypher_remove_item_list( add_volatile_wrapper_to_target_entry(query->targetList, item->entity_position); - // extract property name + /* extract property name */ if (list_length(ind->indirection) != 1) { ereport(ERROR, @@ -1695,9 +1698,9 @@ cypher_update_information *transform_cypher_set_item_list( A_Indirection *ind; char *variable_name, *property_name; String *property_node, *variable_node; - int is_entire_prop_update = 0; // true if a map is assigned to variable + int is_entire_prop_update = 0; /* true if a map is assigned to variable */ - // LHS of set_item must be a variable or an indirection. + /* LHS of set_item must be a variable or an indirection. */ if (IsA(set_item->prop, ColumnRef)) { /* @@ -1752,7 +1755,7 @@ cypher_update_information *transform_cypher_set_item_list( item->remove_item = false; - // set variable, is_add and extract property name + /* set variable, is_add and extract property name */ if (is_entire_prop_update) { ref = (ColumnRef *)set_item->prop; @@ -1775,7 +1778,7 @@ cypher_update_information *transform_cypher_set_item_list( } set_item->is_add = false; - // extract property name + /* extract property name */ if (list_length(ind->indirection) != 1) { ereport( @@ -1798,7 +1801,7 @@ cypher_update_information *transform_cypher_set_item_list( item->prop_name = property_name; } - // extract variable name + /* extract variable name */ variable_node = linitial(ref->fields); if (!IsA(variable_node, String)) { @@ -1825,13 +1828,13 @@ cypher_update_information *transform_cypher_set_item_list( add_volatile_wrapper_to_target_entry(query->targetList, item->entity_position); - // set keep_null property + /* set keep_null property */ if (is_ag_node(set_item->expr, cypher_map)) { ((cypher_map*)set_item->expr)->keep_null = set_item->is_add; } - // create target entry for the new property value + /* create target entry for the new property value */ item->prop_position = (AttrNumber)pstate->p_next_resno; target_item = transform_cypher_item(cpstate, set_item->expr, NULL, EXPR_KIND_SELECT_TARGET, NULL, @@ -2139,7 +2142,7 @@ static Query *transform_cypher_return(cypher_parsestate *cpstate, markTargetListOrigins(pstate, query->targetList); - // ORDER BY + /* ORDER BY */ query->sortClause = transform_cypher_order_by(cpstate, self->order_by, &query->targetList, EXPR_KIND_ORDER_BY); @@ -2151,7 +2154,7 @@ static Query *transform_cypher_return(cypher_parsestate *cpstate, query->sortClause, EXPR_KIND_GROUP_BY); - // DISTINCT + /* DISTINCT */ if (self->distinct) { query->distinctClause = transformDistinctClause( @@ -2164,7 +2167,7 @@ static Query *transform_cypher_return(cypher_parsestate *cpstate, query->hasDistinctOn = false; } - // SKIP and LIMIT + /* SKIP and LIMIT */ query->limitOffset = transform_cypher_limit(cpstate, self->skip, EXPR_KIND_OFFSET, "SKIP"); query->limitCount = transform_cypher_limit(cpstate, self->limit, @@ -2187,7 +2190,7 @@ static Query *transform_cypher_return(cypher_parsestate *cpstate, return query; } -// see transformSortClause() +/* see transformSortClause() */ static List *transform_cypher_order_by(cypher_parsestate *cpstate, List *sort_items, List **target_list, ParseExprKind expr_kind) @@ -2211,7 +2214,7 @@ static List *transform_cypher_order_by(cypher_parsestate *cpstate, return sort_list; } -// see findTargetlistEntrySQL99() +/* see findTargetlistEntrySQL99() */ static TargetEntry *find_target_list_entry(cypher_parsestate *cpstate, Node *node, List **target_list, ParseExprKind expr_kind) @@ -2242,7 +2245,7 @@ static TargetEntry *find_target_list_entry(cypher_parsestate *cpstate, return te; } -// see transformLimitClause() +/* see transformLimitClause() */ static Node *transform_cypher_limit(cypher_parsestate *cpstate, Node *node, ParseExprKind expr_kind, const char *construct_name) @@ -2259,7 +2262,7 @@ static Node *transform_cypher_limit(cypher_parsestate *cpstate, Node *node, qual = coerce_to_specific_type(pstate, qual, INT8OID, construct_name); - // LIMIT can't refer to any variables of the current query. + /* LIMIT can't refer to any variables of the current query. */ if (contain_vars_of_level(qual, 0)) { ereport(ERROR, @@ -2279,9 +2282,9 @@ static Query *transform_cypher_with(cypher_parsestate *cpstate, cypher_return *return_clause; cypher_clause *wrapper; - // TODO: check that all items have an alias for each + /* TODO: check that all items have an alias for each */ - // WITH clause is basically RETURN clause with optional WHERE subclause + /* WITH clause is basically RETURN clause with optional WHERE subclause */ return_clause = make_ag_node(cypher_return); return_clause->distinct = self->distinct; return_clause->items = self->items; @@ -2379,7 +2382,7 @@ static Query *transform_cypher_clause_with_where(cypher_parsestate *cpstate, Assert(pnsi != NULL); rtindex = list_length(pstate->p_rtable); - // rte is the only RangeTblEntry in pstate + /* rte is the only RangeTblEntry in pstate */ if (rtindex != 1) { ereport(ERROR, @@ -2403,7 +2406,7 @@ static Query *transform_cypher_clause_with_where(cypher_parsestate *cpstate, where_qual = coerce_to_boolean(pstate, where_qual, "WHERE"); - // check if we have a list comprehension in the where clause + /* check if we have a list comprehension in the where clause */ if (cpstate->p_list_comp && has_a_cypher_list_comprehension_node(where)) { @@ -2552,11 +2555,11 @@ static void get_res_cols(ParseState *pstate, ParseNamespaceItem *l_pnsi, expandRTE(r_pnsi->p_rte, r_pnsi->p_rtindex, 0, -1, false, &r_colnames, &r_colvars); - // add in all colnames and colvars from the l_rte. + /* add in all colnames and colvars from the l_rte. */ *res_colnames = list_concat(*res_colnames, l_colnames); *res_colvars = list_concat(*res_colvars, l_colvars); - // find new columns and if they are a var, pass them in. + /* find new columns and if they are a var, pass them in. */ forboth(r_lname, r_colnames, r_lvar, r_colvars) { char *r_colname = strVal(lfirst(r_lname)); @@ -2630,7 +2633,7 @@ static RangeTblEntry *transform_cypher_optional_match_clause(cypher_parsestate * prevclause = clause->prev; clause->prev = NULL; - //set the lateral flag to true + /* set the lateral flag to true */ pstate->p_lateral_active = true; j->rarg = transform_clause_for_join(cpstate, clause, &r_rte, @@ -2643,7 +2646,7 @@ static RangeTblEntry *transform_cypher_optional_match_clause(cypher_parsestate * */ markRelsAsNulledBy(pstate, j->rarg, r_nsitem->p_rtindex + 1); - // we are done transform the lateral left join + /* we are done transform the lateral left join */ pstate->p_lateral_active = false; /* @@ -2654,7 +2657,7 @@ static RangeTblEntry *transform_cypher_optional_match_clause(cypher_parsestate * pstate->p_namespace = NIL; - // get the colnames and colvars from the rtes + /* get the colnames and colvars from the rtes */ get_res_cols(pstate, l_nsitem, r_nsitem, &res_colnames, &res_colvars); jnsitem = addRangeTableEntryForJoin(pstate, @@ -2727,7 +2730,7 @@ static Query *transform_cypher_match_pattern(cypher_parsestate *cpstate, } } - // If there is no previous clause, transform to a general MATCH clause. + /* If there is no previous clause, transform to a general MATCH clause. */ if (self->optional == true && clause->prev != NULL) { RangeTblEntry *rte = transform_cypher_optional_match_clause(cpstate, clause); @@ -2748,7 +2751,7 @@ static Query *transform_cypher_match_pattern(cypher_parsestate *cpstate, pnsi = transform_prev_cypher_clause(cpstate, clause->prev, true); rte = pnsi->p_rte; rtindex = list_length(pstate->p_rtable); - // rte is the first RangeTblEntry in pstate + /* rte is the first RangeTblEntry in pstate */ if (rtindex != 1) { ereport(ERROR, @@ -3203,7 +3206,7 @@ static void transform_match_pattern(cypher_parsestate *cpstate, Query *query, } } - // transform the where clause quals and add to the quals, + /* transform the where clause quals and add to the quals, */ if (where != NULL) { Expr *where_qual; @@ -3287,7 +3290,7 @@ static FuncCall *prevent_duplicate_edges(cypher_parsestate *cpstate, qualified_function_name = list_make2(ag_catalog, edge_fn); - // iterate through each entity, collecting the access node for each edge + /* iterate through each entity, collecting the access node for each edge */ foreach (lc, entities) { transform_entity *entity = lfirst(lc); @@ -3417,10 +3420,10 @@ static List *make_join_condition_for_edge(cypher_parsestate *cpstate, left_id = (Node *)make_qual(cpstate, prev_node, "id"); right_id = (Node *)make_qual(cpstate, next_node, "id"); - // create the argument list + /* create the argument list */ args = list_make3(left_id, right_id, entity->expr); - // add to quals + /* add to quals */ quals = lappend(quals, makeFuncCall(qualified_func_name, args, COERCE_EXPLICIT_CALL, -1)); } @@ -3441,13 +3444,13 @@ static List *make_join_condition_for_edge(cypher_parsestate *cpstate, match_qual = makeString("age_match_two_vle_edges"); - // make the qualified function name + /* make the qualified function name */ qualified_name = list_make2(ag_catalog, match_qual); - // make the args + /* make the args */ args = list_make2(prev_edge->expr, entity->expr); - // create the function call + /* create the function call */ fc = makeFuncCall(qualified_name, args, COERCE_EXPLICIT_CALL, -1); quals = lappend(quals, fc); @@ -3575,7 +3578,7 @@ static List *make_join_condition_for_edge(cypher_parsestate *cpstate, } } -// creates a type cast node to agtype +/* creates a type cast node to agtype */ static Node *make_type_cast_to_agtype(Node *arg) { TypeCast *n = makeNode(TypeCast); @@ -3601,7 +3604,7 @@ static Node *make_bool_a_const(bool state) n->val.sval.sval = (state ? "true" : "false"); n->location = -1; - // typecast to agtype + /* typecast to agtype */ return make_type_cast_to_agtype((Node *)n); } @@ -3660,12 +3663,12 @@ static List *join_to_entity(cypher_parsestate *cpstate, */ if (side == JOIN_SIDE_LEFT) { - // [vle_edge]-()-[regular_edge] + /* [vle_edge]-()-[regular_edge] */ is_left_side = true; } else if (side == JOIN_SIDE_RIGHT) { - // [edge]-()-[vle_edge] + /* [edge]-()-[vle_edge] */ is_left_side = false; } else @@ -3676,13 +3679,13 @@ static List *join_to_entity(cypher_parsestate *cpstate, parser_errposition(pstate, entity->entity.rel->location))); } - // make the qualified function name + /* make the qualified function name */ qualified_name = list_make2(ag_catalog, match_qual); - // make the args + /* make the args */ args = list_make3(entity->expr, qual, make_bool_a_const(is_left_side)); - // create the function call + /* create the function call */ fc = makeFuncCall(qualified_name, args, COERCE_EXPLICIT_CALL, -1); quals = lappend(quals, fc); @@ -3698,7 +3701,7 @@ static List *join_to_entity(cypher_parsestate *cpstate, return quals; } -// makes the quals necessary when an edge is joining to another edge. +/* makes the quals necessary when an edge is joining to another edge. */ static List *make_edge_quals(cypher_parsestate *cpstate, transform_entity *edge, enum transform_entity_join_side side) @@ -3829,16 +3832,16 @@ static A_Expr *filter_vertices_on_label_id(cypher_parsestate *cpstate, static Node *transform_map_to_ind(cypher_parsestate *cpstate, transform_entity *entity, cypher_map *map) { - List *quals; // list of equality and/or containment qual node + List *quals; /* list of equality and/or containment qual node */ if (entity->entity.node->use_equals) { - // Case 1 + /* Case 1 */ quals = transform_map_to_ind_top_level(cpstate, entity, map); } else { - // Case 2 + /* Case 2 */ quals = transform_map_to_ind_recursive(cpstate, entity, map, NIL); } @@ -4100,10 +4103,10 @@ static List *transform_match_path(cypher_parsestate *cpstate, Query *query, FuncCall *duplicate_edge_qual; List *join_quals; - // transform the entities in the path + /* transform the entities in the path */ entities = transform_match_entities(cpstate, query, path); - // create the path variable, if needed. + /* create the path variable, if needed. */ if (path->var_name != NULL) { TargetEntry *path_te; @@ -4122,11 +4125,11 @@ static List *transform_match_path(cypher_parsestate *cpstate, Query *query, query->targetList = lappend(query->targetList, path_te); } - // construct the quals for the join tree + /* construct the quals for the join tree */ join_quals = make_path_join_quals(cpstate, entities); qual = list_concat(qual, join_quals); - // construct the qual to prevent duplicate edges + /* construct the qual to prevent duplicate edges */ if (list_length(entities) > 3) { duplicate_edge_qual = prevent_duplicate_edges(cpstate, entities); @@ -4705,7 +4708,7 @@ static List *make_path_join_quals(cypher_parsestate *cpstate, List *entities) List *quals = NIL; List *join_quals; - // for vertex only queries, there is no work to do + /* for vertex only queries, there is no work to do */ if (list_length(entities) < 3) { return NIL; @@ -4725,7 +4728,7 @@ static List *make_path_join_quals(cypher_parsestate *cpstate, List *entities) edge = lfirst(lc); } - // Retrieve the next node and edge in the pattern. + /* Retrieve the next node and edge in the pattern. */ if (lnext(entities, lc) != NULL) { lc = lnext(entities, lc); @@ -4738,7 +4741,7 @@ static List *make_path_join_quals(cypher_parsestate *cpstate, List *entities) } } - // create the join quals for the node + /* create the join quals for the node */ join_quals = make_join_condition_for_edge(cpstate, prev_edge, prev_node, edge, next_node, next_edge); @@ -4846,12 +4849,12 @@ static char *get_accessor_function_name(enum transform_entity_type type, { if (type == ENT_VERTEX) { - // id + /* id */ if (!strcmp(AG_VERTEX_COLNAME_ID, name)) { return AG_VERTEX_ACCESS_FUNCTION_ID; } - // props + /* props */ else if (!strcmp(AG_VERTEX_COLNAME_PROPERTIES, name)) { return AG_VERTEX_ACCESS_FUNCTION_PROPERTIES; @@ -4859,22 +4862,22 @@ static char *get_accessor_function_name(enum transform_entity_type type, } if (type == ENT_EDGE) { - // id + /* id */ if (!strcmp(AG_EDGE_COLNAME_ID, name)) { return AG_EDGE_ACCESS_FUNCTION_ID; } - // start id + /* start id */ else if (!strcmp(AG_EDGE_COLNAME_START_ID, name)) { return AG_EDGE_ACCESS_FUNCTION_START_ID; } - // end id + /* end id */ else if (!strcmp(AG_EDGE_COLNAME_END_ID, name)) { return AG_EDGE_ACCESS_FUNCTION_END_ID; } - // props + /* props */ else if (!strcmp(AG_VERTEX_COLNAME_PROPERTIES, name)) { return AG_VERTEX_ACCESS_FUNCTION_PROPERTIES; @@ -4885,7 +4888,7 @@ static char *get_accessor_function_name(enum transform_entity_type type, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("column %s does not have an accessor function", name))); - // keeps compiler silent + /* keeps compiler silent */ return NULL; } @@ -5611,7 +5614,7 @@ static Query *transform_cypher_create(cypher_parsestate *cpstate, func_expr = make_clause_func_expr(CREATE_CLAUSE_FUNCTION_NAME, (Node *)target_nodes); - // Create the target entry + /* Create the target entry */ tle = makeTargetEntry((Expr *)func_expr, pstate->p_next_resno++, AGE_VARNAME_CREATE_CLAUSE, false); query->targetList = lappend(query->targetList, tle); @@ -5844,7 +5847,7 @@ transform_create_cypher_edge(cypher_parsestate *cpstate, List **target_list, parser_errposition(&cpstate->pstate, edge->location))); } - // create the label entry if it does not exist + /* create the label entry if it does not exist */ if (!label_exists(edge->label, cpstate->graph_oid)) { List *parent; @@ -5858,11 +5861,11 @@ transform_create_cypher_edge(cypher_parsestate *cpstate, List **target_list, parent); } - // lock the relation of the label + /* lock the relation of the label */ rv = makeRangeVar(cpstate->graph_name, edge->label, -1); label_relation = parserOpenTable(&cpstate->pstate, rv, RowExclusiveLock); - // Store the relid + /* Store the relid */ rel->relid = RelationGetRelid(label_relation); pnsi = addRangeTableEntryForRelation((ParseState *)cpstate, label_relation, @@ -5871,11 +5874,11 @@ transform_create_cypher_edge(cypher_parsestate *cpstate, List **target_list, rte_pi = pnsi->p_perminfo; rte_pi->requiredPerms = ACL_INSERT; - // Build Id expression, always use the default logic + /* Build Id expression, always use the default logic */ rel->id_expr = (Expr *)build_column_default(label_relation, Anum_ag_label_edge_table_id); - // Build properties expression, if no map is given, use the default logic + /* Build properties expression, if no map is given, use the default logic */ alias = get_next_default_alias(cpstate); resno = pstate->p_next_resno++; @@ -5887,7 +5890,7 @@ transform_create_cypher_edge(cypher_parsestate *cpstate, List **target_list, *target_list = lappend(*target_list, te); - // Keep the lock + /* Keep the lock */ table_close(label_relation, NoLock); return rel; @@ -5915,7 +5918,7 @@ static bool variable_exists(cypher_parsestate *cpstate, char *name) return false; } -// transform nodes, check to see if the variable name already exists. +/* transform nodes, check to see if the variable name already exists. */ static cypher_target_node * transform_create_cypher_node(cypher_parsestate *cpstate, List **target_list, cypher_node *node, bool has_edge) @@ -5982,7 +5985,7 @@ transform_create_cypher_node(cypher_parsestate *cpstate, List **target_list, } } - // otherwise transform the target node as a new node + /* otherwise transform the target node as a new node */ return transform_create_cypher_new_node(cpstate, target_list, node); } @@ -6121,7 +6124,7 @@ transform_create_cypher_new_node(cypher_parsestate *cpstate, rel->label_name = node->label; } - // create the label entry if it does not exist + /* create the label entry if it does not exist */ if (!label_exists(node->label, cpstate->graph_oid)) { List *parent; @@ -6140,7 +6143,7 @@ transform_create_cypher_new_node(cypher_parsestate *cpstate, rv = makeRangeVar(cpstate->graph_name, node->label, -1); label_relation = parserOpenTable(&cpstate->pstate, rv, RowExclusiveLock); - // Store the relid + /* Store the relid */ rel->relid = RelationGetRelid(label_relation); pnsi = addRangeTableEntryForRelation((ParseState *)cpstate, label_relation, @@ -6149,11 +6152,11 @@ transform_create_cypher_new_node(cypher_parsestate *cpstate, rte_pi = pnsi->p_perminfo; rte_pi->requiredPerms = ACL_INSERT; - // id + /* id */ rel->id_expr = (Expr *)build_column_default(label_relation, Anum_ag_label_vertex_table_id); - // properties + /* properties */ alias = get_next_default_alias(cpstate); resno = pstate->p_next_resno++; @@ -6247,7 +6250,7 @@ static Expr *cypher_create_properties(cypher_parsestate *cpstate, ereport(ERROR, (errmsg_internal("unrecognized entity type"))); } - // add a volatile wrapper call to prevent the optimizer from removing it + /* add a volatile wrapper call to prevent the optimizer from removing it */ return (Expr *)add_volatile_wrapper(properties); } @@ -6290,7 +6293,7 @@ transform_cypher_clause_as_subquery(cypher_parsestate *cpstate, } else if (pstate->p_expr_kind == EXPR_KIND_OTHER) { - // this is a lateral subselect for the MERGE + /* this is a lateral subselect for the MERGE */ pstate->p_expr_kind = EXPR_KIND_FROM_SUBSELECT; lateral = true; } @@ -6339,7 +6342,7 @@ transform_cypher_clause_as_subquery(cypher_parsestate *cpstate, if (add_rte_to_query) { - // all variables(attributes) from the previous clause(subquery) are visible + /* all variables(attributes) from the previous clause(subquery) are visible */ addNSItemToQuery(pstate, pnsi, true, false, true); } @@ -6557,7 +6560,7 @@ static Query *transform_cypher_merge(cypher_parsestate *cpstate, merge_information->flags = CYPHER_CLAUSE_FLAG_NONE; - // make the merge node into a match node + /* make the merge node into a match node */ merge_clause_as_match = convert_merge_to_match(self); /* @@ -6573,11 +6576,11 @@ static Query *transform_cypher_merge(cypher_parsestate *cpstate, } else { - // make the merge node into a match node + /* make the merge node into a match node */ - // TODO this is called above and appears redundant but needs to be - // looked into - //cypher_clause *merge_clause_as_match = convert_merge_to_match(self); + /* TODO this is called above and appears redundant but needs to be */ + /* looked into */ + /* cypher_clause *merge_clause_as_match = convert_merge_to_match(self); */ /* * Create the metadata needed for creating missing paths. @@ -6619,7 +6622,7 @@ static Query *transform_cypher_merge(cypher_parsestate *cpstate, func_expr = make_clause_func_expr(MERGE_CLAUSE_FUNCTION_NAME, (Node *)merge_information); - // Create the target entry + /* Create the target entry */ tle = makeTargetEntry((Expr *)func_expr, pstate->p_next_resno++, AGE_VARNAME_MERGE_CLAUSE, false); @@ -6701,7 +6704,7 @@ transform_merge_make_lateral_join(cypher_parsestate *cpstate, Query *query, tmp = pstate->p_expr_kind; pstate->p_expr_kind = EXPR_KIND_OTHER; - // transform MERGE + /* transform MERGE */ j->rarg = transform_clause_for_join(cpstate, isolated_merge_clause, &r_rte, &r_nsitem, r_alias); @@ -6712,7 +6715,7 @@ transform_merge_make_lateral_join(cypher_parsestate *cpstate, Query *query, */ markRelsAsNulledBy(pstate, j->rarg, r_nsitem->p_rtindex + 1); - // deactivate the lateral flag + /* deactivate the lateral flag */ pstate->p_lateral_active = false; pstate->p_namespace = NIL; @@ -6723,7 +6726,7 @@ transform_merge_make_lateral_join(cypher_parsestate *cpstate, Query *query, */ get_res_cols(pstate, l_nsitem, r_nsitem, &res_colnames, &res_colvars); - // make the RTE for the join + /* make the RTE for the join */ jnsitem = addRangeTableEntryForJoin(pstate, res_colnames, NULL, j->jointype, 0, res_colvars, NIL, NIL, j->alias, NULL, true); @@ -6813,7 +6816,7 @@ transform_cypher_merge_mark_tuple_position(cypher_parsestate *cpstate, */ te->expr = add_volatile_wrapper(te->expr); - // Mark the tuple position the target_node is for. + /* Mark the tuple position the target_node is for. */ path->path_attr_num = te->resno; } @@ -6830,7 +6833,7 @@ transform_cypher_merge_mark_tuple_position(cypher_parsestate *cpstate, */ te->expr = add_volatile_wrapper(te->expr); - // Mark the tuple position the target_node is for. + /* Mark the tuple position the target_node is for. */ node->tuple_position = te->resno; } @@ -7126,7 +7129,7 @@ transform_cypher_merge_path(cypher_parsestate *cpstate, List **target_list, prev_node = lc; } - // store the path's variable name + /* store the path's variable name */ if (path->var_name) { ccp->var_name = path->var_name; @@ -7158,7 +7161,7 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, transform_entity *entity = find_transform_entity(cpstate, edge->name, ENT_EDGE); - // We found a variable with this variable name, throw an error. + /* We found a variable with this variable name, throw an error. */ if (entity || variable_exists(cpstate, edge->name)) { ereport(ERROR, @@ -7171,13 +7174,13 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, } else { - // assign a default variable name. + /* assign a default variable name. */ edge->name = get_next_default_alias(cpstate); } rel->type = LABEL_KIND_EDGE; - // all edges are marked with insert + /* all edges are marked with insert */ rel->flags |= CYPHER_TARGET_NODE_FLAG_INSERT; rel->label_name = edge->label; rel->variable_name = edge->name; @@ -7194,7 +7197,7 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, } - // check to see if the label exists, create the label entry if it does not. + /* check to see if the label exists, create the label entry if it does not. */ if (edge->label && !label_exists(edge->label, cpstate->graph_oid)) { List *parent; @@ -7207,12 +7210,12 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, parent = list_make1(rv); - // create the label + /* create the label */ create_label(cpstate->graph_name, edge->label, LABEL_TYPE_EDGE, parent); } - // lock the relation of the label + /* lock the relation of the label */ rv = makeRangeVar(cpstate->graph_name, edge->label, -1); label_relation = parserOpenTable(&cpstate->pstate, rv, RowExclusiveLock); @@ -7224,14 +7227,15 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, * isn't either and has the correct number of columns. However, for now, * we just check the number of columns. */ - if (label_relation->rd_att->natts == 2) // TODO temporarily hardcoded + /* TODO temporarily hardcoded */ + if (label_relation->rd_att->natts == 2) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Expecting edge label, found existing vertex label"), parser_errposition(&cpstate->pstate, edge->location))); } - // Store the relid + /* Store the relid */ rel->relid = RelationGetRelid(label_relation); pnsi = addRangeTableEntryForRelation((ParseState *)cpstate, label_relation, @@ -7239,14 +7243,14 @@ transform_merge_cypher_edge(cypher_parsestate *cpstate, List **target_list, rte_pi = pnsi->p_perminfo; rte_pi->requiredPerms = ACL_INSERT; - // Build Id expression, always use the default logic + /* Build Id expression, always use the default logic */ rel->id_expr = (Expr *)build_column_default(label_relation, Anum_ag_label_edge_table_id); rel->prop_expr = cypher_create_properties(cpstate, rel, label_relation, edge->props, ENT_EDGE); - // Keep the lock + /* Keep the lock */ table_close(label_relation, NoLock); return rel; @@ -7305,7 +7309,7 @@ transform_merge_cypher_node(cypher_parsestate *cpstate, List **target_list, } else { - // assign a default variable name. + /* assign a default variable name. */ node->name = get_next_default_alias(cpstate); } @@ -7328,7 +7332,7 @@ transform_merge_cypher_node(cypher_parsestate *cpstate, List **target_list, rel->label_name = node->label; } - // check to see if the label exists, create the label entry if it does not. + /* check to see if the label exists, create the label entry if it does not. */ if (node->label && !label_exists(node->label, cpstate->graph_oid)) { List *parent; @@ -7342,7 +7346,7 @@ transform_merge_cypher_node(cypher_parsestate *cpstate, List **target_list, parent = list_make1(rv); - // create the label + /* create the label */ create_label(cpstate->graph_name, node->label, LABEL_TYPE_VERTEX, parent); } @@ -7360,14 +7364,15 @@ transform_merge_cypher_node(cypher_parsestate *cpstate, List **target_list, * isn't either and has the correct number of columns. However, for now, * we just check the number of columns. */ - if (label_relation->rd_att->natts == 4) // TODO temporarily hardcoded + /* TODO temporarily hardcoded */ + if (label_relation->rd_att->natts == 4) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Expecting vertex label, found existing edge label"), parser_errposition(&cpstate->pstate, node->location))); } - // Store the relid + /* Store the relid */ rel->relid = RelationGetRelid(label_relation); pnsi = addRangeTableEntryForRelation((ParseState *)cpstate, label_relation, @@ -7376,7 +7381,7 @@ transform_merge_cypher_node(cypher_parsestate *cpstate, List **target_list, rte_pi = pnsi->p_perminfo; rte_pi->requiredPerms = ACL_INSERT; - // id + /* id */ rel->id_expr = (Expr *)build_column_default(label_relation, Anum_ag_label_vertex_table_id); @@ -7396,9 +7401,9 @@ static cypher_clause *convert_merge_to_match(cypher_merge *merge) cypher_match *match = make_ag_node(cypher_match); cypher_clause *clause = palloc(sizeof(cypher_clause)); - // match supports multiple paths, whereas merge only supports one. + /* match supports multiple paths, whereas merge only supports one. */ match->pattern = list_make1(merge->path); - // MERGE does not support where + /* MERGE does not support where */ match->where = NULL; /* @@ -7532,7 +7537,7 @@ static void handle_prev_clause(cypher_parsestate *cpstate, Query *query, rtindex = list_length(pstate->p_rtable); - // rte is the first RangeTblEntry in pstate + /* rte is the first RangeTblEntry in pstate */ if (first_rte) { if (rtindex != 1) @@ -7543,7 +7548,7 @@ static void handle_prev_clause(cypher_parsestate *cpstate, Query *query, } } - // add all the rte's attributes to the current queries targetlist + /* add all the rte's attributes to the current queries targetlist */ query->targetList = expandNSItemAttrs(pstate, pnsi, 0, true, -1); } diff --git a/src/backend/parser/cypher_expr.c b/src/backend/parser/cypher_expr.c index 1ba2b7ee4..499c9528e 100644 --- a/src/backend/parser/cypher_expr.c +++ b/src/backend/parser/cypher_expr.c @@ -103,7 +103,7 @@ Node *transform_cypher_expr(cypher_parsestate *cpstate, Node *expr, ParseExprKind old_expr_kind; Node *result; - // save and restore identity of expression type we're parsing + /* save and restore identity of expression type we're parsing */ Assert(expr_kind != EXPR_KIND_NONE); old_expr_kind = pstate->p_expr_kind; pstate->p_expr_kind = expr_kind; @@ -121,7 +121,7 @@ static Node *transform_cypher_expr_recurse(cypher_parsestate *cpstate, if (!expr) return NULL; - // guard against stack overflow due to overly complex expressions + /* guard against stack overflow due to overly complex expressions */ check_stack_depth(); switch (nodeTag(expr)) @@ -299,7 +299,7 @@ static Node *transform_A_Const(cypher_parsestate *cpstate, A_Const *ac) } cancel_parser_errposition_callback(&pcbstate); - // typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. + /* typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. */ c = makeConst(AGTYPEOID, -1, InvalidOid, -1, d, is_null, false); c->location = ac->location; return (Node *)c; @@ -598,7 +598,7 @@ static Node *transform_AEXPR_IN(cypher_parsestate *cpstate, A_Expr *a) Assert(is_ag_node(a->rexpr, cypher_list)); - // If the operator is <>, combine with AND not OR. + /* If the operator is <>, combine with AND not OR. */ if (strcmp(strVal(linitial(a->name)), "<>") == 0) { useOr = false; @@ -677,13 +677,13 @@ static Node *transform_AEXPR_IN(cypher_parsestate *cpstate, A_Expr *a) rexprs = rvars; } - // Must do it the hard way, with a boolean expression tree. + /* Must do it the hard way, with a boolean expression tree. */ foreach(l, rexprs) { Node *rexpr = (Node *) lfirst(l); Node *cmp; - // Ordinary scalar operator + /* Ordinary scalar operator */ cmp = (Node *) make_op(pstate, a->name, copyObject(lexpr), rexpr, pstate->p_last_srf, a->location); @@ -770,7 +770,7 @@ static Node *transform_cypher_bool_const(cypher_parsestate *cpstate, agt = boolean_to_agtype(bc->boolean); cancel_parser_errposition_callback(&pcbstate); - // typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. + /* typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. */ c = makeConst(AGTYPEOID, -1, InvalidOid, -1, agt, false, false); c->location = bc->location; @@ -789,7 +789,7 @@ static Node *transform_cypher_integer_const(cypher_parsestate *cpstate, agt = integer_to_agtype(ic->integer); cancel_parser_errposition_callback(&pcbstate); - // typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. + /* typtypmod, typcollation, typlen, and typbyval of agtype are hard-coded. */ c = makeConst(AGTYPEOID, -1, InvalidOid, -1, agt, false, false); c->location = ic->location; @@ -1102,8 +1102,8 @@ static Node *transform_cypher_map(cypher_parsestate *cpstate, cypher_map *cm) /* build and append the transformed key/val pair */ setup_parser_errposition_callback(&pcbstate, pstate, cm->location); - // typtypmod, typcollation, typlen, and typbyval of agtype are - // hard-coded. + /* typtypmod, typcollation, typlen, and typbyval of agtype are */ + /* hard-coded. */ newkey = makeConst(TEXTOID, -1, InvalidOid, -1, CStringGetTextDatum(strVal(key)), false, false); cancel_parser_errposition_callback(&pcbstate); @@ -1238,7 +1238,7 @@ static Node *transform_cypher_list(cypher_parsestate *cpstate, cypher_list *cl) return (Node *)fexpr; } -// makes a VARIADIC agtype array +/* makes a VARIADIC agtype array */ static ArrayExpr *make_agtype_array_expr(List *args) { ArrayExpr *newa = makeNode(ArrayExpr); @@ -1860,10 +1860,10 @@ static Node *transform_CaseExpr(cypher_parsestate *cpstate, CaseExpr */ ptype = select_common_type(pstate, resultexprs, NULL, NULL); - //InvalidOid shows that there is a boolean in the result expr. + /* InvalidOid shows that there is a boolean in the result expr. */ if (ptype == InvalidOid) { - //we manually set the type to boolean here to handle the bool casting. + /* we manually set the type to boolean here to handle the bool casting. */ ptype = BOOLOID; } diff --git a/src/backend/parser/cypher_gram.y b/src/backend/parser/cypher_gram.y index 165e4b119..4b80f4f00 100644 --- a/src/backend/parser/cypher_gram.y +++ b/src/backend/parser/cypher_gram.y @@ -27,7 +27,7 @@ #include "parser/cypher_parse_node.h" #include "parser/scansup.h" -// override the default action for locations +/* override the default action for locations */ #define YYLLOC_DEFAULT(current, rhs, n) \ do \ { \ @@ -195,16 +195,16 @@ %type utility_option_name %{ -// -// internal alias check + +/* internal alias check */ static bool has_internal_default_prefix(char *str); -// unique name generation +/* unique name generation */ #define UNIQUE_NAME_NULL_PREFIX AGE_DEFAULT_PREFIX"unique_null_prefix" static char *create_unique_name(char *prefix_name); static unsigned long get_a_unique_number(void); -// logical operators +/* logical operators */ static Node *make_or_expr(Node *lexpr, Node *rexpr, int location); static Node *make_and_expr(Node *lexpr, Node *rexpr, int location); static Node *make_xor_expr(Node *lexpr, Node *rexpr, int location); @@ -216,46 +216,46 @@ static Node *make_cypher_comparison_aexpr(A_Expr_Kind kind, char *name, static Node *make_cypher_comparison_boolexpr(BoolExprType boolop, List *args, int location); -// arithmetic operators +/* arithmetic operators */ static Node *do_negate(Node *n, int location); static void do_negate_float(Float *v); -// indirection +/* indirection */ static Node *append_indirection(Node *expr, Node *selector); -// literals +/* literals */ static Node *make_int_const(int i, int location); static Node *make_float_const(char *s, int location); static Node *make_string_const(char *s, int location); static Node *make_bool_const(bool b, int location); static Node *make_null_const(int location); -// typecast +/* typecast */ static Node *make_typecast_expr(Node *expr, char *typecast, int location); -// functions +/* functions */ static Node *make_function_expr(List *func_name, List *exprs, int location); static Node *make_star_function_expr(List *func_name, List *exprs, int location); static Node *make_distinct_function_expr(List *func_name, List *exprs, int location); static FuncCall *node_to_agtype(Node* fnode, char *type, int location); -// setops +/* setops */ static Node *make_set_op(SetOperation op, bool all_or_distinct, List *larg, List *rarg); -// VLE +/* VLE */ static cypher_relationship *build_VLE_relation(List *left_arg, cypher_relationship *cr, Node *right_arg, int left_arg_location, int cr_location); -// comparison +/* comparison */ static bool is_A_Expr_a_comparison_operation(cypher_comparison_aexpr *a); static Node *build_comparison_expression(Node *left_grammar_node, Node *right_grammar_node, char *opr_name, int location); -// list_comprehension +/* list_comprehension */ static Node *verify_rule_as_list_comprehension(Node *expr, Node *expr2, Node *where, Node *mapping_expr, int var_loc, int expr_loc, @@ -915,7 +915,7 @@ sort_item: n->sortby_dir = $2; n->sortby_nulls = SORTBY_NULLS_DEFAULT; n->useOp = NIL; - n->location = -1; // no operator + n->location = -1; /* no operator */ $$ = (Node *)n; } @@ -924,7 +924,7 @@ sort_item: order_opt: /* empty */ { - $$ = SORTBY_DEFAULT; // is the same with SORTBY_ASC + $$ = SORTBY_DEFAULT; /* is the same with SORTBY_ASC */ } | ASC { @@ -972,12 +972,12 @@ with: ListCell *li; cypher_with *n; - // check expressions are aliased + /* check expressions are aliased */ foreach(li, $3) { ResTarget *item = lfirst(li); - // variable does not have to be aliased + /* variable does not have to be aliased */ if (IsA(item->val, ColumnRef) || item->name) continue; @@ -1004,12 +1004,12 @@ with: ListCell *li; cypher_with *n; - // check expressions are aliased + /* check expressions are aliased */ foreach (li, $2) { ResTarget *item = lfirst(li); - // variable does not have to be aliased + /* variable does not have to be aliased */ if (IsA(item->val, ColumnRef) || item->name) continue; @@ -2455,7 +2455,7 @@ conflicted_keywords: static Node *make_or_expr(Node *lexpr, Node *rexpr, int location) { - // flatten "a OR b OR c ..." to a single BoolExpr on sight + /* flatten "a OR b OR c ..." to a single BoolExpr on sight */ if (IsA(lexpr, BoolExpr)) { BoolExpr *bexpr = (BoolExpr *)lexpr; @@ -2473,7 +2473,7 @@ static Node *make_or_expr(Node *lexpr, Node *rexpr, int location) static Node *make_and_expr(Node *lexpr, Node *rexpr, int location) { - // flatten "a AND b AND c ..." to a single BoolExpr on sight + /* flatten "a AND b AND c ..." to a single BoolExpr on sight */ if (IsA(lexpr, BoolExpr)) { BoolExpr *bexpr = (BoolExpr *)lexpr; @@ -2494,7 +2494,7 @@ static Node *make_xor_expr(Node *lexpr, Node *rexpr, int location) Expr *aorb; Expr *notaandb; - // XOR is (A OR B) AND (NOT (A AND B)) + /* XOR is (A OR B) AND (NOT (A AND B)) */ aorb = makeBoolExpr(OR_EXPR, list_make2(lexpr, rexpr), location); notaandb = makeBoolExpr(AND_EXPR, list_make2(lexpr, rexpr), location); @@ -2537,7 +2537,7 @@ static Node *make_cypher_comparison_boolexpr(BoolExprType boolop, List *args, in static Node *make_comparison_and_expr(Node *lexpr, Node *rexpr, int location) { - // flatten "a AND b AND c ..." to a single BoolExpr on sight + /* flatten "a AND b AND c ..." to a single BoolExpr on sight */ if (is_ag_node(lexpr, cypher_comparison_boolexpr)) { cypher_comparison_boolexpr *bexpr = (cypher_comparison_boolexpr *)lexpr; @@ -2563,7 +2563,7 @@ static Node *do_negate(Node *n, int location) { A_Const *c = (A_Const *)n; - // report the constant's location as that of the '-' sign + /* report the constant's location as that of the '-' sign */ c->location = location; if (c->val.ival.type == T_Integer) @@ -3274,7 +3274,7 @@ static cypher_relationship *build_VLE_relation(List *left_arg, return cr; } -// Helper function to verify that the rule is a list comprehension +/* Helper function to verify that the rule is a list comprehension */ static Node *verify_rule_as_list_comprehension(Node *expr, Node *expr2, Node *where, Node *mapping_expr, int var_loc, int expr_loc, @@ -3315,7 +3315,7 @@ static Node *build_list_comprehension_node(ColumnRef *cref, Node *expr, char *var_name = NULL; String *val; - // Extract name from cref + /* Extract name from cref */ val = linitial(cref->fields); if (!IsA(val, String)) diff --git a/src/backend/parser/cypher_item.c b/src/backend/parser/cypher_item.c index 3045d6c05..c32b46c46 100644 --- a/src/backend/parser/cypher_item.c +++ b/src/backend/parser/cypher_item.c @@ -39,7 +39,7 @@ static List *expand_pnsi_attrs(ParseState *pstate, ParseNamespaceItem *pnsi, int location); bool has_a_cypher_list_comprehension_node(Node *expr); -// see transformTargetEntry() +/* see transformTargetEntry() */ TargetEntry *transform_cypher_item(cypher_parsestate *cpstate, Node *node, Node *expr, ParseExprKind expr_kind, char *colname, bool resjunk) @@ -47,13 +47,13 @@ TargetEntry *transform_cypher_item(cypher_parsestate *cpstate, Node *node, ParseState *pstate = (ParseState *)cpstate; bool old_p_lateral_active = pstate->p_lateral_active; - // we want to see lateral variables + /* we want to see lateral variables */ pstate->p_lateral_active = true; if (!expr) expr = transform_cypher_expr(cpstate, node, expr_kind); - // set lateral back to what it was + /* set lateral back to what it was */ pstate->p_lateral_active = old_p_lateral_active; if (!colname && !resjunk) @@ -69,13 +69,13 @@ TargetEntry *transform_cypher_item(cypher_parsestate *cpstate, Node *node, */ bool has_a_cypher_list_comprehension_node(Node *expr) { - // return false on NULL input + /* return false on NULL input */ if (expr == NULL) { return false; } - // since this function recurses, it could be driven to stack overflow + /* since this function recurses, it could be driven to stack overflow */ check_stack_depth(); switch (nodeTag(expr)) @@ -96,7 +96,7 @@ bool has_a_cypher_list_comprehension_node(Node *expr) BoolExpr *bexpr = (BoolExpr *)expr; ListCell *lc; - // is any of the boolean expression argument a list comprehension? + /* is any of the boolean expression argument a list comprehension? */ foreach(lc, bexpr->args) { Node *arg = lfirst(lc); @@ -110,10 +110,10 @@ bool has_a_cypher_list_comprehension_node(Node *expr) } case T_A_Indirection: { - // set expr to the object of the indirection + /* set expr to the object of the indirection */ expr = ((A_Indirection *)expr)->arg; - // check the object of the indirection + /* check the object of the indirection */ return has_a_cypher_list_comprehension_node(expr); } case T_ExtensibleNode: @@ -122,7 +122,7 @@ bool has_a_cypher_list_comprehension_node(Node *expr) { cypher_unwind *cu = (cypher_unwind *)expr; - // it is a list comprehension if it has a collect node + /* it is a list comprehension if it has a collect node */ return cu->collect != NULL; } else if (is_ag_node(expr, cypher_map)) @@ -137,15 +137,15 @@ bool has_a_cypher_list_comprehension_node(Node *expr) return false; } - // check each key and value for a list comprehension + /* check each key and value for a list comprehension */ for (i = 0; i < map->keyvals->length; i += 2) { Node *val; - // get the value + /* get the value */ val = (Node *)map->keyvals->elements[i + 1].ptr_value; - // check the value + /* check the value */ if (has_a_cypher_list_comprehension_node(val)) { return true; @@ -156,7 +156,7 @@ bool has_a_cypher_list_comprehension_node(Node *expr) { cypher_string_match *csm_match = (cypher_string_match *)expr; - // is lhs or rhs of the string match a list comprehension? + /* is lhs or rhs of the string match a list comprehension? */ return (has_a_cypher_list_comprehension_node(csm_match->lhs) || has_a_cypher_list_comprehension_node(csm_match->rhs)); } @@ -164,14 +164,14 @@ bool has_a_cypher_list_comprehension_node(Node *expr) { cypher_typecast *ctypecast = (cypher_typecast *)expr; - // is expr being typecasted a list comprehension? + /* is expr being typecasted a list comprehension? */ return has_a_cypher_list_comprehension_node(ctypecast->expr); } else if (is_ag_node(expr, cypher_comparison_aexpr)) { cypher_comparison_aexpr *aexpr = (cypher_comparison_aexpr *)expr; - // is left or right argument a list comprehension? + /* is left or right argument a list comprehension? */ return (has_a_cypher_list_comprehension_node(aexpr->lexpr) || has_a_cypher_list_comprehension_node(aexpr->rexpr)); } @@ -180,7 +180,7 @@ bool has_a_cypher_list_comprehension_node(Node *expr) cypher_comparison_boolexpr *bexpr = (cypher_comparison_boolexpr *)expr; ListCell *lc; - // is any of the boolean expression argument a list comprehension? + /* is any of the boolean expression argument a list comprehension? */ foreach(lc, bexpr->args) { Node *arg = lfirst(lc); @@ -196,11 +196,11 @@ bool has_a_cypher_list_comprehension_node(Node *expr) default: break; } - // otherwise, return false + /* otherwise, return false */ return false; } -// see transformTargetList() +/* see transformTargetList() */ List *transform_cypher_item_list(cypher_parsestate *cpstate, List *item_list, List **groupClause, ParseExprKind expr_kind) { @@ -245,10 +245,10 @@ List *transform_cypher_item_list(cypher_parsestate *cpstate, List *item_list, } } - // Check if we have a list comprehension + /* Check if we have a list comprehension */ has_list_comp = has_a_cypher_list_comprehension_node(item->val); - // Clear the exprHasAgg flag to check transform for an aggregate + /* Clear the exprHasAgg flag to check transform for an aggregate */ cpstate->exprHasAgg = false; if (has_list_comp && item_list->length > 1) @@ -280,7 +280,7 @@ List *transform_cypher_item_list(cypher_parsestate *cpstate, List *item_list, } else { - // transform the item + /* transform the item */ te = transform_cypher_item(cpstate, item->val, NULL, expr_kind, item->name, false); @@ -339,15 +339,15 @@ List *transform_cypher_item_list(cypher_parsestate *cpstate, List *item_list, ColumnRef *cref = NULL; char *colname = NULL; - // get the name of the column (varname) + /* get the name of the column (varname) */ colname = strVal(lfirst(list_head(rte->eref->colnames))); - // create the ColumnRef + /* create the ColumnRef */ cref = makeNode(ColumnRef); cref->fields = list_make1(makeString(colname)); cref->location = -1; - // add the expression for grouping + /* add the expression for grouping */ group_clause = lappend(group_clause, cref); } } diff --git a/src/backend/parser/cypher_keywords.c b/src/backend/parser/cypher_keywords.c index dcc807e68..f7be0db0e 100644 --- a/src/backend/parser/cypher_keywords.c +++ b/src/backend/parser/cypher_keywords.c @@ -52,7 +52,7 @@ const uint16 CypherKeywordCategories[] = { PG_FUNCTION_INFO_V1(get_cypher_keywords); -// function to return the list of grammar keywords +/* function to return the list of grammar keywords */ Datum get_cypher_keywords(PG_FUNCTION_ARGS) { FuncCallContext *func_ctx; @@ -82,7 +82,7 @@ Datum get_cypher_keywords(PG_FUNCTION_ARGS) char *values[3]; HeapTuple tuple; - // cast-away-const is ugly but alternatives aren't much better + /* cast-away-const is ugly but alternatives aren't much better */ values[0] = (char *) GetScanKeyword((int) func_ctx->call_cntr, &CypherKeyword); @@ -105,7 +105,7 @@ Datum get_cypher_keywords(PG_FUNCTION_ARGS) values[2] = "reserved"; break; default: - // shouldn't be possible + /* shouldn't be possible */ values[1] = NULL; values[2] = NULL; break; diff --git a/src/backend/parser/cypher_parse_node.c b/src/backend/parser/cypher_parse_node.c index 2e5378b77..48c50d4fd 100644 --- a/src/backend/parser/cypher_parse_node.c +++ b/src/backend/parser/cypher_parse_node.c @@ -30,7 +30,7 @@ static void errpos_ecb(void *arg); -// NOTE: sync the logic with make_parsestate() +/* NOTE: sync the logic with make_parsestate() */ cypher_parsestate *make_cypher_parsestate(cypher_parsestate *parent_cpstate) { ParseState *parent_pstate = (ParseState *)parent_cpstate; diff --git a/src/backend/parser/cypher_transform_entity.c b/src/backend/parser/cypher_transform_entity.c index 5a2508c3c..1b2ab0edd 100644 --- a/src/backend/parser/cypher_transform_entity.c +++ b/src/backend/parser/cypher_transform_entity.c @@ -21,7 +21,7 @@ #include "parser/cypher_transform_entity.h" -// creates a transform entity +/* creates a transform entity */ transform_entity *make_transform_entity(cypher_parsestate *cpstate, enum transform_entity_type type, Node *node, Expr *expr) @@ -153,7 +153,7 @@ transform_entity *find_variable(cypher_parsestate *cpstate, char *name) return NULL; } -// helper function that extracts the name associated with the transform_entity. +/* helper function that extracts the name associated with the transform_entity. */ char *get_entity_name(transform_entity *entity) { if (entity->type == ENT_EDGE || entity->type == ENT_VLE_EDGE) diff --git a/src/backend/utils/adt/agtype.c b/src/backend/utils/adt/agtype.c index cbcacdc78..5925c0c62 100644 --- a/src/backend/utils/adt/agtype.c +++ b/src/backend/utils/adt/agtype.c @@ -1381,7 +1381,8 @@ static void agtype_categorize_type(Oid typoid, agt_type_category *tcategory, { *tcategory = AGT_TYPE_ARRAY; } - else if (type_is_rowtype(typoid)) /* includes RECORDOID */ + /* includes RECORDOID */ + else if (type_is_rowtype(typoid)) { *tcategory = AGT_TYPE_COMPOSITE; } @@ -1862,7 +1863,8 @@ static void composite_to_agtype(Datum composite, agtype_in_state *result) */ void remove_null_from_agtype_object(agtype_value *object) { - agtype_pair *avail; // next available position + /* next available position */ + agtype_pair *avail; agtype_pair *ptr; if (object->type != AGTV_OBJECT) @@ -4376,7 +4378,7 @@ Datum agtype_string_match_contains(PG_FUNCTION_ARGS) #define LEFT_ROTATE(n, i) ((n << i) | (n >> (64 - i))) #define RIGHT_ROTATE(n, i) ((n >> i) | (n << (64 - i))) -//Hashing Function for Hash Indexes +/* Hashing Function for Hash Indexes */ PG_FUNCTION_INFO_V1(agtype_hash_cmp); Datum agtype_hash_cmp(PG_FUNCTION_ARGS) @@ -4418,7 +4420,7 @@ Datum agtype_hash_cmp(PG_FUNCTION_ARGS) PG_RETURN_INT32(hash); } -// Comparison function for btree Indexes +/* Comparison function for btree Indexes */ PG_FUNCTION_INFO_V1(agtype_btree_cmp); Datum agtype_btree_cmp(PG_FUNCTION_ARGS) @@ -5841,7 +5843,7 @@ Datum age_tobooleanlist(PG_FUNCTION_ARGS) /* iterate through the list */ for (i = 0; i < count; i++) { - // check element's type, it's value, and convert it to boolean if possible. + /* check element's type, it's value, and convert it to boolean if possible. */ elem = get_ith_agtype_value_from_container(&agt_arg->root, i); bool_elem.type = AGTV_BOOL; @@ -6090,7 +6092,7 @@ Datum age_tofloatlist(PG_FUNCTION_ARGS) /* iterate through the list */ for (i = 0; i < count; i++) { - // TODO: check element's type, it's value, and convert it to float if possible. + /* TODO: check element's type, it's value, and convert it to float if possible. */ elem = get_ith_agtype_value_from_container(&agt_arg->root, i); float_elem.type = AGTV_FLOAT; @@ -6418,7 +6420,7 @@ Datum age_tointegerlist(PG_FUNCTION_ARGS) /* iterate through the list */ for (i = 0; i < count; i++) { - // TODO: check element's type, it's value, and convert it to integer if possible. + /* TODO: check element's type, it's value, and convert it to integer if possible. */ elem = get_ith_agtype_value_from_container(&agt_arg->root, i); integer_elem.type = AGTV_INTEGER; @@ -6766,7 +6768,7 @@ Datum age_label(PG_FUNCTION_ARGS) /* get the argument */ agt_arg = AG_GET_ARG_AGTYPE_P(0); - // edges and vertices are considered scalars + /* edges and vertices are considered scalars */ if (!AGT_ROOT_IS_SCALAR(agt_arg)) { if (AGTE_IS_NULL(agt_arg->root.children[0])) @@ -6779,7 +6781,7 @@ Datum age_label(PG_FUNCTION_ARGS) agtv_value = get_ith_agtype_value_from_container(&agt_arg->root, 0); - // fail if agtype value isn't an edge or vertex + /* fail if agtype value isn't an edge or vertex */ if (agtv_value->type != AGTV_VERTEX && agtv_value->type != AGTV_EDGE) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -6787,7 +6789,7 @@ Datum age_label(PG_FUNCTION_ARGS) } - // extract the label agtype value from the vertex or edge + /* extract the label agtype value from the vertex or edge */ label = GET_AGTYPE_VALUE_OBJECT_VALUE(agtv_value, "label"); PG_RETURN_POINTER(agtype_value_to_agtype(label)); @@ -7042,7 +7044,7 @@ Datum age_tostringlist(PG_FUNCTION_ARGS) /* iterate through the list */ for (i = 0; i < count; i++) { - // TODO: check element's type, it's value, and convert it to string if possible. + /* TODO: check element's type, it's value, and convert it to string if possible. */ elem = get_ith_agtype_value_from_container(&agt_arg->root, i); string_elem.type = AGTV_STRING; @@ -9790,7 +9792,7 @@ agtype_value *agtype_composite_to_agtype_value_binary(agtype *a) result = palloc(sizeof(agtype_value)); - // convert the agtype to a binary agtype_value + /* convert the agtype to a binary agtype_value */ result->type = AGTV_BINARY; result->val.binary.len = AGTYPE_CONTAINER_SIZE(&a->root); result->val.binary.data = &a->root; @@ -9815,13 +9817,13 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, agtype_value *parsed_agtype_value = NULL; bool found; - // if no properties, return NULL + /* if no properties, return NULL */ if (properties == NULL) { return NULL; } - // if properties is not an object, throw an error + /* if properties is not an object, throw an error */ if (properties->type != AGTV_OBJECT) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -9867,11 +9869,11 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, */ if (strcmp(str, var_name)) { - // push the key + /* push the key */ parsed_agtype_value = push_agtype_value( &parse_state, tok, tok < WAGT_BEGIN_ARRAY ? r : NULL); - // get the value and push the value + /* get the value and push the value */ tok = agtype_iterator_next(&it, r, true); parsed_agtype_value = push_agtype_value(&parse_state, tok, r); } @@ -9879,19 +9881,19 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, { agtype_value *new_agtype_value_v; - // if the remove flag is set, don't push the key or any value + /* if the remove flag is set, don't push the key or any value */ if(remove_property) { - // skip the value + /* skip the value */ tok = agtype_iterator_next(&it, r, true); continue; } - // push the key + /* push the key */ parsed_agtype_value = push_agtype_value( &parse_state, tok, tok < WAGT_BEGIN_ARRAY ? r : NULL); - // skip the existing value for the key + /* skip the existing value for the key */ tok = agtype_iterator_next(&it, r, true); /* @@ -9903,7 +9905,7 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, */ if (AGTYPE_CONTAINER_IS_SCALAR(&new_v->root)) { - //get the scalar value and push as the value + /* get the scalar value and push as the value */ new_agtype_value_v = get_ith_agtype_value_from_container(&new_v->root, 0); parsed_agtype_value = push_agtype_value(&parse_state, WAGT_VALUE, new_agtype_value_v); @@ -9928,7 +9930,7 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, agtype_value *new_agtype_value_v; agtype_value *key = string_to_agtype_value(var_name); - // push the new key + /* push the new key */ parsed_agtype_value = push_agtype_value( &parse_state, WAGT_KEY, key); @@ -9943,7 +9945,7 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, { new_agtype_value_v = get_ith_agtype_value_from_container(&new_v->root, 0); - // convert the agtype array or object to a binary agtype_value + /* convert the agtype array or object to a binary agtype_value */ parsed_agtype_value = push_agtype_value(&parse_state, WAGT_VALUE, new_agtype_value_v); } else @@ -9954,7 +9956,7 @@ agtype_value *alter_property_value(agtype_value *properties, char *var_name, } } - // push the end object token to parse state + /* push the end object token to parse state */ parsed_agtype_value = push_agtype_value(&parse_state, WAGT_END_OBJECT, NULL); return parsed_agtype_value; @@ -9980,7 +9982,7 @@ agtype_value *alter_properties(agtype_value *original_properties, parsed_agtype_value = push_agtype_value(&parse_state, WAGT_BEGIN_OBJECT, NULL); - // Copy original properties. + /* Copy original properties. */ if (original_properties) { if (original_properties->type != AGTV_OBJECT) @@ -9993,7 +9995,7 @@ agtype_value *alter_properties(agtype_value *original_properties, &parsed_agtype_value, true); } - // Append new properties. + /* Append new properties. */ key = palloc0(sizeof(agtype_value)); value = palloc0(sizeof(agtype_value)); it = agtype_iterator_init(&new_properties->root); @@ -11100,7 +11102,7 @@ Datum age_keys(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - //needs to be a map, node, or relationship + /* needs to be a map, node, or relationship */ agt_arg = AG_GET_ARG_AGTYPE_P(0); /* diff --git a/src/backend/utils/adt/agtype_ext.c b/src/backend/utils/adt/agtype_ext.c index 29cf40bbf..8fc6600d1 100644 --- a/src/backend/utils/adt/agtype_ext.c +++ b/src/backend/utils/adt/agtype_ext.c @@ -190,7 +190,7 @@ static void ag_deserialize_composite(char *base, enum agtype_value_type type, agtype_parse_state *parse_state = NULL; agtype_value *r = NULL; agtype_value *parsed_agtype_value = NULL; - //offset container by the extended type header + /* offset container by the extended type header */ char *container_base = base + AGT_HEADER_SIZE; r = palloc(sizeof(agtype_value)); diff --git a/src/backend/utils/adt/agtype_ops.c b/src/backend/utils/adt/agtype_ops.c index e9a69d5cc..c6c13aadb 100644 --- a/src/backend/utils/adt/agtype_ops.c +++ b/src/backend/utils/adt/agtype_ops.c @@ -283,13 +283,13 @@ static agtype *delete_from_array(agtype *agt, agtype *indexes) "using integer index"))); } - // array is empty, pass the original array + /* array is empty, pass the original array */ if (AGT_ROOT_COUNT(agt) == 0) { return agt; } - // start buidiling the result agtype array + /* start buidiling the result agtype array */ it = agtype_iterator_init(&agt->root); r = agtype_iterator_next(&it, &v, false); @@ -329,7 +329,7 @@ static agtype *delete_from_array(agtype *agt, agtype *indexes) it_indexes = agtype_iterator_init(&indexes->root); contains_idx = agtype_deep_contains(&it_indexes, &it_cur_idx, false); - // re-initialize indexes array iterator + /* re-initialize indexes array iterator */ it_indexes = agtype_iterator_init(&indexes->root); contains_neg_idx = agtype_deep_contains(&it_indexes, &it_neg_idx, false); diff --git a/src/backend/utils/adt/agtype_raw.c b/src/backend/utils/adt/agtype_raw.c index f54068069..e7270ef84 100644 --- a/src/backend/utils/adt/agtype_raw.c +++ b/src/backend/utils/adt/agtype_raw.c @@ -26,9 +26,9 @@ */ struct agtype_build_state { - int a_offset; // next location to write agtentry - int i; // index of current agtentry being processed - int d_start; // start of variable-length portion + int a_offset; /* next location to write agtentry */ + int i; /* index of current agtentry being processed */ + int d_start; /* start of variable-length portion */ StringInfo buffer; }; @@ -127,16 +127,16 @@ agtype_build_state *init_agtype_build_state(uint32 size, uint32 header_flag) bstate->a_offset = 0; bstate->i = 0; - // reserve for varlen header + /* reserve for varlen header */ BUFFER_RESERVE(VARHDRSZ); bstate->a_offset += VARHDRSZ; - // write container header + /* write container header */ BUFFER_RESERVE(sizeof(uint32)); BUFFER_WRITE_CONST(bstate->a_offset, uint32, header_flag | size); bstate->a_offset += sizeof(uint32); - // reserve for agtentry headers + /* reserve for agtentry headers */ if ((header_flag & AGT_FOBJECT) != 0) { agtentry_count = size * 2; @@ -190,18 +190,18 @@ void write_graphid(agtype_build_state *bstate, graphid graphid) { int length = 0; - // padding + /* padding */ length += BUFFER_WRITE_PAD(); - // graphid header + /* graphid header */ write_const(AGT_HEADER_INTEGER, AGT_HEADER_TYPE); length += AGT_HEADER_SIZE; - // graphid value + /* graphid value */ write_const(graphid, int64); length += sizeof(int64); - // agtentry + /* agtentry */ write_agt(AGTENTRY_IS_AGTYPE | length); bstate->i++; @@ -211,13 +211,13 @@ void write_container(agtype_build_state *bstate, agtype *agtype) { int length = 0; - // padding + /* padding */ length += BUFFER_WRITE_PAD(); - // varlen data + /* varlen data */ length += write_ptr((char *) &agtype->root, VARSIZE(agtype)); - // agtentry + /* agtentry */ write_agt(AGTENTRY_IS_CONTAINER | length); bstate->i++; @@ -231,17 +231,17 @@ void write_extended(agtype_build_state *bstate, agtype *val, uint32 header) { int length = 0; - // padding + /* padding */ length += BUFFER_WRITE_PAD(); - // vertex header + /* vertex header */ write_const(header, AGT_HEADER_TYPE); length += AGT_HEADER_SIZE; - // vertex data + /* vertex data */ length += write_ptr((char *) &val->root, VARSIZE(val)); - // agtentry + /* agtentry */ write_agt(AGTENTRY_IS_AGTYPE | length); bstate->i++; diff --git a/src/backend/utils/adt/agtype_util.c b/src/backend/utils/adt/agtype_util.c index eef916fdc..89aedeace 100644 --- a/src/backend/utils/adt/agtype_util.c +++ b/src/backend/utils/adt/agtype_util.c @@ -1218,7 +1218,7 @@ bool agtype_deep_contains(agtype_iterator **val, Assert(lhs_val->type == AGTV_BINARY); Assert(vcontained.type == AGTV_BINARY); - // We will just check if the rhs value is equal to lhs + /* We will just check if the rhs value is equal to lhs */ if (compare_agtype_containers_orderability( lhs_val->val.binary.data, vcontained.val.binary.data) != 0) @@ -2338,7 +2338,7 @@ void pfree_agtype_value_content(agtype_value* value) { int i; - // guards against stack overflow due to deeply nested agtype_value + /* guards against stack overflow due to deeply nested agtype_value */ check_stack_depth(); switch (value->type) diff --git a/src/backend/utils/adt/graphid.c b/src/backend/utils/adt/graphid.c index 7082fed0e..71f41093b 100644 --- a/src/backend/utils/adt/graphid.c +++ b/src/backend/utils/adt/graphid.c @@ -65,7 +65,7 @@ void clear_global_Oids_GRAPHID(void) PG_FUNCTION_INFO_V1(graphid_in); -// graphid type input function +/* graphid type input function */ Datum graphid_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); @@ -86,11 +86,11 @@ Datum graphid_in(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(graphid_out); -// graphid type output function +/* graphid type output function */ Datum graphid_out(PG_FUNCTION_ARGS) { graphid gid = AG_GETARG_GRAPHID(0); - char buf[32]; // greater than MAXINT8LEN+1 + char buf[32]; /* greater than MAXINT8LEN+1 */ char *out; pg_lltoa(gid, buf); @@ -252,13 +252,13 @@ Datum _graphid(PG_FUNCTION_ARGS) AG_RETURN_GRAPHID(gid); } -//Hashing Function for Hash Indexes +/* Hashing Function for Hash Indexes */ PG_FUNCTION_INFO_V1(graphid_hash_cmp); Datum graphid_hash_cmp(PG_FUNCTION_ARGS) { graphid l = AG_GETARG_GRAPHID(0); - int hash = (int) ((l >> 32) ^ l);// ^ seed; + int hash = (int) ((l >> 32) ^ l);/* ^ seed; */ PG_RETURN_INT32(hash); } diff --git a/src/backend/utils/ag_func.c b/src/backend/utils/ag_func.c index 3040e44b8..1762286c3 100644 --- a/src/backend/utils/ag_func.c +++ b/src/backend/utils/ag_func.c @@ -33,7 +33,7 @@ #include "catalog/ag_namespace.h" #include "utils/ag_func.h" -// checks that func_oid is of func_name function in ag_catalog +/* checks that func_oid is of func_name function in ag_catalog */ bool is_oid_ag_func(Oid func_oid, const char *func_name) { HeapTuple proctup; @@ -61,7 +61,7 @@ bool is_oid_ag_func(Oid func_oid, const char *func_name) return (strcmp(nspname, "ag_catalog") == 0); } -// gets the function OID that matches with func_name and argument types +/* gets the function OID that matches with func_name and argument types */ Oid get_ag_func_oid(const char *func_name, const int nargs, ...) { Oid oids[FUNC_MAX_ARGS]; diff --git a/src/backend/utils/cache/ag_cache.c b/src/backend/utils/cache/ag_cache.c index 92f795848..e3c4d0794 100644 --- a/src/backend/utils/cache/ag_cache.c +++ b/src/backend/utils/cache/ag_cache.c @@ -32,13 +32,13 @@ typedef struct graph_name_cache_entry { - NameData name; // hash key + NameData name; /* hash key */ graph_cache_data data; } graph_name_cache_entry; typedef struct graph_namespace_cache_entry { - Oid namespace; // hash key + Oid namespace; /* hash key */ graph_cache_data data; } graph_namespace_cache_entry; @@ -50,7 +50,7 @@ typedef struct label_name_graph_cache_key typedef struct label_name_graph_cache_entry { - label_name_graph_cache_key key; // hash key + label_name_graph_cache_key key; /* hash key */ label_cache_data data; } label_name_graph_cache_entry; @@ -62,13 +62,13 @@ typedef struct label_graph_oid_cache_key typedef struct label_graph_oid_cache_entry { - label_graph_oid_cache_key key; // hash key + label_graph_oid_cache_key key; /* hash key */ label_cache_data data; } label_graph_oid_cache_entry; typedef struct label_relation_cache_entry { - Oid relation; // hash key + Oid relation; /* hash key */ label_cache_data data; } label_relation_cache_entry; @@ -80,43 +80,43 @@ typedef struct label_seq_name_graph_cache_key typedef struct label_seq_name_graph_cache_entry { - label_seq_name_graph_cache_key key; // hash key + label_seq_name_graph_cache_key key; /* hash key */ label_cache_data data; } label_seq_name_graph_cache_entry; -// ag_graph.name +/* ag_graph.name */ static HTAB *graph_name_cache_hash = NULL; static ScanKeyData graph_name_scan_keys[1]; -// ag_graph.namespace +/* ag_graph.namespace */ static HTAB *graph_namespace_cache_hash = NULL; static ScanKeyData graph_namespace_scan_keys[1]; -// ag_label.name, ag_label.graph +/* ag_label.name, ag_label.graph */ static HTAB *label_name_graph_cache_hash = NULL; static ScanKeyData label_name_graph_scan_keys[2]; -// ag_label.graph, ag_label.id +/* ag_label.graph, ag_label.id */ static HTAB *label_graph_oid_cache_hash = NULL; static ScanKeyData label_graph_oid_scan_keys[2]; -// ag_label.relation +/* ag_label.relation */ static HTAB *label_relation_cache_hash = NULL; static ScanKeyData label_relation_scan_keys[1]; -// ag_label.seq_name, ag_label.graph +/* ag_label.seq_name, ag_label.graph */ static HTAB *label_seq_name_graph_cache_hash = NULL; static ScanKeyData label_seq_name_graph_scan_keys[2]; -// initialize all caches +/* initialize all caches */ static void initialize_caches(void); -// common +/* common */ static void ag_cache_scan_key_init(ScanKey entry, AttrNumber attno, RegProcedure func); static int name_hash_compare(const void *key1, const void *key2, Size keysize); -// ag_graph +/* ag_graph */ static void initialize_graph_caches(void); static void create_graph_caches(void); static void create_graph_name_cache(void); @@ -130,7 +130,7 @@ static graph_cache_data *search_graph_namespace_cache_miss(Oid namespace); static void fill_graph_cache_data(graph_cache_data *cache_data, HeapTuple tuple, TupleDesc tuple_desc); -// ag_label +/* ag_label */ static void initialize_label_caches(void); static void create_label_caches(void); static void create_label_name_graph_cache(void); @@ -201,7 +201,7 @@ static int name_hash_compare(const void *key1, const void *key2, Size keysize) Name name1 = (Name)key1; Name name2 = (Name)key2; - // keysize parameter is superfluous here + /* keysize parameter is superfluous here */ Assert(keysize == NAMEDATALEN); return strncmp(NameStr(*name1), NameStr(*name2), NAMEDATALEN); @@ -209,11 +209,11 @@ static int name_hash_compare(const void *key1, const void *key2, Size keysize) static void initialize_graph_caches(void) { - // ag_graph.name + /* ag_graph.name */ ag_cache_scan_key_init(&graph_name_scan_keys[0], Anum_ag_graph_name, F_NAMEEQ); - // ag_graph.namespace + /* ag_graph.namespace */ ag_cache_scan_key_init(&graph_namespace_scan_keys[0], Anum_ag_graph_namespace, F_OIDEQ); @@ -374,7 +374,7 @@ static graph_cache_data *search_graph_name_cache_miss(Name name) scan_desc = systable_beginscan(ag_graph, ag_graph_name_index_id(), true, NULL, 1, scan_keys); - // don't need to loop over scan_desc because ag_graph_name_index is UNIQUE + /* don't need to loop over scan_desc because ag_graph_name_index is UNIQUE */ tuple = systable_getnext(scan_desc); if (!HeapTupleIsValid(tuple)) { @@ -384,11 +384,11 @@ static graph_cache_data *search_graph_name_cache_miss(Name name) return NULL; } - // get a new entry + /* get a new entry */ entry = hash_search(graph_name_cache_hash, name, HASH_ENTER, &found); - Assert(!found); // no concurrent update on graph_name_cache_hash + Assert(!found); /* no concurrent update on graph_name_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_graph_cache_data(&entry->data, tuple, RelationGetDescr(ag_graph)); systable_endscan(scan_desc); @@ -435,8 +435,8 @@ static graph_cache_data *search_graph_namespace_cache_miss(Oid namespace) scan_desc = systable_beginscan(ag_graph, ag_graph_namespace_index_id(), true, NULL, 1, scan_keys); - // don't need to loop over scan_desc because ag_graph_namespace_index is - // UNIQUE + /* don't need to loop over scan_desc because ag_graph_namespace_index is */ + /* UNIQUE */ tuple = systable_getnext(scan_desc); if (!HeapTupleIsValid(tuple)) { @@ -446,12 +446,12 @@ static graph_cache_data *search_graph_namespace_cache_miss(Oid namespace) return NULL; } - // get a new entry + /* get a new entry */ entry = hash_search(graph_namespace_cache_hash, &namespace, HASH_ENTER, &found); - Assert(!found); // no concurrent update on graph_namespace_cache_hash + Assert(!found); /* no concurrent update on graph_namespace_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_graph_cache_data(&entry->data, tuple, RelationGetDescr(ag_graph)); systable_endscan(scan_desc); @@ -467,17 +467,17 @@ static void fill_graph_cache_data(graph_cache_data *cache_data, Datum value; Name name; - // ag_graph.id + /* ag_graph.id */ value = heap_getattr(tuple, Anum_ag_graph_oid, tuple_desc, &is_null); Assert(!is_null); cache_data->oid = DatumGetObjectId(value); - // ag_graph.name + /* ag_graph.name */ value = heap_getattr(tuple, Anum_ag_graph_name, tuple_desc, &is_null); Assert(!is_null); name = DatumGetName(value); Assert(name != NULL); namestrcpy(&cache_data->name, name->data); - // ag_graph.namespace + /* ag_graph.namespace */ value = heap_getattr(tuple, Anum_ag_graph_namespace, tuple_desc, &is_null); Assert(!is_null); cache_data->namespace = DatumGetObjectId(value); @@ -485,35 +485,35 @@ static void fill_graph_cache_data(graph_cache_data *cache_data, static void initialize_label_caches(void) { - // ag_label.name, ag_label.graph + /* ag_label.name, ag_label.graph */ ag_cache_scan_key_init(&label_name_graph_scan_keys[0], Anum_ag_label_name, F_NAMEEQ); ag_cache_scan_key_init(&label_name_graph_scan_keys[1], Anum_ag_label_graph, F_INT4EQ); - // ag_label.graph, ag_label.id + /* ag_label.graph, ag_label.id */ ag_cache_scan_key_init(&label_graph_oid_scan_keys[0], Anum_ag_label_graph, F_INT4EQ); ag_cache_scan_key_init(&label_graph_oid_scan_keys[1], Anum_ag_label_id, F_INT4EQ); - // ag_label.relation + /* ag_label.relation */ ag_cache_scan_key_init(&label_relation_scan_keys[0], Anum_ag_label_relation, F_OIDEQ); - // ag_label.seq_name, ag_label.graph + /* ag_label.seq_name, ag_label.graph */ ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[0], Anum_ag_label_seq_name, F_NAMEEQ); ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[1], Anum_ag_label_graph, F_OIDEQ); - // ag_label.seq_name, ag_label.graph + /* ag_label.seq_name, ag_label.graph */ ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[0], Anum_ag_label_seq_name, F_NAMEEQ); ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[1], Anum_ag_label_graph, F_OIDEQ); - // ag_label.seq_name, ag_label.graph + /* ag_label.seq_name, ag_label.graph */ ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[0], Anum_ag_label_seq_name, F_NAMEEQ); ag_cache_scan_key_init(&label_seq_name_graph_scan_keys[1], @@ -902,12 +902,12 @@ static label_cache_data *search_label_name_graph_cache_miss(Name name, return NULL; } - // get a new entry + /* get a new entry */ entry = label_name_graph_cache_hash_search(name, graph, HASH_ENTER, &found); - Assert(!found); // no concurrent update on label_name_graph_cache_hash + Assert(!found); /* no concurrent update on label_name_graph_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_label_cache_data(&entry->data, tuple, RelationGetDescr(ag_label)); systable_endscan(scan_desc); @@ -921,7 +921,7 @@ static void *label_name_graph_cache_hash_search(Name name, Oid graph, { label_name_graph_cache_key key; - // initialize the hash key for label_name_graph_cache_hash + /* initialize the hash key for label_name_graph_cache_hash */ namestrcpy(&key.name, name->data); key.graph = graph; @@ -980,11 +980,11 @@ static label_cache_data *search_label_graph_oid_cache_miss(Oid graph, uint32 id) return NULL; } - // get a new entry + /* get a new entry */ entry = label_graph_oid_cache_hash_search(graph, id, HASH_ENTER, &found); - Assert(!found); // no concurrent update on label_graph_oid_cache_hash + Assert(!found); /* no concurrent update on label_graph_oid_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_label_cache_data(&entry->data, tuple, RelationGetDescr(ag_label)); systable_endscan(scan_desc); @@ -998,7 +998,7 @@ static void *label_graph_oid_cache_hash_search(uint32 graph, int32 id, { label_graph_oid_cache_key key; - // initialize the hash key for label_graph_oid_cache_hash + /* initialize the hash key for label_graph_oid_cache_hash */ key.graph = graph; key.id = id; @@ -1041,8 +1041,8 @@ static label_cache_data *search_label_relation_cache_miss(Oid relation) scan_desc = systable_beginscan(ag_label, ag_label_relation_index_id(), true, NULL, 1, scan_keys); - // don't need to loop over scan_desc because ag_label_relation_index is - // UNIQUE + /* don't need to loop over scan_desc because ag_label_relation_index is */ + /* UNIQUE */ tuple = systable_getnext(scan_desc); if (!HeapTupleIsValid(tuple)) { @@ -1052,12 +1052,12 @@ static label_cache_data *search_label_relation_cache_miss(Oid relation) return NULL; } - // get a new entry + /* get a new entry */ entry = hash_search(label_relation_cache_hash, &relation, HASH_ENTER, &found); - Assert(!found); // no concurrent update on label_relation_cache_hash + Assert(!found); /* no concurrent update on label_relation_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_label_cache_data(entry, tuple, RelationGetDescr(ag_label)); systable_endscan(scan_desc); @@ -1123,12 +1123,12 @@ static label_cache_data *search_label_seq_name_graph_cache_miss(Name name, return NULL; } - // get a new entry + /* get a new entry */ entry = label_seq_name_graph_cache_hash_search(name, graph, HASH_ENTER, &found); - Assert(!found); // no concurrent update on label_seq_name_graph_cache_hash + Assert(!found); /* no concurrent update on label_seq_name_graph_cache_hash */ - // fill the new entry with the retrieved tuple + /* fill the new entry with the retrieved tuple */ fill_label_cache_data(&entry->data, tuple, RelationGetDescr(ag_label)); systable_endscan(scan_desc); @@ -1143,7 +1143,7 @@ static void *label_seq_name_graph_cache_hash_search(Name name, Oid graph, { label_seq_name_graph_cache_key key; - // initialize the hash key for label_seq_name_graph_cache_hash + /* initialize the hash key for label_seq_name_graph_cache_hash */ namestrcpy(&key.name, name->data); key.graph = graph; @@ -1157,29 +1157,29 @@ static void fill_label_cache_data(label_cache_data *cache_data, Datum value; Name name; - // ag_label.name + /* ag_label.name */ value = heap_getattr(tuple, Anum_ag_label_name, tuple_desc, &is_null); Assert(!is_null); name = DatumGetName(value); Assert(name != NULL); namestrcpy(&cache_data->name, name->data); - // ag_label.graph + /* ag_label.graph */ value = heap_getattr(tuple, Anum_ag_label_graph, tuple_desc, &is_null); Assert(!is_null); cache_data->graph = DatumGetObjectId(value); - // ag_label.id + /* ag_label.id */ value = heap_getattr(tuple, Anum_ag_label_id, tuple_desc, &is_null); Assert(!is_null); cache_data->id = DatumGetInt32(value); - // ag_label.kind + /* ag_label.kind */ value = heap_getattr(tuple, Anum_ag_label_kind, tuple_desc, &is_null); Assert(!is_null); cache_data->kind = DatumGetChar(value); - // ag_label.relation + /* ag_label.relation */ value = heap_getattr(tuple, Anum_ag_label_relation, tuple_desc, &is_null); Assert(!is_null); cache_data->relation = DatumGetObjectId(value); - // ag_label.seq_name + /* ag_label.seq_name */ value = heap_getattr(tuple, Anum_ag_label_seq_name, tuple_desc, &is_null); Assert(!is_null); namestrcpy(&cache_data->seq_name, DatumGetName(value)->data); diff --git a/src/backend/utils/graph_generation.c b/src/backend/utils/graph_generation.c index f84031c79..ea8e1bd5b 100644 --- a/src/backend/utils/graph_generation.c +++ b/src/backend/utils/graph_generation.c @@ -119,7 +119,7 @@ Datum create_complete_graph(PG_FUNCTION_ARGS) vtx_label_name = PG_GETARG_NAME(3); vtx_name_str = NameStr(*vtx_label_name); - // Check if vertex and edge label are same + /* Check if vertex and edge label are same */ if (strcmp(vtx_name_str, edge_name_str) == 0) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -136,7 +136,7 @@ Datum create_complete_graph(PG_FUNCTION_ARGS) if (!PG_ARGISNULL(3)) { - // Check if label with the input name already exists + /* Check if label with the input name already exists */ if (!label_exists(vtx_name_str, graph_oid)) { DirectFunctionCall2(create_vlabel, @@ -256,8 +256,8 @@ Datum age_create_barbell_graph(PG_FUNCTION_ARGS) arguments = fcinfo; - // Checking for possible NULL arguments - // Name graph_name + /* Checking for possible NULL arguments */ + /* Name graph_name */ if (PG_ARGISNULL(0)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -267,7 +267,7 @@ Datum age_create_barbell_graph(PG_FUNCTION_ARGS) graph_name = PG_GETARG_NAME(0); graph_name_str = NameStr(*graph_name); - // int graph size (number of nodes in each complete graph) + /* int graph size (number of nodes in each complete graph) */ if (PG_ARGISNULL(1) && PG_GETARG_INT32(1) < 3) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -284,7 +284,7 @@ Datum age_create_barbell_graph(PG_FUNCTION_ARGS) errmsg("Bridge size cannot be NULL or lower than 0"))); } - // node label: if null, gets default label, which is "_ag_label_vertex" + /* node label: if null, gets default label, which is "_ag_label_vertex" */ if (PG_ARGISNULL(3)) { namestrcpy(node_label_name, AG_DEFAULT_LABEL_VERTEX); @@ -306,7 +306,7 @@ Datum age_create_barbell_graph(PG_FUNCTION_ARGS) edge_label_str = NameStr(*edge_label_name); - // create two separate complete graphs + /* create two separate complete graphs */ DirectFunctionCall4(create_complete_graph, arguments->args[0].value, arguments->args[1].value, arguments->args[5].value, @@ -327,20 +327,22 @@ Datum age_create_barbell_graph(PG_FUNCTION_ARGS) graph_cache = search_graph_name_cache(graph_name_str); edge_cache = search_label_name_graph_cache(edge_label_str,graph_oid); - // connect a node from each graph - start_node_index = 1; // first created node, from the first complete graph - end_node_index = arguments->args[1].value*2; // last created node, second graph + /* connect a node from each graph */ + /* first created node, from the first complete graph */ + start_node_index = 1; + /* last created node, second graph */ + end_node_index = arguments->args[1].value*2; - // next index to be assigned to a node or edge + /* next index to be assigned to a node or edge */ nextval = get_nextval_internal(graph_cache, edge_cache); - // build the graph id's of the edge to be created + /* build the graph id's of the edge to be created */ object_graph_id = make_graphid(edge_label_id, nextval); start_node_graph_id = make_graphid(node_label_id, start_node_index); end_node_graph_id = make_graphid(node_label_id, end_node_index); properties = create_empty_agtype(); - // connect two nodes + /* connect two nodes */ insert_edge_simple(graph_oid, edge_label_str, object_graph_id, start_node_graph_id, end_node_graph_id, properties); diff --git a/src/backend/utils/load/ag_load_edges.c b/src/backend/utils/load/ag_load_edges.c index 5a07c4035..d516d334f 100644 --- a/src/backend/utils/load/ag_load_edges.c +++ b/src/backend/utils/load/ag_load_edges.c @@ -33,7 +33,7 @@ void edge_field_cb(void *field, size_t field_len, void *data) ereport(NOTICE,(errmsg("There is some unknown error"))); } - // check for space to store this field + /* check for space to store this field */ if (cr->cur_field == cr->alloc) { cr->alloc *= 2; @@ -53,7 +53,7 @@ void edge_field_cb(void *field, size_t field_len, void *data) cr->cur_field += 1; } -// Parser calls this function when it detects end of a row +/* Parser calls this function when it detects end of a row */ void edge_row_cb(int delim __attribute__((unused)), void *data) { diff --git a/src/backend/utils/load/ag_load_labels.c b/src/backend/utils/load/ag_load_labels.c index f7fc6ff07..137734fe5 100644 --- a/src/backend/utils/load/ag_load_labels.c +++ b/src/backend/utils/load/ag_load_labels.c @@ -33,7 +33,7 @@ void vertex_field_cb(void *field, size_t field_len, void *data) ereport(NOTICE,(errmsg("There is some unknown error"))); } - // check for space to store this field + /* check for space to store this field */ if (cr->cur_field == cr->alloc) { cr->alloc *= 2; diff --git a/src/backend/utils/load/age_load.c b/src/backend/utils/load/age_load.c index a1eea48d0..60dbf9941 100644 --- a/src/backend/utils/load/age_load.c +++ b/src/backend/utils/load/age_load.c @@ -145,7 +145,7 @@ void insert_edge_simple(Oid graph_oid, char *label_name, graphid edge_id, Relation label_relation; HeapTuple tuple; - // Check if label provided exists as vertex label, then throw error + /* Check if label provided exists as vertex label, then throw error */ if (get_label_kind(label_name, graph_oid) == LABEL_KIND_VERTEX) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -177,7 +177,7 @@ void insert_vertex_simple(Oid graph_oid, char *label_name, graphid vertex_id, Relation label_relation; HeapTuple tuple; - // Check if label provided exists as edge label, then throw error + /* Check if label provided exists as edge label, then throw error */ if (get_label_kind(label_name, graph_oid) == LABEL_KIND_EDGE) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), diff --git a/src/backend/utils/load/libcsv.c b/src/backend/utils/load/libcsv.c index c17304caa..f0e8b46be 100644 --- a/src/backend/utils/load/libcsv.c +++ b/src/backend/utils/load/libcsv.c @@ -22,7 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #if __STDC_VERSION__ >= 199901L # include #else -# define SIZE_MAX ((size_t)-1) /* C89 doesn't have stdint.h or SIZE_MAX */ + /* C89 doesn't have stdint.h or SIZE_MAX */ +# define SIZE_MAX ((size_t)-1) #endif #include "utils/load/csv.h" diff --git a/src/include/executor/cypher_utils.h b/src/include/executor/cypher_utils.h index 5a8812ab0..0798f153c 100644 --- a/src/include/executor/cypher_utils.h +++ b/src/include/executor/cypher_utils.h @@ -25,7 +25,7 @@ #include "nodes/cypher_nodes.h" #include "utils/agtype.h" -// declaration of a useful postgres macro that isn't in a header file +/* declaration of a useful postgres macro that isn't in a header file */ #define DatumGetItemPointer(X) ((ItemPointer) DatumGetPointer(X)) #define ItemPointerGetDatum(X) PointerGetDatum(X) diff --git a/src/include/nodes/ag_nodes.h b/src/include/nodes/ag_nodes.h index 84f541546..fe9c9663e 100644 --- a/src/include/nodes/ag_nodes.h +++ b/src/include/nodes/ag_nodes.h @@ -22,56 +22,56 @@ #include "nodes/extensible.h" -// This list must match node_names and node_methods. +/* This list must match node_names and node_methods. */ typedef enum ag_node_tag { ag_node_invalid_t = 0, - // projection + /* projection */ cypher_return_t, cypher_with_t, - // reading clause + /* reading clause */ cypher_match_t, - // updating clause + /* updating clause */ cypher_create_t, cypher_set_t, cypher_set_item_t, cypher_delete_t, cypher_unwind_t, cypher_merge_t, - // pattern + /* pattern */ cypher_path_t, cypher_node_t, cypher_relationship_t, - // expression + /* expression */ cypher_bool_const_t, cypher_param_t, cypher_map_t, cypher_map_projection_t, cypher_map_projection_element_t, cypher_list_t, - // comparison expression + /* comparison expression */ cypher_comparison_aexpr_t, cypher_comparison_boolexpr_t, - // string match + /* string match */ cypher_string_match_t, - // typecast + /* typecast */ cypher_typecast_t, - // integer constant + /* integer constant */ cypher_integer_const_t, - // sub patterns/queries + /* sub patterns/queries */ cypher_sub_pattern_t, cypher_sub_query_t, - // procedure calls + /* procedure calls */ cypher_call_t, - // create data structures + /* create data structures */ cypher_create_target_nodes_t, cypher_create_path_t, cypher_target_node_t, - // set/remove data structures + /* set/remove data structures */ cypher_update_information_t, cypher_update_item_t, - // delete data structures + /* delete data structures */ cypher_delete_information_t, cypher_delete_item_t, cypher_merge_information_t diff --git a/src/include/nodes/cypher_copyfuncs.h b/src/include/nodes/cypher_copyfuncs.h index 2b9eebc62..d7ed7eff7 100644 --- a/src/include/nodes/cypher_copyfuncs.h +++ b/src/include/nodes/cypher_copyfuncs.h @@ -29,7 +29,7 @@ void copy_ag_node(ExtensibleNode *newnode, const ExtensibleNode *oldnode); -// create data structures +/* create data structures */ void copy_cypher_create_target_nodes(ExtensibleNode *newnode, const ExtensibleNode *from); void copy_cypher_create_path(ExtensibleNode *newnode, @@ -37,19 +37,19 @@ void copy_cypher_create_path(ExtensibleNode *newnode, void copy_cypher_target_node(ExtensibleNode *newnode, const ExtensibleNode *from); -// set/remove data structures +/* set/remove data structures */ void copy_cypher_update_information(ExtensibleNode *newnode, const ExtensibleNode *from); void copy_cypher_update_item(ExtensibleNode *newnode, const ExtensibleNode *from); -// delete data structures +/* delete data structures */ void copy_cypher_delete_information(ExtensibleNode *newnode, const ExtensibleNode *from); void copy_cypher_delete_item(ExtensibleNode *newnode, const ExtensibleNode *from); -// merge data structure +/* merge data structure */ void copy_cypher_merge_information(ExtensibleNode *newnode, const ExtensibleNode *from); #endif diff --git a/src/include/nodes/cypher_nodes.h b/src/include/nodes/cypher_nodes.h index a64f5a003..e7e293f3e 100644 --- a/src/include/nodes/cypher_nodes.h +++ b/src/include/nodes/cypher_nodes.h @@ -52,7 +52,7 @@ typedef struct cypher_return { ExtensibleNode extensible; bool distinct; - List *items; // a list of ResTarget's + List *items; /* a list of ResTarget's */ List *order_by; Node *skip; Node *limit; @@ -67,8 +67,8 @@ typedef struct cypher_with { ExtensibleNode extensible; bool distinct; - bool subquery_intermediate; //flag that denotes a subquery node - List *items; // a list of ResTarget's + bool subquery_intermediate; /* flag that denotes a subquery node */ + List *items; /* a list of ResTarget's */ List *order_by; Node *skip; Node *limit; @@ -78,39 +78,39 @@ typedef struct cypher_with typedef struct cypher_match { ExtensibleNode extensible; - List *pattern; // a list of cypher_paths - Node *where; // optional WHERE subclause (expression) - bool optional; // OPTIONAL MATCH + List *pattern; /* a list of cypher_paths */ + Node *where; /* optional WHERE subclause (expression) */ + bool optional; /* OPTIONAL MATCH */ } cypher_match; typedef struct cypher_create { ExtensibleNode extensible; - List *pattern; // a list of cypher_paths + List *pattern; /* a list of cypher_paths */ } cypher_create; typedef struct cypher_set { ExtensibleNode extensible; - List *items; // a list of cypher_set_items - bool is_remove; // true if this is REMOVE clause + List *items; /* a list of cypher_set_items */ + bool is_remove; /* true if this is REMOVE clause */ int location; } cypher_set; typedef struct cypher_set_item { ExtensibleNode extensible; - Node *prop; // LHS - Node *expr; // RHS - bool is_add; // true if this is += + Node *prop; /* LHS */ + Node *expr; /* RHS */ + bool is_add; /* true if this is += */ int location; } cypher_set_item; typedef struct cypher_delete { ExtensibleNode extensible; - bool detach; // true if DETACH is specified - List *exprs; // targets of this deletion + bool detach; /* true if DETACH is specified */ + List *exprs; /* targets of this deletion */ int location; } cypher_delete; @@ -137,13 +137,13 @@ typedef struct cypher_merge typedef struct cypher_path { ExtensibleNode extensible; - List *path; // [ node ( , relationship , node , ... ) ] + List *path; /* [ node ( , relationship , node , ... ) ] */ char *var_name; char *parsed_var_name; int location; } cypher_path; -// ( name :label props ) +/* ( name :label props ) */ typedef struct cypher_node { ExtensibleNode extensible; @@ -152,7 +152,7 @@ typedef struct cypher_node char *label; char *parsed_label; bool use_equals; - Node *props; // map or parameter + Node *props; /* map or parameter */ int location; } cypher_node; @@ -163,7 +163,7 @@ typedef enum CYPHER_REL_DIR_RIGHT = 1 } cypher_rel_dir; -// -[ name :label props ]- +/* -[ name :label props ]- */ typedef struct cypher_relationship { ExtensibleNode extensible; @@ -172,8 +172,8 @@ typedef struct cypher_relationship char *label; char *parsed_label; bool use_equals; - Node *props; // map or parameter - Node *varlen; // variable length relationships (A_Indices) + Node *props; /* map or parameter */ + Node *varlen; /* variable length relationships (A_Indices) */ cypher_rel_dir dir; int location; } cypher_relationship; @@ -208,7 +208,7 @@ typedef struct cypher_map ExtensibleNode extensible; List *keyvals; int location; - bool keep_null; // if false, keyvals with null value are removed + bool keep_null; /* if false, keyvals with null value are removed */ } cypher_map; typedef struct cypher_map_projection @@ -318,7 +318,7 @@ typedef struct cypher_call FuncExpr *funcexpr; /*transformed */ Node *where; - List *yield_items; // optional yield subclause + List *yield_items; /* optional yield subclause */ } cypher_call; #define CYPHER_CLAUSE_FLAG_NONE 0x0000 @@ -342,11 +342,11 @@ typedef struct cypher_call typedef struct cypher_target_node { ExtensibleNode extensible; - // 'v' for vertex or 'e' for edge + /* 'v' for vertex or 'e' for edge */ char type; - // flags defined below, prefaced with CYPHER_TARGET_NODE_FLAG_* + /* flags defined below, prefaced with CYPHER_TARGET_NODE_FLAG_* */ uint32 flags; - // if an edge, denotes direction + /* if an edge, denotes direction */ cypher_rel_dir dir; /* * Used to create the id for the vertex/edge, @@ -368,15 +368,15 @@ typedef struct cypher_target_node * are stored in the CustomScanState's child TupleTableSlot */ AttrNumber prop_attr_num; - // RelInfo for the table this entity will be stored in + /* RelInfo for the table this entity will be stored in */ ResultRelInfo *resultRelInfo; - // elemTupleSlot used to insert the entity into its table + /* elemTupleSlot used to insert the entity into its table */ TupleTableSlot *elemTupleSlot; - // relid that the label stores its entity + /* relid that the label stores its entity */ Oid relid; - // label this entity belongs to. + /* label this entity belongs to. */ char *label_name; - // variable name for this entity + /* variable name for this entity */ char *variable_name; /* * Attribute number this entity needs to be stored in @@ -387,7 +387,7 @@ typedef struct cypher_target_node } cypher_target_node; #define CYPHER_TARGET_NODE_FLAG_NONE 0x0000 -// node must insert data +/* node must insert data */ #define CYPHER_TARGET_NODE_FLAG_INSERT 0x0001 /* * Flag that denotes if this target node is referencing @@ -396,9 +396,9 @@ typedef struct cypher_target_node */ #define EXISTING_VARIABLE_DECLARED_SAME_CLAUSE 0x0002 -//node is the first instance of a declared variable +/* node is the first instance of a declared variable */ #define CYPHER_TARGET_NODE_IS_VAR 0x0004 -// node is an element in a path variable +/* node is an element in a path variable */ #define CYPHER_TARGET_NODE_IN_PATH_VAR 0x0008 #define CYPHER_TARGET_NODE_MERGE_EXISTS 0x0010 diff --git a/src/include/nodes/cypher_outfuncs.h b/src/include/nodes/cypher_outfuncs.h index fc4782d29..4a04cf94f 100644 --- a/src/include/nodes/cypher_outfuncs.h +++ b/src/include/nodes/cypher_outfuncs.h @@ -26,7 +26,7 @@ * and DEFINE_NODE_METHODS_EXTENDED macros in ag_nodes.c. */ -// clauses +/* clauses */ void out_cypher_return(StringInfo str, const ExtensibleNode *node); void out_cypher_with(StringInfo str, const ExtensibleNode *node); void out_cypher_match(StringInfo str, const ExtensibleNode *node); @@ -37,53 +37,53 @@ void out_cypher_delete(StringInfo str, const ExtensibleNode *node); void out_cypher_unwind(StringInfo str, const ExtensibleNode *node); void out_cypher_merge(StringInfo str, const ExtensibleNode *node); -// pattern +/* pattern */ void out_cypher_path(StringInfo str, const ExtensibleNode *node); void out_cypher_node(StringInfo str, const ExtensibleNode *node); void out_cypher_relationship(StringInfo str, const ExtensibleNode *node); -// expression +/* expression */ void out_cypher_bool_const(StringInfo str, const ExtensibleNode *node); void out_cypher_param(StringInfo str, const ExtensibleNode *node); void out_cypher_map(StringInfo str, const ExtensibleNode *node); void out_cypher_map_projection(StringInfo str, const ExtensibleNode *node); void out_cypher_list(StringInfo str, const ExtensibleNode *node); -// comparison expression +/* comparison expression */ void out_cypher_comparison_aexpr(StringInfo str, const ExtensibleNode *node); void out_cypher_comparison_boolexpr(StringInfo str, const ExtensibleNode *node); -// string match +/* string match */ void out_cypher_string_match(StringInfo str, const ExtensibleNode *node); -// typecast +/* typecast */ void out_cypher_typecast(StringInfo str, const ExtensibleNode *node); -// integer constant +/* integer constant */ void out_cypher_integer_const(StringInfo str, const ExtensibleNode *node); -// sub patterns/queries +/* sub patterns/queries */ void out_cypher_sub_pattern(StringInfo str, const ExtensibleNode *node); void out_cypher_sub_query(StringInfo str, const ExtensibleNode *node); -// procedure call +/* procedure call */ void out_cypher_call(StringInfo str, const ExtensibleNode *node); -// create private data structures +/* create private data structures */ void out_cypher_create_target_nodes(StringInfo str, const ExtensibleNode *node); void out_cypher_create_path(StringInfo str, const ExtensibleNode *node); void out_cypher_target_node(StringInfo str, const ExtensibleNode *node); -// set/remove private data structures +/* set/remove private data structures */ void out_cypher_update_information(StringInfo str, const ExtensibleNode *node); void out_cypher_update_item(StringInfo str, const ExtensibleNode *node); -// delete private data structures +/* delete private data structures */ void out_cypher_delete_information(StringInfo str, const ExtensibleNode *node); void out_cypher_delete_item(StringInfo str, const ExtensibleNode *node); -// merge private data structures +/* merge private data structures */ void out_cypher_merge_information(StringInfo str, const ExtensibleNode *node); #endif diff --git a/src/include/nodes/cypher_readfuncs.h b/src/include/nodes/cypher_readfuncs.h index ab4938546..5792332ac 100644 --- a/src/include/nodes/cypher_readfuncs.h +++ b/src/include/nodes/cypher_readfuncs.h @@ -36,16 +36,16 @@ void read_ag_node(ExtensibleNode *node); -// create data structures +/* create data structures */ void read_cypher_create_target_nodes(struct ExtensibleNode *node); void read_cypher_create_path(struct ExtensibleNode *node); void read_cypher_target_node(struct ExtensibleNode *node); -// set/remove data structures +/* set/remove data structures */ void read_cypher_update_information(struct ExtensibleNode *node); void read_cypher_update_item(struct ExtensibleNode *node); -// delete data structures +/* delete data structures */ void read_cypher_delete_information(struct ExtensibleNode *node); void read_cypher_delete_item(struct ExtensibleNode *node); diff --git a/src/include/parser/ag_scanner.h b/src/include/parser/ag_scanner.h index 16f7f9c84..7351b89b5 100644 --- a/src/include/parser/ag_scanner.h +++ b/src/include/parser/ag_scanner.h @@ -80,7 +80,7 @@ typedef struct ag_token int location; } ag_token; -// an opaque data structure encapsulating the current state of the scanner +/* an opaque data structure encapsulating the current state of the scanner */ typedef void *ag_scanner_t; ag_scanner_t ag_scanner_create(const char *s); diff --git a/src/include/parser/cypher_clause.h b/src/include/parser/cypher_clause.h index 6ce76c737..51ba5cb47 100644 --- a/src/include/parser/cypher_clause.h +++ b/src/include/parser/cypher_clause.h @@ -26,9 +26,9 @@ typedef struct cypher_clause cypher_clause; struct cypher_clause { - cypher_clause *next; //next clause + cypher_clause *next; /* next clause */ Node *self; - cypher_clause *prev; // previous clause + cypher_clause *prev; /* previous clause */ }; Query *transform_cypher_clause(cypher_parsestate *cpstate, diff --git a/src/include/parser/cypher_gram.h b/src/include/parser/cypher_gram.h index c74567b81..cbd8eb98b 100644 --- a/src/include/parser/cypher_gram.h +++ b/src/include/parser/cypher_gram.h @@ -31,7 +31,7 @@ #include "parser/ag_scanner.h" -// override the default data type of locations (yylloc) +/* override the default data type of locations (yylloc) */ #define YYLTYPE int /* @@ -64,7 +64,7 @@ typedef struct cypher_yy_extra */ #include "parser/cypher_gram_def.h" -// cypher_parser.c +/* cypher_parser.c */ int cypher_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, ag_scanner_t scanner); void cypher_yyerror(YYLTYPE *llocp, ag_scanner_t scanner, cypher_yy_extra *extra, const char *msg); diff --git a/src/include/parser/cypher_parse_node.h b/src/include/parser/cypher_parse_node.h index 75dcc1c01..f7169380e 100644 --- a/src/include/parser/cypher_parse_node.h +++ b/src/include/parser/cypher_parse_node.h @@ -40,7 +40,7 @@ typedef struct cypher_parsestate int default_alias_num; List *entities; List *property_constraint_quals; - bool subquery_where_flag; // flag for knowing we are in a subquery where + bool subquery_where_flag; /* flag for knowing we are in a subquery where */ /* * To flag when an aggregate has been found in an expression during an * expression transform. This is used during the return_item list transform @@ -56,8 +56,8 @@ typedef struct cypher_parsestate typedef struct errpos_ecb_state { ErrorContextCallback ecb; - ParseState *pstate; // ParseState of query that has subquery being parsed - int query_loc; // location of subquery starting from p_sourcetext + ParseState *pstate; /* ParseState of query that has subquery being parsed */ + int query_loc; /* location of subquery starting from p_sourcetext */ } errpos_ecb_state; cypher_parsestate *make_cypher_parsestate(cypher_parsestate *parent_cpstate); diff --git a/src/include/parser/cypher_transform_entity.h b/src/include/parser/cypher_transform_entity.h index bffce7cac..d24d4c372 100644 --- a/src/include/parser/cypher_transform_entity.h +++ b/src/include/parser/cypher_transform_entity.h @@ -46,7 +46,7 @@ enum transform_entity_join_side */ typedef struct { - // denotes whether this entity is a vertex or edge + /* denotes whether this entity is a vertex or edge */ enum transform_entity_type type; /* @@ -75,7 +75,7 @@ typedef struct * declared by itself or a previous clause. */ bool declared_in_current_clause; - // The parse data structure that we transformed + /* The parse data structure that we transformed */ union { cypher_node *node; diff --git a/src/include/utils/ag_cache.h b/src/include/utils/ag_cache.h index cfd7c0335..0e2c3a91f 100644 --- a/src/include/utils/ag_cache.h +++ b/src/include/utils/ag_cache.h @@ -20,7 +20,7 @@ #ifndef AG_AG_CACHE_H #define AG_AG_CACHE_H -// graph_cache_data contains the same fields that ag_graph catalog table has +/* graph_cache_data contains the same fields that ag_graph catalog table has */ typedef struct graph_cache_data { Oid oid; @@ -28,7 +28,7 @@ typedef struct graph_cache_data Oid namespace; } graph_cache_data; -// label_cache_data contains the same fields that ag_label catalog table has +/* label_cache_data contains the same fields that ag_label catalog table has */ typedef struct label_cache_data { NameData name; @@ -39,7 +39,7 @@ typedef struct label_cache_data NameData seq_name; } label_cache_data; -// callers of these functions must not modify the returned struct +/* callers of these functions must not modify the returned struct */ graph_cache_data *search_graph_name_cache(const char *name); graph_cache_data *search_graph_namespace_cache(Oid namespace); label_cache_data *search_label_oid_cache(Oid oid); diff --git a/src/include/utils/graphid.h b/src/include/utils/graphid.h index 95e0eca9b..bfb72ee8c 100644 --- a/src/include/utils/graphid.h +++ b/src/include/utils/graphid.h @@ -37,7 +37,8 @@ typedef int64 graphid; #define label_id_is_valid(id) (id >= LABEL_ID_MIN && id <= LABEL_ID_MAX) #define ENTRY_ID_MIN INT64CONST(1) -#define ENTRY_ID_MAX INT64CONST(281474976710655) // 0x0000ffffffffffff +/* 0x0000ffffffffffff */ +#define ENTRY_ID_MAX INT64CONST(281474976710655) #define INVALID_ENTRY_ID INT64CONST(0) #define entry_id_is_valid(id) (id >= ENTRY_ID_MIN && id <= ENTRY_ID_MAX) diff --git a/src/include/utils/load/ag_load_edges.h b/src/include/utils/load/ag_load_edges.h index 0779685c2..292d828be 100644 --- a/src/include/utils/load/ag_load_edges.h +++ b/src/include/utils/load/ag_load_edges.h @@ -48,5 +48,5 @@ void edge_row_cb(int delim __attribute__((unused)), void *data); int create_edges_from_csv_file(char *file_path, char *graph_name, Oid graph_oid, char *object_name, int object_id ); -#endif //AG_LOAD_EDGES_H +#endif /* AG_LOAD_EDGES_H */ diff --git a/src/include/utils/load/ag_load_labels.h b/src/include/utils/load/ag_load_labels.h index e2b19ab1c..9fed8b502 100644 --- a/src/include/utils/load/ag_load_labels.h +++ b/src/include/utils/load/ag_load_labels.h @@ -60,4 +60,4 @@ int create_labels_from_csv_file(char *file_path, char *graph_name, Oid graph_oid char *object_name, int object_id, bool id_field_exists); -#endif //AG_LOAD_LABELS_H +#endif /* AG_LOAD_LABELS_H */ diff --git a/src/include/utils/load/age_load.h b/src/include/utils/load/age_load.h index f3c251aed..07d0275a7 100644 --- a/src/include/utils/load/age_load.h +++ b/src/include/utils/load/age_load.h @@ -41,4 +41,4 @@ void insert_edge_simple(Oid graph_oid, char *label_name, graphid edge_id, graphid start_id, graphid end_id, agtype* end_properties); -#endif //AGE_ENTITY_CREATOR_H +#endif /* AGE_ENTITY_CREATOR_H */ diff --git a/src/include/utils/load/csv.h b/src/include/utils/load/csv.h index fd1edb4d9..062536977 100644 --- a/src/include/utils/load/csv.h +++ b/src/include/utils/load/csv.h @@ -1,6 +1,6 @@ -// -// Created by Shoaib on 12/5/2021. -// +/* + * Created by Shoaib on 12/5/2021. +*/ /* libcsv - parse and write csv data