| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
| Cc: | Manuel Reyes Bravo <manuelreyesbravo(at)gmail(dot)com>, 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>, 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>, shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Subject: | Re: Distinguish publication exclusions in object addresses |
| Date: | 2026-09-16 10:13:46 |
| Message-ID: | CAJpy0uBYAnz3igzh1CGObc0JzGtX81kAjCuZO0k=oL0gxropSA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Sep 16, 2026 at 3:24 PM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> 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.
I agree that there is no confusion in above case. But I also don't see
any harm in having a schema-qualified name. It makes the message
clearer. The cases like below can become more understandable with
schema qualified name.
CREATE SCHEMA s1;
CREATE TABLE s1.t2(a int);
CREATE SCHEMA s2;
CREATE TABLE s2.t2(a int);
create publication pub for table s1.t2;
SET search_path = s1;
postgres=# SELECT pg_get_object_address('publication relation',
'{t2}', '{pub}');
pg_get_object_address
-----------------------
(6106,16395,0)
(1 row)
postgres=# SET search_path = s2;
SET
postgres=# SELECT pg_get_object_address('publication relation',
'{t2}', '{pub}');
ERROR: publication relation "t2" in publication "pub" does not exist
>
> >
> > 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"
If at all we plan to add it, it will be good to use
'RelationGetQualifiedRelationName' instead.
+++ b/src/backend/catalog/objectaddress.c
@@ -1941,12 +1941,12 @@ get_object_address_publication_rel(ObjectType
objtype, List *object,
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an excluded
relation of publication \"%s\"",
-
RelationGetRelationName(relation), pubname)));
+
RelationGetQualifiedRelationName(relation), pubname)))
thanks
Shveta
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhijie Hou (Fujitsu) | 2026-09-16 10:23:42 | RE: Distinguish publication exclusions in object addresses |
| Previous Message | Mario Karuza | 2026-09-16 10:10:42 | Improve hash aggregate spilling by writing only the needed columns |