Use InvalidateForeignKeyGraph in postprocess

pull/4453/head
Onur Tirtir 2021-01-06 10:44:59 +03:00
parent 904bc71a07
commit ee502453d6
2 changed files with 15 additions and 15 deletions

View File

@ -204,7 +204,7 @@ PostprocessCreateTableStmt(CreateStmt *createStatement, const char *queryString)
/* invalidate foreign key cache if the table involved in any foreign key */
if ((TableReferenced(relationId) || TableReferencing(relationId)))
{
MarkInvalidateForeignKeyGraph();
InvalidateForeignKeyGraph();
}
#endif
@ -263,7 +263,7 @@ PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement, const
*/
if ((TableReferenced(parentRelationId) || TableReferencing(parentRelationId)))
{
MarkInvalidateForeignKeyGraph();
InvalidateForeignKeyGraph();
}
}
@ -353,7 +353,7 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
*/
if ((TableReferenced(relationId) || TableReferencing(relationId)))
{
MarkInvalidateForeignKeyGraph();
InvalidateForeignKeyGraph();
}
}
}

View File

@ -515,8 +515,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,
}
PG_CATCH();
{
PostStandardProcessUtility(parsetree);
/*
* We call MarkInvalidateForeignKeyGraph in preprocess without knowing
* that if command would fail or not. However, we don't want to invalidate
@ -528,6 +526,8 @@ multi_ProcessUtility(PlannedStmt *pstmt,
*/
shouldInvalidateForeignKeyGraph = false;
PostStandardProcessUtility(parsetree);
PG_RE_THROW();
}
PG_END_TRY();
@ -577,16 +577,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,
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 */
if (ddlJobs != NIL)
{
@ -912,6 +902,16 @@ static void
PostStandardProcessUtility(Node *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();
}