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");
|
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);
|
CreateMatTable(cimvCreate, false);
|
||||||
|
|
||||||
if (cimvCreate->createOptions->schedule != NULL)
|
if (cimvCreate->createOptions->schedule != NULL)
|
||||||
|
@ -180,7 +173,6 @@ CreateCimv(CimvCreate *cimvCreate)
|
||||||
RefreshCimv(cimvCreate->formCimv, cimvCreate->stmt->into->skipData, true);
|
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");
|
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(
|
const char *matTableSchemaName = get_namespace_name(get_rel_namespace(
|
||||||
formCimv->mattable));
|
formCimv->mattable));
|
||||||
const char *matTableName = get_rel_name(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. */
|
/* Close SPI context. */
|
||||||
if (SPI_finish() != SPI_OK_FINISH)
|
if (SPI_finish() != SPI_OK_FINISH)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "distributed/multi_explain.h"
|
#include "distributed/multi_explain.h"
|
||||||
#include "distributed/multi_physical_planner.h"
|
#include "distributed/multi_physical_planner.h"
|
||||||
#include "distributed/resource_lock.h"
|
#include "distributed/resource_lock.h"
|
||||||
|
#include "distributed/security_utils.h"
|
||||||
#include "distributed/transmit.h"
|
#include "distributed/transmit.h"
|
||||||
#include "distributed/version_compat.h"
|
#include "distributed/version_compat.h"
|
||||||
#include "distributed/worker_transaction.h"
|
#include "distributed/worker_transaction.h"
|
||||||
|
@ -460,29 +461,27 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
bool continueProcessing = true;
|
bool continueProcessing = true;
|
||||||
if (IsA(parsetree, CreateTableAsStmt))
|
if (IsA(parsetree, CreateTableAsStmt))
|
||||||
{
|
{
|
||||||
Oid savedUserId = InvalidOid;
|
PushCitusSecurityContext();
|
||||||
int savedSecurityContext = 0;
|
|
||||||
|
|
||||||
/* make sure we have write access */
|
|
||||||
GetUserIdAndSecContext(&savedUserId, &savedSecurityContext);
|
|
||||||
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
|
|
||||||
continueProcessing = !ProcessCreateMaterializedViewStmt((const
|
continueProcessing = !ProcessCreateMaterializedViewStmt((const
|
||||||
CreateTableAsStmt *)
|
CreateTableAsStmt *)
|
||||||
parsetree, queryString,
|
parsetree, queryString,
|
||||||
pstmt);
|
pstmt);
|
||||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
PopCitusSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsA(parsetree, RefreshMatViewStmt))
|
if (IsA(parsetree, RefreshMatViewStmt))
|
||||||
{
|
{
|
||||||
|
PushCitusSecurityContext();
|
||||||
continueProcessing = !ProcessRefreshMaterializedViewStmt(
|
continueProcessing = !ProcessRefreshMaterializedViewStmt(
|
||||||
(RefreshMatViewStmt *) parsetree);
|
(RefreshMatViewStmt *) parsetree);
|
||||||
|
PopCitusSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsA(parsetree, DropStmt))
|
if (IsA(parsetree, DropStmt))
|
||||||
{
|
{
|
||||||
DropStmt *dropStatement = (DropStmt *) parsetree;
|
DropStmt *dropStatement = (DropStmt *) parsetree;
|
||||||
|
|
||||||
|
PushCitusSecurityContext();
|
||||||
if (dropStatement->removeType == OBJECT_MATVIEW)
|
if (dropStatement->removeType == OBJECT_MATVIEW)
|
||||||
{
|
{
|
||||||
ProcessDropMaterializedViewStmt(dropStatement);
|
ProcessDropMaterializedViewStmt(dropStatement);
|
||||||
|
@ -491,6 +490,8 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
{
|
{
|
||||||
ProcessDropViewStmt(dropStatement);
|
ProcessDropViewStmt(dropStatement);
|
||||||
}
|
}
|
||||||
|
PopCitusSecurityContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDropCitusExtensionStmt(parsetree))
|
if (IsDropCitusExtensionStmt(parsetree))
|
||||||
|
|
Loading…
Reference in New Issue