mirror of https://github.com/citusdata/citus.git
wip
parent
6c9872d182
commit
c8237b6c73
|
@ -149,6 +149,13 @@ CreateCimv(CimvCreate *cimvCreate)
|
|||
elog(ERROR, "SPI_connect failed");
|
||||
}
|
||||
|
||||
Oid savedUserId = InvalidOid;
|
||||
int savedSecurityContext = 0;
|
||||
|
||||
/* make sure we have write access */
|
||||
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
||||
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
||||
|
||||
CreateMatTable(cimvCreate, false);
|
||||
|
||||
if (cimvCreate->createOptions->schedule != NULL)
|
||||
|
@ -172,6 +179,8 @@ CreateCimv(CimvCreate *cimvCreate)
|
|||
{
|
||||
RefreshCimv(cimvCreate->formCimv, cimvCreate->stmt->into->skipData, true);
|
||||
}
|
||||
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,13 @@ RefreshCimv(Form_pg_cimv formCimv, bool skipData, bool isCreate)
|
|||
elog(ERROR, "SPI_connect failed");
|
||||
}
|
||||
|
||||
Oid savedUserId = InvalidOid;
|
||||
int savedSecurityContext = 0;
|
||||
|
||||
/* make sure we have write access */
|
||||
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
||||
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
||||
|
||||
const char *matTableSchemaName = get_namespace_name(get_rel_namespace(
|
||||
formCimv->mattable));
|
||||
const char *matTableName = get_rel_name(formCimv->mattable);
|
||||
|
@ -149,6 +156,8 @@ RefreshCimv(Form_pg_cimv formCimv, bool skipData, bool isCreate)
|
|||
}
|
||||
}
|
||||
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
|
||||
/* Close SPI context. */
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
{
|
||||
|
|
|
@ -460,10 +460,17 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
bool continueProcessing = true;
|
||||
if (IsA(parsetree, CreateTableAsStmt))
|
||||
{
|
||||
Oid savedUserId = InvalidOid;
|
||||
int savedSecurityContext = 0;
|
||||
|
||||
/* make sure we have write access */
|
||||
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
||||
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
||||
continueProcessing = !ProcessCreateMaterializedViewStmt((const
|
||||
CreateTableAsStmt *)
|
||||
parsetree, queryString,
|
||||
pstmt);
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
}
|
||||
|
||||
if (IsA(parsetree, RefreshMatViewStmt))
|
||||
|
|
Loading…
Reference in New Issue