mirror of https://github.com/citusdata/citus.git
Set user as pg_merge_job_* schema owner
parent
4914ccbaba
commit
42ff472721
|
@ -261,12 +261,8 @@ CreateJobSchema(StringInfo schemaName)
|
||||||
|
|
||||||
Oid savedUserId = InvalidOid;
|
Oid savedUserId = InvalidOid;
|
||||||
int savedSecurityContext = 0;
|
int savedSecurityContext = 0;
|
||||||
|
CreateSchemaStmt *createSchemaStmt = NULL;
|
||||||
/* build a CREATE SCHEMA statement */
|
RoleSpec currentUserRole = { 0 };
|
||||||
CreateSchemaStmt *createSchemaStmt = makeNode(CreateSchemaStmt);
|
|
||||||
createSchemaStmt->schemaname = schemaName->data;
|
|
||||||
createSchemaStmt->authrole = NULL;
|
|
||||||
createSchemaStmt->schemaElts = NIL;
|
|
||||||
|
|
||||||
/* allow schema names that start with pg_ */
|
/* allow schema names that start with pg_ */
|
||||||
oldAllowSystemTableMods = allowSystemTableMods;
|
oldAllowSystemTableMods = allowSystemTableMods;
|
||||||
|
@ -276,7 +272,18 @@ CreateJobSchema(StringInfo schemaName)
|
||||||
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
||||||
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
||||||
|
|
||||||
/* actually create schema, and make it visible */
|
/* build a CREATE SCHEMA statement */
|
||||||
|
currentUserRole.type = T_RoleSpec;
|
||||||
|
currentUserRole.roletype = ROLESPEC_CSTRING;
|
||||||
|
currentUserRole.rolename = GetUserNameFromId(savedUserId, false);
|
||||||
|
currentUserRole.location = -1;
|
||||||
|
|
||||||
|
createSchemaStmt = makeNode(CreateSchemaStmt);
|
||||||
|
createSchemaStmt->schemaname = schemaName->data;
|
||||||
|
createSchemaStmt->authrole = (Node *) ¤tUserRole;
|
||||||
|
createSchemaStmt->schemaElts = NIL;
|
||||||
|
|
||||||
|
/* actually create schema with the current user as owner */
|
||||||
CreateSchemaCommand(createSchemaStmt, queryString);
|
CreateSchemaCommand(createSchemaStmt, queryString);
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue