Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
Cc: Alexander Korotkov <aekorotkov(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2025-08-22 03:36:45
Message-ID: CACJufxEH45Rtkn=n9hjakeKEkH7ou8domh+iQHMp+18Wq_L-4g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 21, 2025 at 2:45 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Thu, Aug 21, 2025 at 10:53 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> >
> > > this time, I only checked
> > > v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch

hi.

+static void
+check_two_partitions_bounds_range(Relation parent,
+{
....
+
+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("lower bound of partition \"%s\" is not equal to the upper
bound of partition \"%s\"",
+ second_name->relname, first_name->relname),
+ errhint("ALTER TABLE ... MERGE PARTITIONS requires the partition
bounds to be adjacent."),
+ parser_errposition(pstate, datum->location));
+ }

I propose change it to:
ereport(ERROR,
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("can not merge partition \"%s\" together with
partition \"%s\"",
second_name->relname, first_name->relname),
errdetail("lower bound of partition \"%s\" is not
equal to the upper bound of partition \"%s\"",
second_name->relname, first_name->relname),
errhint("ALTER TABLE ... MERGE PARTITIONS requires the
partition bounds to be adjacent."),
parser_errposition(pstate, datum->location));

<para>
+ There is also an option for merging multiple table partitions into
+ a single partition using the
+ <link linkend="sql-altertable-merge-partitions"><command>ALTER
TABLE ... MERGE PARTITIONS</command></link>.
+ This feature simplifies the management of partitioned tables by allowing
+ users to combine partitions that are no longer needed as
+ separate entities. It's important to note that this operation is not
+ supported for hash-partitioned tables and acquires an
+ <literal>ACCESS EXCLUSIVE</literal> lock, which could impact high-load
+ systems due to the lock's restrictive nature. For example, we can
+ merge three monthly partitions into one quarter partition:
I am not sure last sentence "merge three monthly partitions into one
quarter partition:"
is correct.

buildExpressionExecutionStates seems not needed, same reason as
mentioned before,
code pattern aligned with ATRewriteTable.
while at it, also did some minor changes.

Attachment Content-Type Size
v52-0001-refactor-buildExpressionExecutionStates.no-cfbot application/octet-stream 4.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-08-22 04:08:25 Re: Logical Replication of sequences
Previous Message Euler Taveira 2025-08-22 03:18:37 Re: Add support for specifying tables in pg_createsubscriber.