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 255dfbbe4..9bdbfb3c0 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 @@ -426,8 +426,11 @@ CreateCitusLocalTablePartitionOf(CreateStmt *createStatement, Oid relationId, */ DropRelationForeignKeys(relationId, fKeyFlags); + /* get the autoconverted field from the parent */ + CitusTableCacheEntry *entry = GetCitusTableCacheEntry(parentRelationId); + bool cascade = false; - bool autoConverted = false; + bool autoConverted = entry->autoConverted; CreateCitusLocalTable(relationId, cascade, autoConverted); ExecuteAndLogUtilityCommand(attachCommand); } diff --git a/src/test/regress/sql/auto_undist_citus_local.sql b/src/test/regress/sql/auto_undist_citus_local.sql index 759421529..c1873e4d0 100644 --- a/src/test/regress/sql/auto_undist_citus_local.sql +++ b/src/test/regress/sql/auto_undist_citus_local.sql @@ -325,6 +325,16 @@ SELECT logicalrelid, autoconverted FROM pg_dist_partition 'table_auto_conv_child_2'::regclass) ORDER BY logicalrelid; +-- get the autoconverted field from the parent in case of +-- CREATE TABLE .. PARTITION OF .. +create table citus_local_parent_t(a int, b int REFERENCES table_ref(a)) PARTITION BY RANGE (b); +create table citus_child_t PARTITION OF citus_local_parent_t FOR VALUES FROM (1) TO (10); +-- should be set to true +SELECT logicalrelid, autoconverted FROM pg_dist_partition + WHERE logicalrelid IN ('citus_local_parent_t'::regclass, + 'citus_child_t'::regclass) + ORDER BY logicalrelid; + -- a single drop table cascades into multiple undistributes DROP TABLE IF EXISTS citus_local_table_1, citus_local_table_2, citus_local_table_3, citus_local_table_2, reference_table_1; CREATE TABLE reference_table_1(r1 int UNIQUE, r2 int);