Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, zengman <zengman(at)halodbtech(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2025-12-20 11:37:57
Message-ID: CALdSSPgj0+Bp0DujZmsX-xVq=k85E2OXNsvKqoak8EU7xpFVYA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 20 Dec 2025 at 16:27, Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
>
> On Sat, Dec 20, 2025 at 1:15 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> > On Sat, Dec 20, 2025 at 6:42 PM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
> > >
> > > Hi Kirill!
> >
> > > > reshke=# alter table only z merge partitions (z_1,z_2) into z_12;
> > > > ALTER TABLE
> > > > reshke=#
> > > >
> > > > ```
> > > >
> > > > IMO "alter table only ... merge partitions" does not make perfect
> > > > sense and should be rejected rather than executed. WDYT?
> > >
> > > Could you, please, clarify your point? I didn't quite get it. It
> > > looks like pretty basic example of merging two adjacent partitions.
> > >
> >
> > > reshke=# alter table only z merge partitions (z_1,z_2) into z_12;
> > I think it should fail, because we are not applying to table "z" itself,
> > For Split/Merge partitions, we are processing the whole partitioned
> > table z hierarchy.
> >
> > alter table z merge partitions (z_1,z_2) into z_12;
> > should work.
> >
> > I guess the attached maybe is what Krill wants.

Jian, Thank, you got me right. Your patch is addressing the problem I
talk about, yes. The only issue about your patch is the actual error
message (error hint is exactly on point.)

So, instead of

```
+ERROR: ALTER TABLE MERGE PARTITIONS must apply to child tables too
+HINT: Do not specify the ONLY keyword.
``

I would prefer (something like)

```
+ERROR: ALTER TABLE MERGE PARTITIONS is a non-recursive command.
+HINT: Do not specify the ONLY keyword.
``

On Sat, 20 Dec 2025 at 16:27, Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:

> I don't think the problem with ONLY keyword is
> that MERGE/SPLIT must be always recursive. I think opposite, it's
> always non-recursive and this is why ONLY is meaningless. Otherwise,
> we may decide to just leave it as it allowing ONLY.

+1

--
Best regards,
Kirill Reshke

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message zengman 2025-12-20 12:21:39 Re: Inline non-SQL SRFs using SupportRequestSimplify
Previous Message Pavel Stehule 2025-12-20 11:36:11 Re: Inline non-SQL SRFs using SupportRequestSimplify