Cover attach partition commands

pull/4453/head
Onur Tirtir 2021-01-06 02:43:30 +03:00
parent 67f677c921
commit fc8cc90845
1 changed files with 30 additions and 0 deletions

View File

@ -251,6 +251,19 @@ PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement, const
CreateDistributedTable(relationId, parentDistributionColumn,
parentDistributionMethod, parentRelationName,
viaDeprecatedAPI);
return;
}
/*
* If parent is a postgres local table, then invalidate foreign key cache
* if the parent table is involved in any foreign key relationship. This is
* because, partition tables inherit foreign keys from parent tables.
* Note that if parent table is a citus table, then CreateDistributedTable
* already invalidates foreign key cache and we handle that case above.
*/
if ((TableReferenced(parentRelationId) || TableReferencing(parentRelationId)))
{
MarkInvalidateForeignKeyGraph();
}
}
@ -326,6 +339,23 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
distributionMethod, parentRelationName,
viaDeprecatedAPI);
}
if (!IsCitusTable(relationId) &&
!IsCitusTable(partitionRelationId))
{
/*
* If parent and child tables are postgres local tables, then invalidate
* foreign key cache if the parent table is involved in any foreign key
* relationship. This is because, partition tables inherit foreign keys
* from parent tables.
* Note that if parent table is a citus table, then CreateDistributedTable
* already invalidates foreign key cache and we handle that case above.
*/
if ((TableReferenced(relationId) || TableReferencing(relationId)))
{
MarkInvalidateForeignKeyGraph();
}
}
}
}