Sait Talha Nisanci 2020-12-30 14:19:03 +03:00
parent c8237b6c73
commit 1b16a9fe02
3 changed files with 8 additions and 24 deletions

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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))