From 81eb1fc166ebf5d46d708d0c892842de593fbd39 Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Fri, 20 Aug 2021 15:36:12 +0300 Subject: [PATCH] Convert all to CLT if a child gets converted --- .../commands/citus_add_local_table_to_metadata.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/backend/distributed/commands/citus_add_local_table_to_metadata.c b/src/backend/distributed/commands/citus_add_local_table_to_metadata.c index a347a6875..22d90483f 100644 --- a/src/backend/distributed/commands/citus_add_local_table_to_metadata.c +++ b/src/backend/distributed/commands/citus_add_local_table_to_metadata.c @@ -130,6 +130,22 @@ citus_add_local_table_to_metadata_internal(Oid relationId, bool cascadeViaForeig "to 'off' to disable this behavior"))); } + /* + * If the relation is a partition, we need to convert all the partitioned table + * to Citus Local Table. To do that, we call CreateCitusLocalTable with the parent + * relation, instead of the child, since this will cause the parent and all the + * partition child tables to become a Citus Local Table. + */ + if (PartitionTable(relationId)) + { + Oid parentOid = PartitionParentOid(relationId); + if (OidIsValid(parentOid) && !IsCitusTable(parentOid)) + { + CreateCitusLocalTable(parentOid, cascadeViaForeignKeys); + return; + } + } + CreateCitusLocalTable(relationId, cascadeViaForeignKeys); }