Re: MERGE/SPLIT PARTITIONS issues/questions

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: MERGE/SPLIT PARTITIONS issues/questions
Date: 2026-08-14 15:49:35
Message-ID: CAPpHfdvgCQhFMqtqQ6aVbT03kqp13HAC4qHZ64vgc4OnT7TRgA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Fri, Aug 14, 2026 at 5:51 PM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
>
> On Fri, Aug 14, 2026 at 10:08 AM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> >
> > > On 12 Aug 2026, at 22:48, Melanie Plageman <melanieplageman(at)gmail(dot)com> wrote:
> >
> > > The user needs to add RLS to the new leaf partitions if they want the
> > > same level of security, but I'm not sure that's intuitive.
> >
> > It's not, and it quite easily will leave the data without the intended
> > protection during a window.
> >
> > > Also, for merging partitions, if you merge two partitions that have
> > > the same RLS, after merging, the new merged partition doesn't have
> > > that RLS policy -- that seems confusing too
> >
> > I would rank this as even more unintuitive than the previous case, as a user I
> > would expect the new partition to have the shared policy.
> >
> > Could we make this safe by restricting to the cases where partitions match the
> > parent and we can make them not drop characteristics? If we want to expand
> > which differences can be handled in a safe manner in 20 then we can revisit,
> > rather than being very lax now and try to restrict later.
>
> Yes, I don't think it makes sense to silently drop the properties in
> 19 and then start automatically propagating them in 20. That seems
> like it will be really confusing for users that have scripts to, for
> example, recreate ACLs for the merged or split partition(s) when using
> 19.

I agree that this kind of changing behavior is not acceptable. My
proposal is to reject partitions with row-level security/policies for
19. Then we could add automatic copy of row-level security/policies
for 20. If changing one behavior to another incompatible behavior is
not acceptable, but changing from ERRCODE_FEATURE_NOT_SUPPORTED to new
behavior seems acceptable (new releases support more features). Or
alternatively we could add copying of row-level security/policies as
an option in SQL statement for 20.

SPLIT/MERGE partition(s) seemed like not so complex feature, but many
aspects like this arise. It would be nice if we could come with some
restricted version for 19, and expand it for 20 and later releases
(rather than re-trying large patchset for 20).

Attached 0004 implements check that source partition doesn't have
ow-level security/policies.

0003 also have integrated edits proposed by Zsolt [1].

Links.
1. https://www.postgresql.org/message-id/CAN4CZFMNhEF85h7h1su30h9E4cExGKpSSViZ2EqggNqAX%2BXtng%40mail.gmail.com

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v4-0001-Don-t-logically-decode-MERGE-SPLIT-PARTITION-row-.patch application/octet-stream 11.2 KB
v4-0002-Peserve-replica-identity-and-publications-in-MERG.patch application/octet-stream 24.8 KB
v4-0004-Reject-MERGE-SPLIT-of-partitions-with-row-level-s.patch application/octet-stream 15.3 KB
v4-0003-Don-t-recalculate-generated-columns-during-MERGE-.patch application/octet-stream 52.4 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-08-14 16:15:44 Re: COPY TO regression with psql -c
Previous Message Adrian Mönnich 2026-08-14 15:10:23 Re: BUG #19449: Massive performance degradation for complex query on Postgres 16+ (few seconds -> multiple hours)

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Kane 2026-08-14 15:52:27 Fix conversion warnings in headers
Previous Message Bertrand Drouvot 2026-08-14 15:27:44 Re: Offline data checksum changes can cause incorrect checksum state on standbys