Fİxes compile errors

grant_parameter_propagation
gurkanindibay 2024-01-17 11:03:04 +03:00
parent 5d8fd32fd3
commit d54ba314f9
2 changed files with 24 additions and 6 deletions

View File

@ -66,7 +66,10 @@ GenerateGrantOnParameterFromAclItem(char *parameterName, AclItem *aclItem)
return queries; 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 static void
CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName, CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName,
AclMode mode, char *modeStr) 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 static void
CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes) 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++) for (int i = 0; i < numModes; i++)
{ {
AclMode mode = modes[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)));
}
} }
} }

View File

@ -2165,7 +2165,13 @@ GenerateGrantStmtForRights(ObjectType objectType,
withGrantOption); 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 * GrantStmt *
GenerateGrantStmtForRightsWithObjectName(ObjectType objectType, GenerateGrantStmtForRightsWithObjectName(ObjectType objectType,
Oid roleOid, Oid roleOid,
@ -2177,7 +2183,12 @@ GenerateGrantStmtForRightsWithObjectName(ObjectType objectType,
permission, withGrantOption); 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 * GrantStmt *
BaseGenerateGrantStmtForRights(ObjectType objectType, BaseGenerateGrantStmtForRights(ObjectType objectType,
Oid roleOid, Oid roleOid,
@ -2260,7 +2271,6 @@ GetObjectsForGrantStmt(ObjectType objectType, Oid objectId)
return list_make1(makeString(get_database_name(objectId))); return list_make1(makeString(get_database_name(objectId)));
} }
default: default:
{ {
elog(ERROR, "unsupported object type for GRANT"); elog(ERROR, "unsupported object type for GRANT");