Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2025-06-12 20:36:25
Message-ID: 9c1b75f1-5c40-4a86-9a61-a4b3f1d7ec60@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Jian He!

Thanks for the notes and patches (again).
I read a part of emails, I hope to read the rest emails tomorrow.

1.
>The attached patch ensures that the newly merged partition is
>evaluated against all of its check constraints and that all stored
>generated columns are recomputed, i guess this would be more safe.
>v43-0001-MERGE-PARTITIONS-constraint-revalidation.no-cfbot

I modified the patch to apply it to the SPLIT PARTITION command too.

2.
>but BuildDescForRelation is based on getAttributesList,
>in getAttributesList, assign pg_attribute.attidentity to def->identity
>should be safe, IMHO.

You are right. Corrected.

3.
+<para>
+If merged partitions have different owners, an error will be generated
>since they <para> are related, these two can be one <para>?

Changed.

4.
>I feel like it's not fully accurate, the following is what I can come
>up with:
>+<para>
>+ When partitions are merged, any individual objects belonging to

Changed.

5.
> /*
> * Detaching the partition might involve TOAST table access, so ensure
> * we have a valid snapshot.
> */
> PushActiveSnapshot(GetTransactionSnapshot());
> /* Do the final part of detaching */
> DetachPartitionFinalize(rel, partRel, concurrent, defaultPartOid);
> PopActiveSnapshot();
>do we need do the same to the following DetachPartitionFinalize:
>...

Thanks. This needs to be done, especially after the recent commit [1].
Fixed.

Links.
------
[1] Ensure we have a snapshot when updating various system catalogs,
https://github.com/postgres/postgres/commit/706054b11b959c865c0c7935c34d92370d7168d4

--
With best regards,
Dmitry Koval

Postgres Professional: http://postgrespro.com

Attachment Content-Type Size
v44-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch text/plain 165.4 KB
v44-0002-Implement-ALTER-TABLE-.-SPLIT-PARTITION-.-comman.patch text/plain 222.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2025-06-12 20:39:00 Re: pg_dump --with-* options
Previous Message Nathan Bossart 2025-06-12 20:22:13 Re: pg_dump --with-* options