mirror of https://github.com/citusdata/citus.git
Adds dependencies
parent
f255643168
commit
f1f7313c8b
|
@ -47,7 +47,7 @@ static bool ShouldPropagateObject(const ObjectAddress *address);
|
||||||
static char * DropTableIfExistsCommand(Oid relationId);
|
static char * DropTableIfExistsCommand(Oid relationId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EnsureObjectExistOnAllNodes is a wrapper around
|
* EnsureObjectAndDependenciesExistOnAllNodes is a wrapper around
|
||||||
* EnsureRequiredObjectExistOnAllNodes to ensure the "object itself" (together
|
* EnsureRequiredObjectExistOnAllNodes to ensure the "object itself" (together
|
||||||
* with its dependencies) is available on all nodes.
|
* with its dependencies) is available on all nodes.
|
||||||
*
|
*
|
||||||
|
@ -55,7 +55,7 @@ static char * DropTableIfExistsCommand(Oid relationId);
|
||||||
* function deals with an object created within the same transaction.
|
* function deals with an object created within the same transaction.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
EnsureObjectExistOnAllNodes(const ObjectAddress *target)
|
EnsureObjectAndDependenciesExistOnAllNodes(const ObjectAddress *target)
|
||||||
{
|
{
|
||||||
EnsureRequiredObjectExistOnAllNodes(target, REQUIRE_OBJECT_AND_DEPENDENCIES);
|
EnsureRequiredObjectExistOnAllNodes(target, REQUIRE_OBJECT_AND_DEPENDENCIES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@
|
||||||
#include "utils/varlena.h"
|
#include "utils/varlena.h"
|
||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
|
|
||||||
|
static ObjectAddress * GetNewRoleAddress(ReassignOwnedStmt *stmt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PreprocessDropOwnedStmt finds the distributed role out of the ones
|
* PreprocessDropOwnedStmt finds the distributed role out of the ones
|
||||||
* being dropped and unmarks them distributed and creates the drop statements
|
* being dropped and unmarks them distributed and creates the drop statements
|
||||||
|
@ -131,9 +134,22 @@ PostprocessReassignOwnedStmt(Node *node, const char *queryString)
|
||||||
char *sql = DeparseTreeNode((Node *) stmt);
|
char *sql = DeparseTreeNode((Node *) stmt);
|
||||||
stmt->roles = allReassignRoles;
|
stmt->roles = allReassignRoles;
|
||||||
|
|
||||||
|
ObjectAddress *newRoleAddress = GetNewRoleAddress(stmt);
|
||||||
|
|
||||||
|
EnsureObjectAndDependenciesExistOnAllNodes(newRoleAddress);
|
||||||
|
|
||||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||||
sql,
|
sql,
|
||||||
ENABLE_DDL_PROPAGATION);
|
ENABLE_DDL_PROPAGATION);
|
||||||
|
|
||||||
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ObjectAddress * GetNewRoleAddress(ReassignOwnedStmt *stmt)
|
||||||
|
{
|
||||||
|
Oid roleOid = get_role_oid(stmt->newrole->rolename, false);
|
||||||
|
ObjectAddress *address = palloc0(sizeof(ObjectAddress));
|
||||||
|
ObjectAddressSet(*address, AuthIdRelationId, roleOid);
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
|
@ -385,7 +385,7 @@ extern void EnsureUndistributeTenantTableSafe(Oid relationId, const char *operat
|
||||||
extern TableConversionReturn * UndistributeTable(TableConversionParameters *params);
|
extern TableConversionReturn * UndistributeTable(TableConversionParameters *params);
|
||||||
extern void UndistributeTables(List *relationIdList);
|
extern void UndistributeTables(List *relationIdList);
|
||||||
|
|
||||||
extern void EnsureObjectExistOnAllNodes(const ObjectAddress *target);
|
extern void EnsureObjectAndDependenciesExistOnAllNodes(const ObjectAddress *target);
|
||||||
extern void EnsureAllObjectDependenciesExistOnAllNodes(const List *targets);
|
extern void EnsureAllObjectDependenciesExistOnAllNodes(const List *targets);
|
||||||
extern DeferredErrorMessage * DeferErrorIfCircularDependencyExists(const
|
extern DeferredErrorMessage * DeferErrorIfCircularDependencyExists(const
|
||||||
ObjectAddress *
|
ObjectAddress *
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
CREATE ROLE role1;
|
CREATE ROLE role1;
|
||||||
|
|
||||||
create ROLE role2;
|
create ROLE role2;
|
||||||
|
|
||||||
|
set citus.create_role
|
||||||
CREATE ROLE role3;
|
CREATE ROLE role3;
|
||||||
|
|
||||||
GRANT CREATE ON SCHEMA public TO role1,role2;
|
GRANT CREATE ON SCHEMA public TO role1,role2;
|
||||||
|
|
Loading…
Reference in New Issue