Question Regarding Publication Membership and Inheritance
Hi All,
(CC: Amit, Vignesh, and Nisha, who were involved in the initial discussion)
While working on a new feature to provide an option to skip a set of
tables from ALL TABLES publication in [1]/messages/by-id/CALDaNm1gwuOgdeffd5yUOe=kP6QCq8uSkX1YFMjx8=5PbCvt-Q@mail.gmail.com, we came across the
following behavior related to inherited tables and would like to
confirm whether this is expected.
Please see the test below.
CREATE TABLE t_inh (id int);
CREATE TABLE t_inh_c1 (c1 int) INHERITS (t_inh);
CREATE TABLE t_inh_c2 (c2 int) INHERITS (t_inh);
CREATE PUBLICATION pub1 FOR TABLE t_inh;
--Descendant tables included in publication
postgres=# \dRp+
Owner | All tables | All sequences |
--------+------------+---------------+
shveta | f | f |
Tables:
"public.t_inh"
"public.t_inh_c1"
"public.t_inh_c2"
Remove the inheritance for one of the child tables:
ALTER TABLE t_inh_c1 NO INHERIT t_inh;
t_inh_c1 is removed from the inheritance tree of t_inh.
postgres=# \d+ t_inh
Column | Type |
--------+------
id | integer |
Publications:
"pub1"
Child tables: t_inh_c2
However, the publication still lists t_inh_c1:
postgres=# \dRp+
Owner | All tables | All sequences |
--------+------------+---------------+
shveta | f | f |
Tables:
"public.t_inh"
"public.t_inh_c1"
"public.t_inh_c2"
Even if we add a new descendant table, it does not get reflected in
the publication:
postgres=# CREATE TABLE t_inh_c3 (c3 int) INHERITS (t_inh);
CREATE TABLE
postgres=# \d+ t_inh
Table "public.t_inh"
Column | Type |
--------+---------+
id | integer |
Publications:
"pub1"
Child tables: t_inh_c2,
t_inh_c3
postgres=# \dRp+
Publication pub1
Owner | All tables | All sequences |
--------+------------+---------------+
shveta | f | f |
Tables:
"public.t_inh"
"public.t_inh_c1"
"public.t_inh_c2"
This is different from how partitioned tables behave. In the case of
partitioned tables, adding or removing a partition automatically
includes or excludes it from the publication.
I am slightly leaning towards the opinion that current behavior for
inherited tables is expected. Descendant tables are independent
relations, and once they are added to a publication, they are treated
as independent entities rather than being dynamically tied to the
parent through the inheritance hierarchy.
However, I would like to get feedback from others. Does this look like
a bug, or is this the intended behavior?
If we consider changing the behavior so that removing t_inh_c1 from
the inheritance tree also removes it from the publication, there is
currently no way to determine whether the user created the publication
for t_inh (implicitly expanding to descendants at creation time) or
explicitly for t_inh, t_inh_c1, and t_inh_c2. This makes it difficult
to decide whether an automatic change would be correct.
Should we update the documentation to briefly mention that changes in
the inheritance tree are not reflected in the publication after its
creation unless done manually? Or is there a better approach?
[1]: /messages/by-id/CALDaNm1gwuOgdeffd5yUOe=kP6QCq8uSkX1YFMjx8=5PbCvt-Q@mail.gmail.com
thanks
Shveta
On Monday, March 2, 2026, shveta malik <shveta.malik@gmail.com> wrote:
This is different from how partitioned tables behave. In the case of
partitioned tables, adding or removing a partition automatically
includes or excludes it from the publication.However, I would like to get feedback from others. Does this look like
a bug, or is this the intended behavior?
It’s defacto intended at this point.
Should we update the documentation to briefly mention that changes in
the inheritance tree are not reflected in the publication after its
creation unless done manually? Or is there a better approach?
There is no bug in the existing documentation which corroborates this being
the intended design. The commentary pertaining to ONLY says what this does
and never communicates that future inherit-based interactions come into
play. We tend not to describe things that don’t happen, and the lack of
reported user confusion doesn’t support making an exception here. But a
concrete suggestion could be considered.
David J.
On Tue, Mar 3, 2026 at 11:08 AM David G. Johnston
<david.g.johnston@gmail.com> wrote:
On Monday, March 2, 2026, shveta malik <shveta.malik@gmail.com> wrote:
This is different from how partitioned tables behave. In the case of
partitioned tables, adding or removing a partition automatically
includes or excludes it from the publication.However, I would like to get feedback from others. Does this look like
a bug, or is this the intended behavior?
It’s defacto intended at this point.
Thanks for your feedback. That was my initial understanding as well.
Should we update the documentation to briefly mention that changes in
the inheritance tree are not reflected in the publication after its
creation unless done manually? Or is there a better approach?There is no bug in the existing documentation which corroborates this being the intended design. The commentary pertaining to ONLY says what this does and never communicates that future inherit-based interactions come into play. We tend not to describe things that don’t happen, and the lack of reported user confusion doesn’t support making an exception here.
Okay, I see your point.
But a concrete suggestion could be considered.
We could consider leaving it as is, given that we haven’t received any
user feedback suggesting a need to modify the documentation.
thanks
Shveta