mirror of https://github.com/citusdata/citus.git
Use InvalidateForeignKeyGraph in postprocess
parent
904bc71a07
commit
ee502453d6
|
@ -204,7 +204,7 @@ PostprocessCreateTableStmt(CreateStmt *createStatement, const char *queryString)
|
||||||
/* invalidate foreign key cache if the table involved in any foreign key */
|
/* invalidate foreign key cache if the table involved in any foreign key */
|
||||||
if ((TableReferenced(relationId) || TableReferencing(relationId)))
|
if ((TableReferenced(relationId) || TableReferencing(relationId)))
|
||||||
{
|
{
|
||||||
MarkInvalidateForeignKeyGraph();
|
InvalidateForeignKeyGraph();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement, const
|
||||||
*/
|
*/
|
||||||
if ((TableReferenced(parentRelationId) || TableReferencing(parentRelationId)))
|
if ((TableReferenced(parentRelationId) || TableReferencing(parentRelationId)))
|
||||||
{
|
{
|
||||||
MarkInvalidateForeignKeyGraph();
|
InvalidateForeignKeyGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
|
||||||
*/
|
*/
|
||||||
if ((TableReferenced(relationId) || TableReferencing(relationId)))
|
if ((TableReferenced(relationId) || TableReferencing(relationId)))
|
||||||
{
|
{
|
||||||
MarkInvalidateForeignKeyGraph();
|
InvalidateForeignKeyGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -515,8 +515,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
}
|
}
|
||||||
PG_CATCH();
|
PG_CATCH();
|
||||||
{
|
{
|
||||||
PostStandardProcessUtility(parsetree);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We call MarkInvalidateForeignKeyGraph in preprocess without knowing
|
* We call MarkInvalidateForeignKeyGraph in preprocess without knowing
|
||||||
* that if command would fail or not. However, we don't want to invalidate
|
* that if command would fail or not. However, we don't want to invalidate
|
||||||
|
@ -528,6 +526,8 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
*/
|
*/
|
||||||
shouldInvalidateForeignKeyGraph = false;
|
shouldInvalidateForeignKeyGraph = false;
|
||||||
|
|
||||||
|
PostStandardProcessUtility(parsetree);
|
||||||
|
|
||||||
PG_RE_THROW();
|
PG_RE_THROW();
|
||||||
}
|
}
|
||||||
PG_END_TRY();
|
PG_END_TRY();
|
||||||
|
@ -577,16 +577,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
PostprocessAlterTableStmtAttachPartition(alterTableStatement, queryString);
|
PostprocessAlterTableStmtAttachPartition(alterTableStatement, queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-forming the foreign key graph relies on the command being executed
|
|
||||||
* on the local table first. However, in order to decide whether the
|
|
||||||
* command leads to an invalidation, we need to check before the command
|
|
||||||
* is being executed since we read pg_constraint table. Thus, we maintain a
|
|
||||||
* local flag and do the invalidation after multi_ProcessUtility,
|
|
||||||
* before ExecuteDistributedDDLJob().
|
|
||||||
*/
|
|
||||||
InvalidateForeignKeyGraphForDDL();
|
|
||||||
|
|
||||||
/* after local command has completed, finish by executing worker DDLJobs, if any */
|
/* after local command has completed, finish by executing worker DDLJobs, if any */
|
||||||
if (ddlJobs != NIL)
|
if (ddlJobs != NIL)
|
||||||
{
|
{
|
||||||
|
@ -912,6 +902,16 @@ static void
|
||||||
PostStandardProcessUtility(Node *parsetree)
|
PostStandardProcessUtility(Node *parsetree)
|
||||||
{
|
{
|
||||||
DecrementUtilityHookCountersIfNecessary(parsetree);
|
DecrementUtilityHookCountersIfNecessary(parsetree);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Re-forming the foreign key graph relies on the command being executed
|
||||||
|
* on the local table first. However, in order to decide whether the
|
||||||
|
* command leads to an invalidation, we need to check before the command
|
||||||
|
* is being executed since we read pg_constraint table. Thus, we maintain a
|
||||||
|
* local flag and do the invalidation after multi_ProcessUtility,
|
||||||
|
* before ExecuteDistributedDDLJob().
|
||||||
|
*/
|
||||||
|
InvalidateForeignKeyGraphForDDL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue