Re: DOCS - Clarify the publication 'publish_via_partition_root' default value.

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: DOCS - Clarify the publication 'publish_via_partition_root' default value.
Date: 2025-12-15 00:25:55
Message-ID: CAHut+Ptz=byEuVf3ThEma6KmuVyxPVjNaD2nR9ozFgY3wP1CBQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 12, 2025 at 12:32 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
>
> > On Dec 12, 2025, at 07:12, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> wrote:
> >
> > On Thu, Dec 11, 2025 at 12:22 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> >>> Why not just say clearly what the default value is?
> >>>
> >>> PSA: a patch to do that.
> >
> > LGTM. (In fact I've read that paragraph three times and still cannot
> > get it to stick in my head, despite having done a fair amount of
> > thinking about publish_via_partition_root, so if you have further
> > improvement ideas I'm all ears.)
> >

Yeah, I proposed only a very small patch instead of a rewrite only
because I thought it would have a better chance of acceptance, not
because I had any love for the rest of that paragraph.

>
> My feeling is that the preceding long sentence has described both sides expect explicitly mentioning true and false, which makes the following sentence, no matter the original version and the patched version sounds slightly redundant. So I think maybe we can rework the entire paragraph like:
>
> ```
> This parameter controls how changes to a partitioned table (or any of its partitions) are published. When set to true, changes are published using the identity and schema of the partitioned table. When set to false (the default), changes are published using the identity and schema of the individual partitions
> where the changes actually occurred. Enabling this option allows the changes to be replicated into a non-partitioned table or into a partitioned table whose
> partition structure differs from that of the publisher.
> ```
>

AFAIK, Chao's improved text is mostly good, except I think there might
be some nuances when there are multiple levels of partitioning.

For example, maybe you need to make this change?
BEFORE
When set to true, changes are published using the identity and schema
of the partitioned table
AFTER
When set to true, changes are published using the identity and schema
of the root partitioned table
~~~

Experiment:

CREATE TABLE t1(a int) PARTITION BY RANGE(a);
|
+-- CREATE TABLE t1_p1 PARTITION OF t1 FOR VALUES FROM (0) TO (5)
PARTITION BY RANGE(a);
| |
| + CREATE TABLE t1_p1_p1 PARTITION OF t1_p1 FOR VALUES FROM (0) TO (3);
| + CREATE TABLE t1_p1_p2 PARTITION OF t1_p1 FOR VALUES FROM (3) TO (5);
|
+-- CREATE TABLE t1_p2 PARTITION OF t1 FOR VALUES FROM (5) TO (10);

CREATE PUBLICATION pub1 FOR ALL TABLES WITH (publish_via_partition_root = true);

Subscriber:
CREATE SUBSCRIPTION sub1 CONNECTION 'dbname=test_pub' PUBLICATION pub1;
test_sub=# CREATE TABLE t1(a int);
test_sub=# CREATE TABLE t1_p1(a int);
test_sub=# CREATE TABLE t1_p2(a int);
test_sub=# CREATE TABLE t1_p1_p1(a int);
test_sub=# CREATE TABLE t1_p1_p2(a int);

Publisher:
Here we are inserting into a sub-partitioned table.

INSERT INTO t1_p1 VALUES (2);

Result (subscriber)
test_sub=#
test_sub=# select * from t1;
a
---
2
(1 row)

test_sub=# select * from t1_p1;
a
---
(0 rows)

Notice the data writes using the *root* partitioned table. Not just
the nearest partitioned table.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-12-15 00:55:43 Re: [Proposal] Adding callback support for custom statistics kinds
Previous Message Chao Li 2025-12-14 23:25:56 Fixes a typo in tablecmd