Hi, I'd like to propose the attached patch, which makes object address output distinguish publication EXCEPT entries from ordinary publication table mappings.
pg_publication_rel can now represent either an explicitly published table
or a table excluded from a FOR ALL TABLES publication. However,
the object address code currently treats every pg_publication_rel entry
as a publication relation.
For example,
=# CREATE TABLE t (a int);
=# CREATE PUBLICATION p FOR ALL TABLES EXCEPT (TABLE t);
=# SELECT pi.* FROM pg_publication_rel pp CROSS JOIN LATERAL
pg_identify_object('pg_publication_rel'::regclass, pp.oid, 0) AS pi;
type | schema | name | identity
----------------------+--------+--------+---------------------------
publication relation | (null) | (null) | public.t in publication p
=# SELECT pd.* FROM pg_publication_rel pp CROSS JOIN LATERAL
pg_describe_object('pg_publication_rel'::regclass, pp.oid, 0) AS pd;
pd
-----------------------------------------
publication of table t in publication p
Although the pg_publication_rel entry for t represents an exclusion,
the object address output makes it appear to be an ordinary published-table
mapping. This affects pg_identify_object(), pg_describe_object(),
and pg_identify_object_as_address(), and can also be confusing for tools
that use object addresses, such as audit or DDL deparsing tools.
The root cause is that objectaddress.c does not check
pg_publication_rel.prexcept when describing or identifying
pg_publication_rel objects.
The patch fixes this by distinguishing EXCEPT entries. They are now
reported as publication exclusion, with identities such as:
=# SELECT pi.* FROM pg_publication_rel pp CROSS JOIN LATERAL
pg_identify_object('pg_publication_rel'::regclass, pp.oid, 0) AS pi;
type | schema | name | identity
-----------------------+--------+--------+--------------------------------------
publication exclusion | (null) | (null) | public.t excluded from
publication p
=# SELECT pd.* FROM pg_publication_rel pp CROSS JOIN LATERAL
pg_describe_object('pg_publication_rel'::regclass, pp.oid, 0) AS pd;
pd
-----------------------------------------
exclusion of table t from publication p
Thoughts?
Regards,
--
Fujii Masao
v1-0001-Distinguish-publication-exclusions-in-object-addr.patch
Description: Binary data
