You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by GitBox <gi...@apache.org> on 2022/12/01 21:25:53 UTC

[GitHub] [age] jrgemignani commented on a diff in pull request #349: Issue 317: Graph naming convention

jrgemignani commented on code in PR #349:
URL: https://github.com/apache/age/pull/349#discussion_r1037555356


##########
src/backend/commands/graph_commands.c:
##########
@@ -323,6 +324,13 @@ static void rename_graph(const Name graph_name, const Name new_name)
     char *newname = NameStr(*new_name);
     char *schema_name;
 
+    if (!is_valid_graph_name(newname)) 

Review Comment:
   There is an extra space at the end of the line, please remove it. Same issues as above.
   



##########
src/backend/commands/label_commands.c:
##########
@@ -221,6 +230,14 @@ Datum create_elabel(PG_FUNCTION_ARGS)
     graph_name_str = NameStr(*graph_name);
     label_name_str = NameStr(*label_name);
 
+    // Check if label name is valid
+    if (!is_valid_edge_label(label_name_str))
+    {
+        ereport(ERROR,
+                (errcode(ERRCODE_UNDEFINED_SCHEMA),
+                        errmsg("label name is invalid")));

Review Comment:
   Please correct formatting.



##########
src/backend/commands/label_commands.c:
##########
@@ -141,6 +142,14 @@ Datum create_vlabel(PG_FUNCTION_ARGS)
     graph_name_str = NameStr(*graph_name);
     label_name_str = NameStr(*label_name);
 
+    // Check if label name is valid
+    if (!is_valid_vertex_label(label_name_str))
+    {
+        ereport(ERROR,
+                (errcode(ERRCODE_UNDEFINED_SCHEMA),
+                        errmsg("label name is invalid")));

Review Comment:
   Please correct formatting.



##########
src/backend/commands/graph_commands.c:
##########
@@ -73,11 +74,11 @@ Datum create_graph(PG_FUNCTION_ARGS)
 
     graph_name_str = NameStr(*graph_name);
 
-    if (strlen(graph_name_str) == 0)
+    if (!is_valid_graph_name(graph_name_str)) 

Review Comment:
   There is an extra space at the end of the line, please remove it.



##########
src/include/utils/name_validation.h:
##########
@@ -0,0 +1,24 @@
+#ifndef AG_NAME_VALIDATION_H

Review Comment:
   Needs Apache header.



##########
src/backend/utils/name_validation.c:
##########
@@ -0,0 +1,78 @@
+#include "postgres.h"

Review Comment:
   Needs Apache license header.
   
   Please go through file and make sure it conforms to our coding standards -
   
   1. All functions, if/else, for, while, do, statements must have braces - no exceptions.
   2. All braces must start on a new line by themselves.
   3. No extra spaces at the end of lines. I know, seems dumb, but that's the way we've been doing it.
   4. Lines are not to exceed 80 columns. A few characters is okay, if you cannot format it otherwise.
   5. When formatting function parameters where the length exceeds 80 characters, align the parameters to each other.
   6. If a function is not going to be used externally, make it static.
   7. Use defined constants or #defines for constant values. Do not hardcode anything, unless necessary.
   



##########
src/backend/commands/graph_commands.c:
##########
@@ -73,11 +74,11 @@ Datum create_graph(PG_FUNCTION_ARGS)
 
     graph_name_str = NameStr(*graph_name);
 
-    if (strlen(graph_name_str) == 0)
+    if (!is_valid_graph_name(graph_name_str)) 

Review Comment:
   Additionally, please align the function parameters correctly.



##########
src/backend/commands/graph_commands.c:
##########
@@ -73,11 +74,11 @@ Datum create_graph(PG_FUNCTION_ARGS)
 
     graph_name_str = NameStr(*graph_name);
 
-    if (strlen(graph_name_str) == 0)
+    if (!is_valid_graph_name(graph_name_str)) 

Review Comment:
   ![image](https://user-images.githubusercontent.com/1505136/205158680-5175af24-4e9c-4346-a24f-a8318a92026a.png)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org