hi. The following are changes I made based on v47. mainly comments refactoring, variable/argument renaming. please see the attached patch.
+ + /* Create the relation. */ + newRelId = heap_create_with_catalog(newPartName->relname, + namespaceId, + modelRel->rd_rel->reltablespace, +.... + allowSystemTableMods, + false, + InvalidOid, + NULL); heap_create_with_catalog parameter is_internal should be set to true. + /* + * Construct a map from the LIKE relation's attnos to the child rel's. + * This re-checks type match etc, although it shouldn't be possible to + * have a failure since both tables are locked. + */ + attmap = build_attrmap_by_name(RelationGetDescr(newRel), + tupleDesc, + false); this comment in createTableConstraints is confusing, especially the word "LIKE". I didn' change it though. +/* + * moveMergedTablesRows: scan partitions to be merged (mergingPartitions) + * of the partitioned table (rel) and move rows into the new partition + * (newPartRel). We also reevaulate check constraints against these rows. + */ +static void +moveMergedTablesRows(List **wqueue, Relation rel, + List *mergingPartitions, Relation newPartRel) the argument (Relation rel) never used in moveMergedTablesRows we can remove it, or rename it as "parent_rel". I didn' change it though. moveMergedTablesRows was never used in SPLIT PARTITION, so maybe we can rename it to ATMergePartitionMoveTablesRows or ATMergePartitionMoveRows or ATMergePartitionRows what do you think? check_two_partitions_bounds_range we can name it to range_partition_bounds_check I don't have a huge opinion though. createTableConstraints(List **wqueue, AlteredTableInfo *tab, Relation modelRel, Relation newRel) rename argument (Relation modelRel) to parent_rel, I think it will improve readability, since "parent_rel" can tell you it's a partitioned table. ATExecMergePartitions some comments position adjusted. minor change src/test/regress/sql/partition_merge.sql -SELECT * FROM sales_list; -SELECT * FROM sales_nord; -SELECT * FROM sales_all; +SELECT tableoid::regclass, * FROM sales_list ORDER BY tableoid, salesperson_id; we need an error case for ERROR: cannot drop table \"%s\" because other objects depend on it so I added a test for it. as you can see below, the error HINT message is not great in this context. CREATE VIEW jan2022v as SELECT * FROM sales_jan2022; ALTER TABLE sales_range MERGE PARTITIONS (sales_jan2022, sales_feb2022) INTO sales_dec_jan_feb2022; ERROR: cannot drop table sales_jan2022 because other objects depend on it DETAIL: view jan2022v depends on table sales_jan2022 HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP VIEW jan2022v;
v47-0001-rename-function-argument-and-minor-refactor.no-cfbot
Description: Binary data