RE: Distinguish publication exclusions in object addresses

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Manuel Reyes Bravo <manuelreyesbravo(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: RE: Distinguish publication exclusions in object addresses
Date: 2026-09-16 09:54:47
Message-ID: OSOPR01MB177251BB29D26575E5AE8538594B92@OSOPR01MB17725.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wednesday, September 16, 2026 5:20 PM Manuel Reyes Bravo <manuelreyesbravo(at)gmail(dot)com> wrote:
>
> Amit asked for an example where the message says a relation is not part
> of the publication while it is. Peter's example goes through the
> pre-existing path; here is one inside the new code:
>
> CREATE TABLE t2(a int);
> CREATE SCHEMA s2; CREATE TABLE s2.t2(a int);
> CREATE PUBLICATION pub FOR ALL TABLES EXCEPT (TABLE s2.t2);
>
> SELECT pg_get_object_address('publication relation','{s2,t2}','{pub}');
> ERROR: "t2" is not a published relation of publication "pub"
>
> SELECT schemaname, tablename FROM pg_publication_tables
> WHERE pubname = 'pub';
> schemaname | tablename
> ------------+-----------
> public | t2
>
> So the message says that "t2" is not a published relation of pub, while
> the catalog says that a t2 is. They are different tables, and the user
> cannot tell which one the message is about.

In this case, the user is explicitly passing s2.t2 as a parameter to get its
object address. In that context, it's pretty clear to me that t2 in the message
refers exactly to the object the user passed, I personally don't think it could
point to any other table.

>
> Attached is a small patch on top of v5 that reports the schema too, in
> the form publicationcmds.c already uses for its own messages:
>
> errmsg("cannot use column list for relation \"%s.%s\" in
> publication \"%s\"",
> get_namespace_name(RelationGetNamespace(pri->relation)),
> RelationGetRelationName(pri->relation), pubname)
>
> With it:
>
> ERROR: "s2.t2" is not a published relation of publication "pub"

To me, the real issue is the documentation stating that we can only get an
object address if the object is explicitly added to the catalog (e.g., via FOR
TABLE), and that users should not use pg_get_object_address for a relation
published via FOR ALL TABLES. So I don't think adding the schema improves
the situation.

>
> Separately, I will start the thread shveta suggested for the case Peter
> ran into with FOR ALL TABLES. I have a patch for it that adds a detail
> only when the table really is published, and I measured that it also
> reproduces back to 13.

Thanks. Just a kind suggestion: the community prefers inline replies rather than
top-posting, as inline replies make it easier to follow the context.

Best Regards,
Zhijie Hou

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mario Karuza 2026-09-16 10:10:42 Improve hash aggregate spilling by writing only the needed columns
Previous Message Manuel Reyes Bravo 2026-09-16 09:43:39 Re: Use C11 alignas instead of palloc/malloc for alignment