diff --git a/src/backend/distributed/commands/parameter.c b/src/backend/distributed/commands/parameter.c index f51e94712..439ff26a1 100644 --- a/src/backend/distributed/commands/parameter.c +++ b/src/backend/distributed/commands/parameter.c @@ -66,7 +66,10 @@ GenerateGrantOnParameterFromAclItem(char *parameterName, AclItem *aclItem) return queries; } - +/* + * CheckAndAppendQuery checks if the aclItem has the given mode and if it has, it appends the + * corresponding query to the queries list. +*/ static void CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName, AclMode mode, char *modeStr) @@ -87,7 +90,10 @@ CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *para } } - +/* +* CheckPermissionsAndGrants checks if the aclItem has the valid permissions and grants +* for the given modes. +*/ static void CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes) { @@ -97,7 +103,9 @@ CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes) for (int i = 0; i < numModes; i++) { AclMode mode = modes[i]; - Assert(!(grants & mode) || (permissions & mode)); + if(!(grants & mode) || (permissions & mode)){ + ereport(ERROR, (errmsg("ACL item has no grant option for mode %d", mode))); + } } } diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 892c7fbc5..879bfbdd4 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -2165,7 +2165,13 @@ GenerateGrantStmtForRights(ObjectType objectType, withGrantOption); } - +/* + * GenerateGrantStmtForRightsWithObjectName is the function for creating + * GrantStmt's for all types of objects that are supported with object name. + * It takes parameters to fill a GrantStmt's fields and returns the GrantStmt. + * The field `objects` of GrantStmt doesn't have a common structure for all types. + * Make sure you have added your object type to GetObjectsForGrantStmt. + */ GrantStmt * GenerateGrantStmtForRightsWithObjectName(ObjectType objectType, Oid roleOid, @@ -2177,7 +2183,12 @@ GenerateGrantStmtForRightsWithObjectName(ObjectType objectType, permission, withGrantOption); } - +/* + * BaseGenerateGrantStmtForRights is the base function for creating + * GrantStmt's for all types of objects that are supported with object . + * It is used by GenerateGrantStmtForRights and GenerateGrantStmtForRightsWithObjectName + * to support both object id and object name. + */ GrantStmt * BaseGenerateGrantStmtForRights(ObjectType objectType, Oid roleOid, @@ -2260,7 +2271,6 @@ GetObjectsForGrantStmt(ObjectType objectType, Oid objectId) return list_make1(makeString(get_database_name(objectId))); } - default: { elog(ERROR, "unsupported object type for GRANT");