mirror of https://github.com/citusdata/citus.git
Fixes indentation
parent
3c73117597
commit
dfbbcce212
|
@ -1,24 +1,24 @@
|
|||
#include "postgres.h"
|
||||
|
||||
|
||||
#include "access/genam.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_parameter_acl.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "distributed/metadata_sync.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/grant_utils.h"
|
||||
#include "distributed/listutils.h"
|
||||
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/grant_utils.h"
|
||||
#include "distributed/listutils.h"
|
||||
#include "distributed/metadata_sync.h"
|
||||
|
||||
static List * GenerateGrantOnParameterFromAclItem(char *parameterName, AclItem *aclItem);
|
||||
static bool HasAclGrantOption(AclItem *aclItem, AclMode aclMode);
|
||||
static void CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes);
|
||||
static void CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName, AclMode mode, char *modeStr);
|
||||
static void CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid,
|
||||
char *parameterName, AclMode mode, char *modeStr);
|
||||
|
||||
|
||||
List *
|
||||
|
@ -58,14 +58,19 @@ GenerateGrantOnParameterFromAclItem(char *parameterName, AclItem *aclItem)
|
|||
queries = lappend(queries, GenerateSetRoleQuery(aclItem->ai_grantor));
|
||||
|
||||
CheckAndAppendQuery(&queries, aclItem, granteeOid, parameterName, ACL_SET, "SET");
|
||||
CheckAndAppendQuery(&queries, aclItem, granteeOid, parameterName, ACL_ALTER_SYSTEM, "ALTER SYSTEM");
|
||||
CheckAndAppendQuery(&queries, aclItem, granteeOid, parameterName, ACL_ALTER_SYSTEM,
|
||||
"ALTER SYSTEM");
|
||||
|
||||
queries = lappend(queries, "RESET ROLE");
|
||||
|
||||
return queries;
|
||||
}
|
||||
|
||||
static void CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName, AclMode mode, char *modeStr) {
|
||||
|
||||
static void
|
||||
CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid, char *parameterName,
|
||||
AclMode mode, char *modeStr)
|
||||
{
|
||||
AclResult aclresult = pg_parameter_aclcheck(parameterName, granteeOid, mode);
|
||||
if (aclresult == ACLCHECK_OK)
|
||||
{
|
||||
|
@ -74,33 +79,42 @@ static void CheckAndAppendQuery(List **queries, AclItem *aclItem, Oid granteeOid
|
|||
modeStr,
|
||||
HasAclGrantOption(aclItem, mode)));
|
||||
|
||||
// remove the semicolon at the end of the query since it is already
|
||||
// appended in metadata_sync phase
|
||||
/* remove the semicolon at the end of the query since it is already */
|
||||
/* appended in metadata_sync phase */
|
||||
query[strlen(query) - 1] = '\0';
|
||||
|
||||
*queries = lappend(*queries, query);
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes) {
|
||||
|
||||
static void
|
||||
CheckPermissionsAndGrants(AclItem *aclItem, AclMode modes[], int numModes)
|
||||
{
|
||||
AclMode permissions = ACLITEM_GET_PRIVS(*aclItem) & ACL_ALL_RIGHTS_PARAMETER_ACL;
|
||||
AclMode grants = ACLITEM_GET_GOPTIONS(*aclItem) & ACL_ALL_RIGHTS_PARAMETER_ACL;
|
||||
|
||||
for (int i = 0; i < numModes; i++) {
|
||||
for (int i = 0; i < numModes; i++)
|
||||
{
|
||||
AclMode mode = modes[i];
|
||||
Assert(!(grants & mode) || (permissions & mode));
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasAclGrantOption(AclItem *aclItem,AclMode aclMode)
|
||||
|
||||
static bool
|
||||
HasAclGrantOption(AclItem *aclItem, AclMode aclMode)
|
||||
{
|
||||
return (aclItem->ai_privs & ACL_GRANT_OPTION_FOR(aclMode)) != 0;
|
||||
}
|
||||
|
||||
List * GrantOnParameters(void)
|
||||
|
||||
List *
|
||||
GrantOnParameters(void)
|
||||
{
|
||||
/* Open pg_shdescription catalog */
|
||||
Relation paramPermissionRelation = table_open(ParameterAclRelationId, AccessShareLock);
|
||||
Relation paramPermissionRelation = table_open(ParameterAclRelationId,
|
||||
AccessShareLock);
|
||||
|
||||
|
||||
int scanKeyCount = 0;
|
||||
|
@ -111,14 +125,14 @@ List * GrantOnParameters(void)
|
|||
List *commands = NIL;
|
||||
while ((tuple = systable_getnext(scan)) != NULL)
|
||||
{
|
||||
|
||||
bool isNull = false;
|
||||
|
||||
TupleDesc tupdesc = RelationGetDescr(paramPermissionRelation);
|
||||
|
||||
Datum aclDatum = heap_getattr(tuple, Anum_pg_parameter_acl_paracl, tupdesc,
|
||||
&isNull);
|
||||
Datum parameterNameDatum = heap_getattr(tuple, Anum_pg_parameter_acl_parname, tupdesc,
|
||||
Datum parameterNameDatum = heap_getattr(tuple, Anum_pg_parameter_acl_parname,
|
||||
tupdesc,
|
||||
&isNull);
|
||||
|
||||
char *parameterName = TextDatumGetCString(parameterNameDatum);
|
||||
|
@ -128,15 +142,12 @@ List * GrantOnParameters(void)
|
|||
int aclNum = ACL_NUM(acl);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < aclNum; i++)
|
||||
{
|
||||
commands = list_concat(commands,
|
||||
GenerateGrantOnParameterFromAclItem(
|
||||
parameterName, &aclDat[i]));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End the scan and close the catalog */
|
||||
|
|
|
@ -33,6 +33,7 @@ AppendGrantParameters(StringInfo buf, GrantStmt *stmt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
AppendGrantOnParameterStmt(StringInfo buf, GrantStmt *stmt)
|
||||
{
|
||||
|
@ -59,5 +60,3 @@ DeparseGrantOnParameterStmt(Node *node)
|
|||
|
||||
return str.data;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "distributed/coordinator_protocol.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/distribution_column.h"
|
||||
#include "distributed/grant_utils.h"
|
||||
#include "distributed/listutils.h"
|
||||
#include "distributed/maintenanced.h"
|
||||
#include "distributed/metadata/dependency.h"
|
||||
|
@ -88,7 +89,6 @@
|
|||
#include "distributed/tenant_schema_metadata.h"
|
||||
#include "distributed/utils/array_type.h"
|
||||
#include "distributed/utils/function.h"
|
||||
#include "distributed/grant_utils.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_manager.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
|
@ -2161,9 +2161,11 @@ GenerateGrantStmtForRights(ObjectType objectType,
|
|||
char *permission,
|
||||
bool withGrantOption)
|
||||
{
|
||||
return BaseGenerateGrantStmtForRights(objectType,roleOid,objectId,NULL,permission,withGrantOption);
|
||||
return BaseGenerateGrantStmtForRights(objectType, roleOid, objectId, NULL, permission,
|
||||
withGrantOption);
|
||||
}
|
||||
|
||||
|
||||
GrantStmt *
|
||||
GenerateGrantStmtForRightsWithObjectName(ObjectType objectType,
|
||||
Oid roleOid,
|
||||
|
@ -2171,7 +2173,8 @@ GenerateGrantStmtForRightsWithObjectName(ObjectType objectType,
|
|||
char *permission,
|
||||
bool withGrantOption)
|
||||
{
|
||||
return BaseGenerateGrantStmtForRights(objectType,roleOid,InvalidOid,objectName,permission,withGrantOption);
|
||||
return BaseGenerateGrantStmtForRights(objectType, roleOid, InvalidOid, objectName,
|
||||
permission, withGrantOption);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2183,8 +2186,7 @@ BaseGenerateGrantStmtForRights(ObjectType objectType,
|
|||
char *permission,
|
||||
bool withGrantOption)
|
||||
{
|
||||
|
||||
//either objectId or objectName should be valid
|
||||
/*either objectId or objectName should be valid */
|
||||
Assert(objectId != InvalidOid || objectName != NULL);
|
||||
|
||||
GrantStmt *stmt = makeNode(GrantStmt);
|
||||
|
@ -2207,7 +2209,6 @@ BaseGenerateGrantStmtForRights(ObjectType objectType,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GetObjectsForGrantStmt takes an object type and object id and returns the 'objects'
|
||||
* field to be used when creating GrantStmt. We have only one object here (the one with
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef CITUS_GRANT_UTILS_H
|
||||
#define CITUS_GRANT_UTILS_H
|
||||
#include "postgres.h"
|
||||
|
||||
#include "nodes/parsenodes.h"
|
||||
|
||||
extern List * GrantOnParameters(void);
|
||||
|
|
Loading…
Reference in New Issue