mirror of https://github.com/citusdata/citus.git
Ensure dependencies exists for all alter owner commands
parent
4312486141
commit
547f6b18ef
|
@ -300,6 +300,32 @@ PreprocessAlterCollationOwnerStmt(Node *node, const char *queryString,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* PostprocessAlterCollationOwnerStmt is invoked after the owner has been changed locally.
|
||||
* Since changing the owner could result in new dependencies being found for this object
|
||||
* we re-ensure all the dependencies for the collation do exist.
|
||||
*
|
||||
* This is solely to propagate the new owner (and all its dependencies) if it was not
|
||||
* already distributed in the cluster.
|
||||
*/
|
||||
List *
|
||||
PostprocessAlterCollationOwnerStmt(Node *node, const char *queryString)
|
||||
{
|
||||
AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node);
|
||||
Assert(stmt->objectType == OBJECT_COLLATION);
|
||||
|
||||
ObjectAddress collationAddress = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
if (!ShouldPropagateObject(&collationAddress))
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
EnsureDependenciesExistOnAllNodes(&collationAddress);
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PreprocessRenameCollationStmt is called when the user is renaming the collation. The invocation happens
|
||||
* before the statement is applied locally.
|
||||
|
|
|
@ -37,7 +37,7 @@ static DistributeObjectOps Aggregate_AlterOwner = {
|
|||
.deparse = DeparseAlterFunctionOwnerStmt,
|
||||
.qualify = QualifyAlterFunctionOwnerStmt,
|
||||
.preprocess = PreprocessAlterFunctionOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterFunctionOwnerStmt,
|
||||
.address = AlterFunctionOwnerObjectAddress,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
@ -269,7 +269,7 @@ static DistributeObjectOps Collation_AlterOwner = {
|
|||
.deparse = DeparseAlterCollationOwnerStmt,
|
||||
.qualify = QualifyAlterCollationOwnerStmt,
|
||||
.preprocess = PreprocessAlterCollationOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterCollationOwnerStmt,
|
||||
.address = AlterCollationOwnerObjectAddress,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
@ -373,7 +373,7 @@ static DistributeObjectOps Function_AlterOwner = {
|
|||
.deparse = DeparseAlterFunctionOwnerStmt,
|
||||
.qualify = QualifyAlterFunctionOwnerStmt,
|
||||
.preprocess = PreprocessAlterFunctionOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterFunctionOwnerStmt,
|
||||
.address = AlterFunctionOwnerObjectAddress,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
@ -437,7 +437,7 @@ static DistributeObjectOps Procedure_AlterOwner = {
|
|||
.deparse = DeparseAlterFunctionOwnerStmt,
|
||||
.qualify = QualifyAlterFunctionOwnerStmt,
|
||||
.preprocess = PreprocessAlterFunctionOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterFunctionOwnerStmt,
|
||||
.address = AlterFunctionOwnerObjectAddress,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
@ -581,7 +581,7 @@ static DistributeObjectOps Routine_AlterOwner = {
|
|||
.deparse = DeparseAlterFunctionOwnerStmt,
|
||||
.qualify = QualifyAlterFunctionOwnerStmt,
|
||||
.preprocess = PreprocessAlterFunctionOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterFunctionOwnerStmt,
|
||||
.address = AlterFunctionOwnerObjectAddress,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
@ -647,7 +647,7 @@ static DistributeObjectOps Statistics_AlterOwner = {
|
|||
.deparse = DeparseAlterStatisticsOwnerStmt,
|
||||
.qualify = QualifyAlterStatisticsOwnerStmt,
|
||||
.preprocess = PreprocessAlterStatisticsOwnerStmt,
|
||||
.postprocess = NULL,
|
||||
.postprocess = PostprocessAlterStatisticsOwnerStmt,
|
||||
.address = NULL,
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
|
|
@ -1584,6 +1584,32 @@ PreprocessAlterFunctionOwnerStmt(Node *node, const char *queryString,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* PostprocessAlterFunctionOwnerStmt is invoked after the owner has been changed locally.
|
||||
* Since changing the owner could result in new dependencies being found for this object
|
||||
* we re-ensure all the dependencies for the function do exist.
|
||||
*
|
||||
* This is solely to propagate the new owner (and all its dependencies) if it was not
|
||||
* already distributed in the cluster.
|
||||
*/
|
||||
List *
|
||||
PostprocessAlterFunctionOwnerStmt(Node *node, const char *queryString)
|
||||
{
|
||||
AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node);
|
||||
AssertObjectTypeIsFunctional(stmt->objectType);
|
||||
|
||||
ObjectAddress address = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
if (!ShouldPropagateAlterFunction(&address))
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
EnsureDependenciesExistOnAllNodes(&address);
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PreprocessDropFunctionStmt gets called during the planning phase of a DROP FUNCTION statement
|
||||
* and returns a list of DDLJob's that will drop any distributed functions from the
|
||||
|
|
|
@ -427,6 +427,37 @@ PreprocessAlterStatisticsOwnerStmt(Node *node, const char *queryString,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* PostprocessAlterStatisticsOwnerStmt is invoked after the owner has been changed locally.
|
||||
* Since changing the owner could result in new dependencies being found for this object
|
||||
* we re-ensure all the dependencies for the statistics do exist.
|
||||
*
|
||||
* This is solely to propagate the new owner (and all its dependencies) if it was not
|
||||
* already distributed in the cluster.
|
||||
*/
|
||||
List *
|
||||
PostprocessAlterStatisticsOwnerStmt(Node *node, const char *queryString)
|
||||
{
|
||||
AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node);
|
||||
Assert(stmt->objectType == OBJECT_STATISTIC_EXT);
|
||||
|
||||
Oid statsOid = get_statistics_object_oid((List *) stmt->object, false);
|
||||
Oid relationId = GetRelIdByStatsOid(statsOid);
|
||||
|
||||
if (!IsCitusTable(relationId) || !ShouldPropagate())
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
ObjectAddress statisticsAddress = { 0 };
|
||||
ObjectAddressSet(statisticsAddress, StatisticExtRelationId, statsOid);
|
||||
|
||||
EnsureDependenciesExistOnAllNodes(&statisticsAddress);
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetExplicitStatisticsCommandList returns the list of DDL commands to create
|
||||
* or alter statistics that are explicitly created for the table with relationId.
|
||||
|
|
|
@ -146,6 +146,7 @@ extern List * PreprocessDropCollationStmt(Node *stmt, const char *queryString,
|
|||
extern List * PreprocessAlterCollationOwnerStmt(Node *stmt, const char *queryString,
|
||||
ProcessUtilityContext
|
||||
processUtilityContext);
|
||||
extern List * PostprocessAlterCollationOwnerStmt(Node *node, const char *queryString);
|
||||
extern List * PreprocessAlterCollationSchemaStmt(Node *stmt, const char *queryString,
|
||||
ProcessUtilityContext
|
||||
processUtilityContext);
|
||||
|
@ -281,6 +282,7 @@ extern ObjectAddress RenameFunctionStmtObjectAddress(Node *stmt,
|
|||
bool missing_ok);
|
||||
extern List * PreprocessAlterFunctionOwnerStmt(Node *stmt, const char *queryString,
|
||||
ProcessUtilityContext processUtilityContext);
|
||||
extern List * PostprocessAlterFunctionOwnerStmt(Node *stmt, const char *queryString);
|
||||
extern ObjectAddress AlterFunctionOwnerObjectAddress(Node *stmt,
|
||||
bool missing_ok);
|
||||
extern List * PreprocessAlterFunctionSchemaStmt(Node *stmt, const char *queryString,
|
||||
|
@ -432,6 +434,7 @@ extern List * PreprocessAlterStatisticsStmt(Node *node, const char *queryString,
|
|||
extern List * PreprocessAlterStatisticsOwnerStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext
|
||||
processUtilityContext);
|
||||
extern List * PostprocessAlterStatisticsOwnerStmt(Node *node, const char *queryString);
|
||||
extern List * GetExplicitStatisticsCommandList(Oid relationId);
|
||||
extern List * GetExplicitStatisticsSchemaIdList(Oid relationId);
|
||||
extern List * GetAlterIndexStatisticsCommands(Oid indexOid);
|
||||
|
|
Loading…
Reference in New Issue