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

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: Dmitry Koval <d.koval@postgrespro.ru>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>, Alexander Korotkov <aekorotkov@gmail.com>
Date: 2026-05-14T06:58:38Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reject degenerate SPLIT PARTITION with DEFAULT partition

  2. Clarify SPLIT PARTITION bound requirements in docs

  3. Fix SPLIT PARTITION hint for DEFAULT partition bounds

  4. Fix SPLIT PARTITION range bound validation with DEFAULT

Attachments


> On May 14, 2026, at 04:47, Dmitry Koval <d.koval@postgrespro.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/