public inbox for [email protected]
help / color / mirror / Atom feedFrom: jian he <[email protected]>
To: Dmitry Koval <[email protected]>
Cc: [email protected]
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: Wed, 18 Jun 2025 10:55:38 +0800
Message-ID: <CACJufxHjpdeDtOsmz9TyGX7jFU73LBEjX=JQpRQdAvDadT0coA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org>
<CACJufxFGPLTDW55bgaBTH1uCf0=YUZUVKWFrTBvOZNYKc49MxA@mail.gmail.com>
<CACJufxHHnJm6Jb2YQpuRU1RX__tO=JJNJ5=EUMuzif_KNxGd9A@mail.gmail.com>
<CACJufxFkscyhak2cSr8t+EPfwv11yccfEZBBnPbX4tRc_mWkXQ@mail.gmail.com>
<[email protected]>
<CACJufxHRX6xQtzn+KenK3SDR2+4kUpVnO+0axforV_pohwMnFw@mail.gmail.com>
<[email protected]>
<CACJufxHNvb6PpeGDEkzZMnKHjZrQGBHRUENKb2AwZ4N3Q8G3fg@mail.gmail.com>
<[email protected]>
<CACJufxE6mU7Za2X5Z4Cs9jEmgfjTYPy_ChiVXND5ZEZ3xM665g@mail.gmail.com>
<[email protected]>
<CACJufxHakPGgUHfe4uThY2u_Hzq3YOP9m4B3gjZUTUm2mbVryA@mail.gmail.com>
<CACJufxHo0u=PzgCn88VZEW0mtB=JopchqBTESudUMH+HCyiTpg@mail.gmail.com>
<[email protected]>
<CACJufxFTiAiN_27FzAE60Hm5yQ124EJ+b1dpNDstcSdCApFzLw@mail.gmail.com>
<[email protected]>
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;
Attachments:
[application/octet-stream] v47-0001-rename-function-argument-and-minor-refactor.no-cfbot (18.1K, ../CACJufxHjpdeDtOsmz9TyGX7jFU73LBEjX=JQpRQdAvDadT0coA@mail.gmail.com/2-v47-0001-rename-function-argument-and-minor-refactor.no-cfbot)
download
view thread (178+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
In-Reply-To: <CACJufxHjpdeDtOsmz9TyGX7jFU73LBEjX=JQpRQdAvDadT0coA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox