From 8387942d92ecb8fe4cf73670a2ed52c187ccfc5d Mon Sep 17 00:00:00 2001 From: gurkanindibay Date: Tue, 26 Dec 2023 21:53:47 +0300 Subject: [PATCH] Fixes review issues --- src/backend/distributed/commands/comment.c | 26 +--------------------- src/include/distributed/comment.h | 10 +++++---- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/backend/distributed/commands/comment.c b/src/backend/distributed/commands/comment.c index 2626163b5..e15b4cbec 100644 --- a/src/backend/distributed/commands/comment.c +++ b/src/backend/distributed/commands/comment.c @@ -21,14 +21,6 @@ #include "distributed/comment.h" - -const CommentStmtType commentStmtTypes[] = { - { OBJECT_DATABASE, "DATABASE" }, - { OBJECT_ROLE, "ROLE" } -}; - - -static char * GetCommentObjectType(ObjectType objectType); static char * GetCommentForObject(Oid oid); @@ -41,7 +33,7 @@ GetCommentPropagationCommands(Oid oid, char *objectName, ObjectType objectType) /* Get the comment for the database */ char *comment = GetCommentForObject(oid); - char *commentObjectType = GetCommentObjectType(objectType); + char *commentObjectType = ObjectTypeInfos[objectType].name; /* Create the SQL command to propagate the comment to other nodes */ if (comment != NULL) @@ -62,22 +54,6 @@ GetCommentPropagationCommands(Oid oid, char *objectName, ObjectType objectType) } -static char * -GetCommentObjectType(ObjectType objectType) -{ - char *objectName = NULL; - for (int i = 0; i < sizeof(commentStmtTypes) / sizeof(CommentStmtType); i++) - { - if (commentStmtTypes[i].objectType == objectType) - { - objectName = commentStmtTypes[i].objectName; - break; - } - } - return objectName; -} - - static char * GetCommentForObject(Oid oid) { diff --git a/src/include/distributed/comment.h b/src/include/distributed/comment.h index 5a52fa352..2ee239a2a 100644 --- a/src/include/distributed/comment.h +++ b/src/include/distributed/comment.h @@ -15,11 +15,13 @@ #include "nodes/parsenodes.h" -typedef struct CommentStmtType +typedef struct { - ObjectType objectType; - char *objectName; -} CommentStmtType; + char *name; + int type; +} ObjectTypeInfo; + +extern const ObjectTypeInfo ObjectTypeInfos[]; extern List * GetCommentPropagationCommands(Oid oid, char *objectName, ObjectType