From 9851f5d28535907f6add8c02f25e513c620ddacf Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 15 Oct 2025 19:23:50 +0800 Subject: [PATCH v62 1/1] doc refactor alter table merge partitions v62 doc changes. Discussion: https://postgr.es/m/c73a1746-0cd0-6bdd-6b23-3ae0b7c0c582%40postgrespro.ru --- doc/src/sgml/ref/alter_table.sgml | 77 ++++++++++++++++--------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 30dd5ef8466..f8dc2a10209 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1166,32 +1166,34 @@ WITH ( MODULUS numeric_literal, REM This form merges several partitions of the target table into a new partition. Hash-partitioned target table is not supported. + Only simple, non-partitioned partitions can be merged. + The new partition (partition_name) + can have the same name as one of the merged partitions + (partition_name1, + partition_name2 [, ...]). + + + If the DEFAULT partition is not in the - list of partitions partition_name1, - partition_name2 [, ...]: + list of merged partitions: - For range-partitioned tables, the ranges of the partitions - partition_name1, - partition_name2, [...] - must be adjacent in order to be merged. Otherwise, an error will be - raised. The resulting combined range will be the new partition bound - for the partition partition_name. + For range-partitioned tables, the ranges of merged partitions + must be adjacent in order to be merged. + The partition bounds of merged partitions are combined to form the new partition bound for + partition_name. For list-partitioned tables, the partition bounds of - partition_name1, - partition_name2, [...] - are combined to form the new partition bound for + merged partitions are combined to form the new partition bound for partition_name. - If the DEFAULT partition is in the list of partitions partition_name1, - partition_name2 [, ...]: + If the DEFAULT partition is in the list of merged partitions: @@ -1201,42 +1203,41 @@ WITH ( MODULUS numeric_literal, REM - The partition bound specifications for all partitions- - partition_name1, - partition_name2, [...] - can be arbitrary. + The partition bound specifications for merged partitions can be arbitrary. - The new partition partition_name - can have the same name as one of the merged partitions. Only simple, - non-partitioned partitions can be merged. - If merged partitions have different owners, an error will be generated. - The owner of the merged partitions will be the owner of the new partition. - It is the user's responsibility to setup ACL on the + All merged partitions must have the same owner. + The owner of merged partitions will be the owner of the new partition. + It is the user's responsibility to setup ACL on new partition. + - The indexes and identity are created later, after moving the data - into the new partition. - Extended statistics aren't copied from the parent table, for consistency with - CREATE TABLE PARTITION OF. - The new partition will inherit the same table access method, persistence - type, and tablespace as the parent table. + ALTER TABLE MERGE PARTITION uses the partitioned table itself + as the template to construct the new partition. + The new partition will inherit the same table access method, persistence + type, and tablespace as the partitioned table. + + Constraints, column defaults, column generation expressions, identity columns, + indexes, triggers are copied from the partitioned table to the new + partition. But extended statistics, security policies etc won't copied from + the partitioned table. + Indexes and identity columns copied from the partitioned table will be + created afterward, once the data has been moved into the new partition. + - When partitions are merged, any individual objects belonging to those - partitions, such as constraints or statistics, will be dropped. This occurs - because ALTER TABLE MERGE PARTITIONS uses the partitioned table itself as the - template to define these objects. - - - If merged partitions have some objects dependent on them, the command can - not be done (CASCADE is not used, and an error will - be returned). + When partitions are merged, any objects depend on this partition, such as + constraints, triggers, extended statistics etc will be dropped. + Eventually we will drop all the merged partitions (using RESTRICT mode) too, + therefore if any objects still dependent on it, + ALTER TABLE MERGE PARTITION would fail. + (see ). + Merging partitions acquires an ACCESS EXCLUSIVE lock on -- 2.34.1