Inherit parent's autoconverted & add test

talha_tes1
Ahmet Gedemenli 2021-10-25 15:05:56 +03:00
parent d4036a949b
commit 2aad28d86d
2 changed files with 14 additions and 1 deletions

View File

@ -426,8 +426,11 @@ CreateCitusLocalTablePartitionOf(CreateStmt *createStatement, Oid relationId,
*/ */
DropRelationForeignKeys(relationId, fKeyFlags); DropRelationForeignKeys(relationId, fKeyFlags);
/* get the autoconverted field from the parent */
CitusTableCacheEntry *entry = GetCitusTableCacheEntry(parentRelationId);
bool cascade = false; bool cascade = false;
bool autoConverted = false; bool autoConverted = entry->autoConverted;
CreateCitusLocalTable(relationId, cascade, autoConverted); CreateCitusLocalTable(relationId, cascade, autoConverted);
ExecuteAndLogUtilityCommand(attachCommand); ExecuteAndLogUtilityCommand(attachCommand);
} }

View File

@ -325,6 +325,16 @@ SELECT logicalrelid, autoconverted FROM pg_dist_partition
'table_auto_conv_child_2'::regclass) 'table_auto_conv_child_2'::regclass)
ORDER BY logicalrelid; 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 -- 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; 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); CREATE TABLE reference_table_1(r1 int UNIQUE, r2 int);