Re: Fix SPLIT PARTITION bound-overlap bug and other improvements

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Re: Fix SPLIT PARTITION bound-overlap bug and other improvements
Date: 2026-05-14 06:58:38
Message-ID: D4A592C8-76F4-41A4-9746-2FED6BED625A@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On May 14, 2026, at 04:47, Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> wrote:
>
> Hi, Chao Li!
>
> Thank you for the bug report, test script, and fix!
>
> >> 0. A bound-overlap bug
>
> I think this fix should be applied without much discussion:
> ------------------------------------------------------------------------
> diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
> index 9b4277a4987..8b8f90569fe 100644
> --- a/src/backend/partitioning/partbounds.c
> +++ b/src/backend/partitioning/partbounds.c
> @@ -5419,7 +5419,8 @@ check_partition_bounds_for_split_range(Relation parent,
> "ALTER TABLE ... SPLIT PARTITION"),
> parser_errposition(pstate, exprLocation((Node *) datum)));
> }
> - else
> +
> + if (last)
> {
> PartitionRangeBound *split_upper;
> ------------------------------------------------------------------------

Thanks for your confirmation.

>
> >> 1. The documentation about splitting with a DEFAULT partition is a bit unclear
> >> ...
> >> 2. I found this hint message confusing:
> >> ...
>
> Unfortunately, I cannot comment on these points; it would be good to get the opinion of people who know English well.

I want to add one more point about these two changes.

There is a code comment saying that when a DEFAULT partition is specified, the new partition's lower bound may be greater than the original lower bound:
```
/*
* The lower bound of "spec" must equal the lower bound of the
* split partition. However, if one of the new partitions is
* DEFAULT, then it is ok for the new partition's lower bound to
* be greater than that of the split partition.
*/
```

This also indicates that the original hint message mentioning “exactly match" is wrong for the DEFAULT case.

>
>
> >> 3. SPLIT PARTITION currently provides another way to add a DEFAULT partition:
> >> ...
>
> Agreed, this is another way to add a DEFAULT partition. But I'm not sure that this way should be disabled (using the special function check_split_partition_not_same_bound)...
> Maybe it's better to keep it "as is"?
>

Yeah, this may be worth more discussion. But I think we should either reject this usage or add a fast path to avoid unnecessary creation of a new partition, data movement, etc. Otherwise, it feels more like a misuse of SPLIT PARTITION rather than a useful new alternative.

To make this patch easier to process, I split it into 4 commits:

0001 - Fixes the bound-overlap bug
0002 - Fix the incorrect HINT message for the DEFAULT case
0003 - Fix the incorrect description about combined bound in the SGML doc
0004 - Reject only-create-default-partition usage

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v2-0001-Fix-SPLIT-PARTITION-range-bound-validation-with-D.patch application/octet-stream 4.0 KB
v2-0002-Fix-SPLIT-PARTITION-hint-for-DEFAULT-partition-bo.patch application/octet-stream 3.4 KB
v2-0003-Clarify-SPLIT-PARTITION-bound-requirements-in-doc.patch application/octet-stream 3.8 KB
v2-0004-Reject-degenerate-SPLIT-PARTITION-with-DEFAULT-pa.patch application/octet-stream 6.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-05-14 07:02:25 Re: Adding REPACK [concurrently]
Previous Message Michael Paquier 2026-05-14 06:58:18 Re: Fix bug with accessing to temporary tables of other sessions