mirror of https://github.com/citusdata/citus.git
wip
parent
c8237b6c73
commit
1b16a9fe02
|
@ -149,13 +149,6 @@ 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)
|
||||
|
@ -180,7 +173,6 @@ CreateCimv(CimvCreate *cimvCreate)
|
|||
RefreshCimv(cimvCreate->formCimv, cimvCreate->stmt->into->skipData, true);
|
||||
}
|
||||
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,13 +50,6 @@ 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);
|
||||
|
@ -156,8 +149,6 @@ RefreshCimv(Form_pg_cimv formCimv, bool skipData, bool isCreate)
|
|||
}
|
||||
}
|
||||
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
|
||||
/* Close SPI context. */
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "distributed/multi_explain.h"
|
||||
#include "distributed/multi_physical_planner.h"
|
||||
#include "distributed/resource_lock.h"
|
||||
#include "distributed/security_utils.h"
|
||||
#include "distributed/transmit.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_transaction.h"
|
||||
|
@ -460,29 +461,27 @@ 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);
|
||||
PushCitusSecurityContext();
|
||||
continueProcessing = !ProcessCreateMaterializedViewStmt((const
|
||||
CreateTableAsStmt *)
|
||||
parsetree, queryString,
|
||||
pstmt);
|
||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||
PopCitusSecurityContext();
|
||||
}
|
||||
|
||||
if (IsA(parsetree, RefreshMatViewStmt))
|
||||
{
|
||||
PushCitusSecurityContext();
|
||||
continueProcessing = !ProcessRefreshMaterializedViewStmt(
|
||||
(RefreshMatViewStmt *) parsetree);
|
||||
PopCitusSecurityContext();
|
||||
}
|
||||
|
||||
if (IsA(parsetree, DropStmt))
|
||||
{
|
||||
DropStmt *dropStatement = (DropStmt *) parsetree;
|
||||
|
||||
PushCitusSecurityContext();
|
||||
if (dropStatement->removeType == OBJECT_MATVIEW)
|
||||
{
|
||||
ProcessDropMaterializedViewStmt(dropStatement);
|
||||
|
@ -491,6 +490,8 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
{
|
||||
ProcessDropViewStmt(dropStatement);
|
||||
}
|
||||
PopCitusSecurityContext();
|
||||
|
||||
}
|
||||
|
||||
if (IsDropCitusExtensionStmt(parsetree))
|
||||
|
|
Loading…
Reference in New Issue