Re: Restrict publishing of partitioned table with a foreign table as partition

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Sergey Tatarintsev <s(dot)tatarintsev(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Restrict publishing of partitioned table with a foreign table as partition
Date: 2025-02-11 11:25:15
Message-ID: CANhcyEXxjq9U7BXxCba3Njz+eHpNzAsSVY2GzbV=8iy5j=UAUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 5 Feb 2025 at 14:14, Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 2025-Feb-05, vignesh C wrote:
>
> > We can maintain the behavior you suggested when the
> > PUBLISH_VIA_PARTITION_ROOT option is set to false. However, when
> > PUBLISH_VIA_PARTITION_ROOT is true, the table data is copied from the
> > root table (as intended by the user), which will also include the
> > foreign table data. In this case, wouldn’t it be better to throw an
> > error?
>
> It sounds to me a reasonable restriction that you can only add a
> partitioned table to a publication if publish_via_partition_root=false.
> Then the case of hybrid partitioned tables is supported, but it requires
> that changes are published directly by partitions, which is sensible
> anyway.
>
I have created a patch with the above approach.
We can create a publication on a partition table with foreign
partition when publish_via_partition_root=false. In this case foreign
partitions will not be published. And if
publish_via_partition_root=true we will throw an error.
Please find the v5 patch.

> In this case, during CREATE FOREIGN TABLE of a partition with this
> condition, we must check whether any publications include the schema
> that the table is being created on (or attached, for ALTER TABLE ATTACH
> PARTITION), and whether there are any publications that are FOR ALL
> TABLES that would be affected.
>

I have handled the above cases and added tests for the same.

> (If we later figure out a way to allow publish_via_partition_root and
> skip the tuples in foreign partitions, it's easy to remove the
> restriction.)
>

Thanks and Regards,
Shlok Kyal

Attachment Content-Type Size
v5-0001-Restrict-publishing-of-partitioned-table-with-for.patch application/octet-stream 25.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2025-02-11 11:26:21 Re: Restrict publishing of partitioned table with a foreign table as partition
Previous Message Amit Kapila 2025-02-11 11:10:48 Re: DOCS - inactive_since field readability