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

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

On 2025-Feb-04, vignesh C wrote:

> We should throw an error for partitioned tables that contain foreign
> partitions, as this would include the data from these foreign tables
> during the initial sync, while incremental changes would not be
> replicated.

Hmm, I would support the idea of allowing partitioned tables containing
foreign partitions into publications, where only the tuples in
non-foreign partitions would be transmitted -- both during initial sync
and during replicated DML. This way, any partitioned tables with mixed
local and foreign partitions would work okay for replication. If the
subscriber wants the data in the foreign partitions, they can create the
foreign table on the subscription side and all is well. From a users
POV this is probably the most useful.

Another aspect is the case where you create the publication first and
the foreign table later. I didn't spot in the proposed patch any code
that would check whether a publication including this schema exists,
which we would have to do if we wanted to be watertight about rejecting
publications with foreign tables. But I think that would be a bad
direction to go it.

I'd rather have the table-listing code for publications skip any foreign
tables. For instance, GetPubPartitionOptionRelations() and
PublicationAddTables() should skip tables with relkind RELKIND_FOREIGN.
The sync code should also silently ignore all foreign tables.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"I am amazed at [the pgsql-sql] mailing list for the wonderful support, and
lack of hesitasion in answering a lost soul's question, I just wished the rest
of the mailing list could be like this." (Fotis)
https://postgr.es/m/200606261359.k5QDxE2p004593@auth-smtp.hol.gr

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-02-04 16:13:23 Re: Better title output for psql \dt \di etc. commands
Previous Message Alena Rybakina 2025-02-04 15:49:43 Re: Vacuum statistics