Re: Distinguish publication exclusions in object addresses

Поиск
Список
Период
Сортировка
Искать

Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
Вложения:
On Tue, 15 Sept 2026 at 16:05, Amit Kapila  wrote:
>
> On Tue, Sep 15, 2026 at 2:01 PM vignesh C  wrote:
> >
> >
> > The attached v2 version patch has the changes for the same. This also
> > addresses Hou's comments from [1].
> >
>
> --- a/src/include/nodes/parsenodes.h
> +++ b/src/include/nodes/parsenodes.h
> @@ -2416,6 +2416,7 @@ typedef enum ObjectType
>   OBJECT_POLICY,
>   OBJECT_PROCEDURE,
>   OBJECT_PUBLICATION,
> + OBJECT_PUBLICATION_EXCLUDED_REL,
>
> I was trying to evaluate whether the above change needs catversion
> bump and reached conclusion that it doesn't need one because we never
> store this enum on-disk as part of parse-trees. Do let me know if you
> or others thinks differently.
>
> *
>  static ObjectAddress
>  get_object_address_publication_rel(List *object,
> -   Relation *relp, bool missing_ok)
> +   Relation *relp, bool missing_ok,
> +   bool pubrel_is_exclusion)
>
> It is better to use objtype here instead of boolean as we already use
> at few other places.
>
> *
> + if (!missing_ok)
> + {
> + if (pubrel_is_exclusion)
> + ereport(ERROR,
> + (errcode(ERRCODE_UNDEFINED_OBJECT),
> + errmsg("publication excluded relation \"%s\" from publication \"%s\"
> does not exist",
> + RelationGetRelationName(relation), pubname)));
> + else
>   ereport(ERROR,
>   (errcode(ERRCODE_UNDEFINED_OBJECT),
>   errmsg("publication relation \"%s\" in publication \"%s\" does not exist",
>   RelationGetRelationName(relation), pubname)));
>
> I think these messages are misleading because actually here the object
> type is wrong rather than object doesn't exist.
>
> Please find a top-patch for the above suggestions.

Thanks for the suggestion, here is an updated v3 merged version with
the fixes for the same. This patch also addresses Nisha's comments
from [1].

[1] - https://www.postgresql.org/message-id/CABdArM5AXL7xN2c7CnUYhUw-kRdMw0WUAxMXMeEjzDV91tVDEw%40mail.gmail.com

Regards,
Vignesh

Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Tue, Sep 15, 2026 at 7:20 PM vignesh C  wrote:
>
> On Tue, 15 Sept 2026 at 16:05, Amit Kapila  wrote:
> >
> > On Tue, Sep 15, 2026 at 2:01 PM vignesh C  wrote:
> > >
> > >
> > > The attached v2 version patch has the changes for the same. This also
> > > addresses Hou's comments from [1].
> > >
> >
> > --- a/src/include/nodes/parsenodes.h
> > +++ b/src/include/nodes/parsenodes.h
> > @@ -2416,6 +2416,7 @@ typedef enum ObjectType
> >   OBJECT_POLICY,
> >   OBJECT_PROCEDURE,
> >   OBJECT_PUBLICATION,
> > + OBJECT_PUBLICATION_EXCLUDED_REL,
> >
> > I was trying to evaluate whether the above change needs catversion
> > bump and reached conclusion that it doesn't need one because we never
> > store this enum on-disk as part of parse-trees. Do let me know if you
> > or others thinks differently.
> >
> > *
> >  static ObjectAddress
> >  get_object_address_publication_rel(List *object,
> > -   Relation *relp, bool missing_ok)
> > +   Relation *relp, bool missing_ok,
> > +   bool pubrel_is_exclusion)
> >
> > It is better to use objtype here instead of boolean as we already use
> > at few other places.
> >
> > *
> > + if (!missing_ok)
> > + {
> > + if (pubrel_is_exclusion)
> > + ereport(ERROR,
> > + (errcode(ERRCODE_UNDEFINED_OBJECT),
> > + errmsg("publication excluded relation \"%s\" from publication \"%s\"
> > does not exist",
> > + RelationGetRelationName(relation), pubname)));
> > + else
> >   ereport(ERROR,
> >   (errcode(ERRCODE_UNDEFINED_OBJECT),
> >   errmsg("publication relation \"%s\" in publication \"%s\" does not exist",
> >   RelationGetRelationName(relation), pubname)));
> >
> > I think these messages are misleading because actually here the object
> > type is wrong rather than object doesn't exist.
> >
> > Please find a top-patch for the above suggestions.
>
> Thanks for the suggestion, here is an updated v3 merged version with
> the fixes for the same. This patch also addresses Nisha's comments
> from [1].
>
> [1] - https://www.postgresql.org/message-id/CABdArM5AXL7xN2c7CnUYhUw-kRdMw0WUAxMXMeEjzDV91tVDEw%40mail.gmail.com
>


A few nitpicks; please feel free to skip if you don't agree. Rest of
the patch looks good.

1)
+ if (!missing_ok)
+ elog(ERROR, "cache lookup failed for publication table %u",
+ pubreloid);
+
+ /* fallback to "publication relation" for an undefined object */
+ appendStringInfoString(buffer, "publication relation");

Why do we use "publication table" in the cache lookup failure message
while using "publication relation" as the description below? I think
it would be okay to use "relation" in the error message as well,
especially since the next line refers to it as a "publication
relation".

If "publication table" was chosen with the possibility of supporting
sequences as EXCEPT entries in the future, we can always change it
later. In that case, we would also need to decide whether to change
"publication relation" to "publication table" and "publication
sequence"

2)
get_object_address_publication_rel()

if (!HeapTupleIsValid(tup))
{
if (!missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication relation \"%s\" in publication \"%s\" does not exist",
RelationGetRelationName(relation), pubname)));
}

Don't we need to change this existing error message based on the
object type as well?

postgres=# SELECT pg_get_object_address('publication excluded relation',
                             '{public, tab2}', '{pub1}');
ERROR:  publication relation "tab2" in publication "pub1" does not exist

Shouldn't it instead say:

ERROR:  publication excluded relation "tab2" in publication "pub1"
does not exist

since the requested object type is publication excluded relation?

thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Tue, Sep 15, 2026 at 7:20 PM vignesh C  wrote:
>
> Thanks for the suggestion, here is an updated v3 merged version with
> the fixes for the same. This patch also addresses Nisha's comments
> from [1].

Thanks for the patch, it LGTM.
I only have one nitpick in object_address.sql: the new line has an
extra leading space.

         ('publication namespace'), ('publication relation'),
+         ('publication excluded relation')

--
Thanks,
Nisha


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 9:43 AM shveta malik  wrote:
>
> A few nitpicks; please feel free to skip if you don't agree. Rest of
> the patch looks good.
>
> 1)
> + if (!missing_ok)
> + elog(ERROR, "cache lookup failed for publication table %u",
> + pubreloid);
> +
> + /* fallback to "publication relation" for an undefined object */
> + appendStringInfoString(buffer, "publication relation");
>
> Why do we use "publication table" in the cache lookup failure message
> while using "publication relation" as the description below? I think
> it would be okay to use "relation" in the error message as well,
> especially since the next line refers to it as a "publication
> relation".
>

We can go either way but there is some precedent as well for using
different names, see:
if (!HeapTupleIsValid(procTup))
{
if (!missing_ok)
elog(ERROR, "cache lookup failed for procedure %u", procid);

/* fallback to "procedure" for an undefined object */
appendStringInfoString(buffer, "routine");

Also, we should change one other existing place than:
case PublicationRelRelationId:
{
HeapTuple tup;
char   *pubname;
Form_pg_publication_rel prform;

tup = SearchSysCache1(PUBLICATIONREL,
 ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tup))
{
if (!missing_ok)
elog(ERROR, "cache lookup failed for publication table %u",
object->objectId);

I would like to retain the one used by patch. If you or others still
want to insist for consistency here then we need to change at both
places.

> If "publication table" was chosen with the possibility of supporting
> sequences as EXCEPT entries in the future, we can always change it
> later. In that case, we would also need to decide whether to change
> "publication relation" to "publication table" and "publication
> sequence"
>
> 2)
> get_object_address_publication_rel()
>
> if (!HeapTupleIsValid(tup))
> {
> if (!missing_ok)
> ereport(ERROR,
> (errcode(ERRCODE_UNDEFINED_OBJECT),
> errmsg("publication relation \"%s\" in publication \"%s\" does not exist",
> RelationGetRelationName(relation), pubname)));
> }
>
> Don't we need to change this existing error message based on the
> object type as well?
>
> postgres=# SELECT pg_get_object_address('publication excluded relation',
>                              '{public, tab2}', '{pub1}');
> ERROR:  publication relation "tab2" in publication "pub1" does not exist
>
> Shouldn't it instead say:
>
> ERROR:  publication excluded relation "tab2" in publication "pub1"
> does not exist
>
> since the requested object type is publication excluded relation?
>

Yes, but if we see the code [1], we are just trying to fetch the
publication table from pg_publication_rel, so I am okay with the
current ERROR message. OTOH, I do see the argument of giving more
appropriate error message for the example you shared but I feel it
will add more checks in the code which doesn't sound worth to me.

[1]:
tup = SearchSysCache2(PUBLICATIONRELMAP,
 ObjectIdGetDatum(RelationGetRelid(relation)),
 ObjectIdGetDatum(pub->oid));
if (!HeapTupleIsValid(tup))


-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
Some review comments for v3:

======
Commit Message

1.
Fix this by distinguishing EXCEPT entries in the object address code.
They are now reported as publication excluded relation, with object
identities indicating that the table is excluded from the publication.

~

Should "publication excluded relation" be quoted here?

======
src/backend/catalog/aclchk.c

+ case OBJECT_PUBLICATION_EXCLUDED_REL:
  case OBJECT_PUBLICATION_NAMESPACE:
  case OBJECT_PUBLICATION_REL:

The new enum name OBJECT_PUBLICATION_EXCLUDED_REL is closely related
to OBJECT_PUBLICATION_REL.

IMO, a better name would be OBJECT_PUBLICATION_REL_EXCLUDED, so these
related things are kept adjacent alphabetically and in the code.

(same comment affects multiple other files but not repeating all those
in this post)

======
src/backend/catalog/objectaddress.c

2.
 static ObjectAddress
-get_object_address_publication_rel(List *object,
+get_object_address_publication_rel(ObjectType objtype, List *object,
    Relation *relp, bool missing_ok)

If not going to describe parameter `objType` then maybe a
self-documenting Assert would be good to have here.

~~~

3.
+ /*
+ * The same relation and publication pair identifies either a published or
+ * an excluded relation, so reject an entry of the kind that was not asked
+ * for.
+ */

The wording looks a bit strange. Particularly the 2nd part ("reject an
entry of the kind that was not asked for")

SUGGESTION:
A given relation/publication pair can represent either a published
relation or an excluded one, but not both.  Reject the entry if it is
not the kind the caller asked for.

~~~

4.
+ if (isexcept)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is not a published relation of publication \"%s\"",
+ RelationGetRelationName(relation), pubname)));
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
+ RelationGetRelationName(relation), pubname)));

Publications can have the same table name in multiple schemas. The
name should be fully-qualified in the errmsg to eliminate any
ambiguity.

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


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
Вложения:
On Wed, Sep 16, 2026 at 10:21 AM Peter Smith  wrote:
>
> Some review comments for v3:
>
> ======
> Commit Message
>
> 1.
> Fix this by distinguishing EXCEPT entries in the object address code.
> They are now reported as publication excluded relation, with object
> identities indicating that the table is excluded from the publication.
>
> ~
>
> Should "publication excluded relation" be quoted here?
>

I have changed the commit message.

>
> ======
> src/backend/catalog/objectaddress.c
>
> 2.
>  static ObjectAddress
> -get_object_address_publication_rel(List *object,
> +get_object_address_publication_rel(ObjectType objtype, List *object,
>     Relation *relp, bool missing_ok)
>
> If not going to describe parameter `objType` then maybe a
> self-documenting Assert would be good to have here.
>

Added assert in the attached patch and changed the if/else to simplify the code.

> ~~~
>
> 3.
> + /*
> + * The same relation and publication pair identifies either a published or
> + * an excluded relation, so reject an entry of the kind that was not asked
> + * for.
> + */
>
> The wording looks a bit strange. Particularly the 2nd part ("reject an
> entry of the kind that was not asked for")
>
> SUGGESTION:
> A given relation/publication pair can represent either a published
> relation or an excluded one, but not both.  Reject the entry if it is
> not the kind the caller asked for.
>
> ~~~
>

I am not sure which one to prefer here. I have kept the proposed one
based on its conciseness.

> 4.
> + if (isexcept)
> + ereport(ERROR,
> + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> + errmsg("\"%s\" is not a published relation of publication \"%s\"",
> + RelationGetRelationName(relation), pubname)));
> + else
> + ereport(ERROR,
> + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> + errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
> + RelationGetRelationName(relation), pubname)));
>
> Publications can have the same table name in multiple schemas. The
> name should be fully-qualified in the errmsg to eliminate any
> ambiguity.
>

But I don't see any ambiguity here as the user can only pass one
relation name. Also, we use the unqualified name in nearby message
[1]. We use RelationGetRelationName all over the code in the error
messages and I don't see the need to qualify here. We will simply
return the name the user has passed.

[1]:
errmsg("publication relation \"%s\" in publication \"%s\" does not exist",
RelationGetRelationName(relation), pubname)));

-- 
With Regards,
Amit Kapila.

RE: Distinguish publication exclusions in object addresses

От:
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
Дата:
On Wednesday, September 16, 2026 12:51 PM Peter Smith  wrote:
> Some review comments for v3:
> 
> 
> ======
> src/backend/catalog/aclchk.c
> 
> + case OBJECT_PUBLICATION_EXCLUDED_REL:
>   case OBJECT_PUBLICATION_NAMESPACE:
>   case OBJECT_PUBLICATION_REL:
> 
> The new enum name OBJECT_PUBLICATION_EXCLUDED_REL is closely
> related to OBJECT_PUBLICATION_REL.
> 
> IMO, a better name would be OBJECT_PUBLICATION_REL_EXCLUDED, so
> these related things are kept adjacent alphabetically and in the code.

I think all object type names end with a noun, whereas the proposed name
doesn't, so I don't find it better. Also, the order of an enum value doesn't
provide enough value to justify the change, in my view.

Best Regards,
Zhijie Hou

Re: Distinguish publication exclusions in object addresses

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 11:21 AM Amit Kapila  wrote:
>
> On Wed, Sep 16, 2026 at 10:21 AM Peter Smith  wrote:
> >
> > Some review comments for v3:
> >
> > ======
> > Commit Message
> >
> > 1.
> > Fix this by distinguishing EXCEPT entries in the object address code.
> > They are now reported as publication excluded relation, with object
> > identities indicating that the table is excluded from the publication.
> >
> > ~
> >
> > Should "publication excluded relation" be quoted here?
> >
>
> I have changed the commit message.
>
> >
> > ======
> > src/backend/catalog/objectaddress.c
> >
> > 2.
> >  static ObjectAddress
> > -get_object_address_publication_rel(List *object,
> > +get_object_address_publication_rel(ObjectType objtype, List *object,
> >     Relation *relp, bool missing_ok)
> >
> > If not going to describe parameter `objType` then maybe a
> > self-documenting Assert would be good to have here.
> >
>
> Added assert in the attached patch and changed the if/else to simplify the code.
>

Should the new Assert be at the start of the function? At the current
position, we have already locked the relation and done some
unnecessary processing by then.

--
Thanks,
Nisha


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 12:00 PM Nisha Moond  wrote:
>
> On Wed, Sep 16, 2026 at 11:21 AM Amit Kapila  wrote:
> >
> > On Wed, Sep 16, 2026 at 10:21 AM Peter Smith  wrote:
> > >
> > > Some review comments for v3:
> > >
> > > ======
> > > Commit Message
> > >
> > > 1.
> > > Fix this by distinguishing EXCEPT entries in the object address code.
> > > They are now reported as publication excluded relation, with object
> > > identities indicating that the table is excluded from the publication.
> > >
> > > ~
> > >
> > > Should "publication excluded relation" be quoted here?
> > >
> >
> > I have changed the commit message.
> >
> > >
> > > ======
> > > src/backend/catalog/objectaddress.c
> > >
> > > 2.
> > >  static ObjectAddress
> > > -get_object_address_publication_rel(List *object,
> > > +get_object_address_publication_rel(ObjectType objtype, List *object,
> > >     Relation *relp, bool missing_ok)
> > >
> > > If not going to describe parameter `objType` then maybe a
> > > self-documenting Assert would be good to have here.
> > >
> >
> > Added assert in the attached patch and changed the if/else to simplify the code.
> >
>
> Should the new Assert be at the start of the function? At the current
> position, we have already locked the relation and done some
> unnecessary processing by then.

Yes, that will be better IMO.

thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
> 
> -- 
> With Regards,
> Amit Kapila.
> 

V4 overall looks sold to me. Just a couple of small comments:

1
```
-- No entry of either kind.  testpub_default publishes nothing.
SELECT pg_get_object_address('publication excluded relation',
                             '{public, testpub_tbl1}', '{testpub_default}');
ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
```

For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
```
publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
```

2
```
+	if (objtype == OBJECT_PUBLICATION_EXCLUDED_REL && !isexcept)
+		ereport(ERROR,
+				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+				 errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
+						RelationGetRelationName(relation), pubname)));
+	else if (objtype == OBJECT_PUBLICATION_REL && isexcept)
+		ereport(ERROR,
+				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+				 errmsg("\"%s\" is not a published relation of publication \"%s\"",
+						RelationGetRelationName(relation), pubname)));
```

Nitpick: with the modern ereport() style, the extra parentheses around errcode() and errmsg() are no longer needed.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 4:46 PM Chao Li  wrote:
>
>
>
> > On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
> >
> > --
> > With Regards,
> > Amit Kapila.
> > 
>
> V4 overall looks sold to me. Just a couple of small comments:
>
> 1
> ```
> -- No entry of either kind.  testpub_default publishes nothing.
> SELECT pg_get_object_address('publication excluded relation',
>                              '{public, testpub_tbl1}', '{testpub_default}');
> ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
> ```
>
> For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
> ```
> publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
> ```

+1 this because maybe the reported table name really *does* exist and
is part of the publication, even though the message is saying the
exact opposite.

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


Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 3:51 PM Amit Kapila  wrote:
>
> > 4.
> > + if (isexcept)
> > + ereport(ERROR,
> > + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> > + errmsg("\"%s\" is not a published relation of publication \"%s\"",
> > + RelationGetRelationName(relation), pubname)));
> > + else
> > + ereport(ERROR,
> > + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> > + errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
> > + RelationGetRelationName(relation), pubname)));
> >
> > Publications can have the same table name in multiple schemas. The
> > name should be fully-qualified in the errmsg to eliminate any
> > ambiguity.
> >
>
> But I don't see any ambiguity here as the user can only pass one
> relation name. Also, we use the unqualified name in nearby message
> [1]. We use RelationGetRelationName all over the code in the error
> messages and I don't see the need to qualify here. We will simply
> return the name the user has passed.
>

In this experiment below I got an unexpected result.
- Is it a bug?
- Is it somehow reporting about a "t1" table of another schema?
- Did I type something wrong somewhere?

I cannot tell because the table name was not qualified...

CREATE SCHEMA s1;
CREATE SCHEMA s2;
CREATE SCHEMA s3;

CREATE TABLE t1(a int);
CREATE TABLE s1.t1(a int);
CREATE TABLE s2.t1(a int);
CREATE TABLE s3.t1(a int);

CREATE PUBLICATION pub FOR ALL TABLES EXCEPT (TABLE s2.t1, s3.t1);

SELECT pg_get_object_address('publication relation','{public,t1}','{pub}');
2026-09-16 17:06:17.136 AEST [250078] ERROR:  publication relation
"t1" in publication "pub" does not exist
2026-09-16 17:06:17.136 AEST [250078] STATEMENT:  SELECT
pg_get_object_address('publication relation','{public,t1}','{pub}');
ERROR:  publication relation "t1" in publication "pub" does not exist

That message can't be right because....

\d+ public.t1
                                           Table "public.t1"
 Column |  Type   | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 a      | integer |           |          |         | plain   |
    |              |
Included in publications:
    "pub"
Access method: heap

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


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 12:46 PM Peter Smith  wrote:
>
> In this experiment below I got an unexpected result.
> - Is it a bug?
>

Possible but not related to this patch. Even the following simple test
without patch gives the same result:

postgres=# CREATE TABLE t1(a int);
CREATE TABLE
postgres=# CREATE PUBLICATION pub FOR ALL TABLES;
CREATE PUBLICATION
postgres=# SELECT pg_get_object_address('publication
relation','{public,t1}','{pub}');
ERROR:  publication relation "t1" in publication "pub" does not exist

I suggest starting a new thread to discuss this case.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
On Wed, 16 Sept 2026 at 12:16, Chao Li  wrote:
>
>
>
> > On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
> >
> > --
> > With Regards,
> > Amit Kapila.
> > 
>
> V4 overall looks sold to me. Just a couple of small comments:
>
> 1
> ```
> -- No entry of either kind.  testpub_default publishes nothing.
> SELECT pg_get_object_address('publication excluded relation',
>                              '{public, testpub_tbl1}', '{testpub_default}');
> ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
> ```
>
> For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
> ```
> publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
> ```

I think it would add some unnecessary code complexity in this case.
Since the underlying issue is simply that the relation is not present
in the publication, I think the existing generic error message is
sufficient and should be understandable in the context of publication
excluded relation.

> 2
> ```
> +       if (objtype == OBJECT_PUBLICATION_EXCLUDED_REL && !isexcept)
> +               ereport(ERROR,
> +                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> +                                errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
> +                                               RelationGetRelationName(relation), pubname)));
> +       else if (objtype == OBJECT_PUBLICATION_REL && isexcept)
> +               ereport(ERROR,
> +                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> +                                errmsg("\"%s\" is not a published relation of publication \"%s\"",
> +                                               RelationGetRelationName(relation), pubname)));
> ```
>
> Nitpick: with the modern ereport() style, the extra parentheses around errcode() and errmsg() are no longer needed.

This is consistent with the nearby code, which already uses the same
style with the extra parentheses. Since this is not a new function, I
think it is better to keep it consistent with the surrounding code.

Regards,
Vignesh


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 12:23 PM Peter Smith  wrote:
>
> On Wed, Sep 16, 2026 at 4:46 PM Chao Li  wrote:
> >
> >
> >
> > > On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
> > >
> > > --
> > > With Regards,
> > > Amit Kapila.
> > > 
> >
> > V4 overall looks sold to me. Just a couple of small comments:
> >
> > 1
> > ```
> > -- No entry of either kind.  testpub_default publishes nothing.
> > SELECT pg_get_object_address('publication excluded relation',
> >                              '{public, testpub_tbl1}', '{testpub_default}');
> > ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
> > ```
> >
> > For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
> > ```
> > publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
> > ```
>
> +1 this because maybe the reported table name really *does* exist and
> is part of the publication, even though the message is saying the
> exact opposite.
>

Can you share an example of such a case?

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 5:41 PM Amit Kapila  wrote:
>
> On Wed, Sep 16, 2026 at 12:23 PM Peter Smith  wrote:
> >
> > On Wed, Sep 16, 2026 at 4:46 PM Chao Li  wrote:
> > >
> > >
> > >
> > > > On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
> > > >
> > > > --
> > > > With Regards,
> > > > Amit Kapila.
> > > > 
> > >
> > > V4 overall looks sold to me. Just a couple of small comments:
> > >
> > > 1
> > > ```
> > > -- No entry of either kind.  testpub_default publishes nothing.
> > > SELECT pg_get_object_address('publication excluded relation',
> > >                              '{public, testpub_tbl1}', '{testpub_default}');
> > > ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
> > > ```
> > >
> > > For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
> > > ```
> > > publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
> > > ```
> >
> > +1 this because maybe the reported table name really *does* exist and
> > is part of the publication, even though the message is saying the
> > exact opposite.
> >
>
> Can you share an example of such a case?
>

My example was using 'publication relation' (not 'publication excluded
relation') and I've already shared it.

But that bug (?) already exists because this logic appears only aware
of PUBLICATIONRELMAP rels and is not accounting for FOR ALL TABLES
etc, so it reports an error like
ERROR:  "t1" is not a published relation of publication "pub"
even though table public.t1 does exist and really is a published
relation of pub.

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


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 12:46 PM Peter Smith  wrote:
>
> On Wed, Sep 16, 2026 at 3:51 PM Amit Kapila  wrote:
> >
> > > 4.
> > > + if (isexcept)
> > > + ereport(ERROR,
> > > + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> > > + errmsg("\"%s\" is not a published relation of publication \"%s\"",
> > > + RelationGetRelationName(relation), pubname)));
> > > + else
> > > + ereport(ERROR,
> > > + (errcode(ERRCODE_WRONG_OBJECT_TYPE),
> > > + errmsg("\"%s\" is not an excluded relation of publication \"%s\"",
> > > + RelationGetRelationName(relation), pubname)));
> > >
> > > Publications can have the same table name in multiple schemas. The
> > > name should be fully-qualified in the errmsg to eliminate any
> > > ambiguity.
> > >
> >
> > But I don't see any ambiguity here as the user can only pass one
> > relation name. Also, we use the unqualified name in nearby message
> > [1]. We use RelationGetRelationName all over the code in the error
> > messages and I don't see the need to qualify here. We will simply
> > return the name the user has passed.
> >
>
> In this experiment below I got an unexpected result.
> - Is it a bug?
> - Is it somehow reporting about a "t1" table of another schema?
> - Did I type something wrong somewhere?
>
> I cannot tell because the table name was not qualified...
>
> CREATE SCHEMA s1;
> CREATE SCHEMA s2;
> CREATE SCHEMA s3;
>
> CREATE TABLE t1(a int);
> CREATE TABLE s1.t1(a int);
> CREATE TABLE s2.t1(a int);
> CREATE TABLE s3.t1(a int);
>
> CREATE PUBLICATION pub FOR ALL TABLES EXCEPT (TABLE s2.t1, s3.t1);
>
> SELECT pg_get_object_address('publication relation','{public,t1}','{pub}');
> 2026-09-16 17:06:17.136 AEST [250078] ERROR:  publication relation
> "t1" in publication "pub" does not exist
> 2026-09-16 17:06:17.136 AEST [250078] STATEMENT:  SELECT
> pg_get_object_address('publication relation','{public,t1}','{pub}');
> ERROR:  publication relation "t1" in publication "pub" does not exist
>
> That message can't be right because....
>
> \d+ public.t1
>                                            Table "public.t1"
>  Column |  Type   | Collation | Nullable | Default | Storage |
> Compression | Stats target | Description
> --------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
>  a      | integer |           |          |         | plain   |
>     |              |
> Included in publications:
>     "pub"
> Access method: heap
>

I had encountered this while testing version 1 posted by Fujii-san in
this thread. It behaves the same not only for ALL TABLES publications,
but also for TABLES IN SCHEMA publications. Perhaps the idea here is
to give object-address of pg_publication_rel catalog and not combined.
This is what I understood at that time. But I couldn't find any doc
describing this behavior. Perhaps the docs need to be updated to
clarify this on HEAD. We can discuss this in a separate thread.

thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 1:21 PM Peter Smith  wrote:
>
> On Wed, Sep 16, 2026 at 5:41 PM Amit Kapila  wrote:
> >
> > On Wed, Sep 16, 2026 at 12:23 PM Peter Smith  wrote:
> >
> > Can you share an example of such a case?
> >
>
> My example was using 'publication relation' (not 'publication excluded
> relation') and I've already shared it.
>
> But that bug (?) already exists because this logic appears only aware
> of PUBLICATIONRELMAP rels and is not accounting for FOR ALL TABLES
> etc, so it reports an error like
> ERROR:  "t1" is not a published relation of publication "pub"
> even though table public.t1 does exist and really is a published
> relation of pub.
>

Right, but it is a different case as discussed. So, I would still
prefer to keep the same message to keep the code simple. Also, I would
like to push this patch after changing the Assert location as pointed
by Nisha unless you or others have any other comment.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Chao Li <li.evan.chao@gmail.com>
Дата:
Вложения:


> On Sep 16, 2026, at 15:37, vignesh C  wrote:
> 
> On Wed, 16 Sept 2026 at 12:16, Chao Li  wrote:
>> 
>> 
>> 
>>> On Sep 16, 2026, at 13:50, Amit Kapila  wrote:
>>> 
>>> --
>>> With Regards,
>>> Amit Kapila.
>>> 
>> 
>> V4 overall looks sold to me. Just a couple of small comments:
>> 
>> 1
>> ```
>> -- No entry of either kind.  testpub_default publishes nothing.
>> SELECT pg_get_object_address('publication excluded relation',
>>                             '{public, testpub_tbl1}', '{testpub_default}');
>> ERROR:  publication relation "testpub_tbl1" in publication "testpub_default" does not exist
>> ```
>> 
>> For this new test, the error message is a little surprising to me. Since the requested object type is "publication excluded relation", I would expect the error message to say something like:
>> ```
>> publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist
>> ```
> 
> I think it would add some unnecessary code complexity in this case.
> Since the underlying issue is simply that the relation is not present
> in the publication, I think the existing generic error message is
> sufficient and should be understandable in the context of publication
> excluded relation.
> 

I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/




Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
Вложения:
On Wed, 16 Sept 2026 at 13:57, Chao Li  wrote:
>
> I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.

Agreed. I had initially thought the additional code complexity was not
worthwhile. Since this is a user-facing error message, I agree that
making it more specific is worthwhile. Thanks, I have merged the
changes.
The attached v5 version patch has the changes for the same.

Regards,
Vignesh

Re: Distinguish publication exclusions in object addresses

От:
Manuel Reyes Bravo <manuelreyesbravo@gmail.com>
Дата:
Вложения:
Hi,

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.

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"

It only touches the two "is not a ... relation of publication" messages,
which are the ones reached when the relation does have an entry.  The
"does not exist" messages, including the new one for excluded relations
in v5, keep the unqualified form of the existing message they sit next
to.  `make check` passes with v5 plus this patch; publication.out is
updated for the two messages.

On the rest of the patch: I applied v4 to master at 04c4c1c3a96, built
with --enable-cassert and exercised the new object type by hand.  All
239 tests pass, pg_identify_object_as_address() reports "publication
excluded relation", the identify/address round trip works, and
pg_describe_object() gives "exclusion of table t2 from publication pub".
Asking for the wrong kind is rejected as intended, in both directions.
I did not find a functional problem.  v5 applies cleanly on the same
commit and passes as well.

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.

Regards,
Manu

El mié, 16 sept 2026 a las 5:57, vignesh C () escribió:
>
> On Wed, 16 Sept 2026 at 13:57, Chao Li  wrote:
> >
> > I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.
>
> Agreed. I had initially thought the additional code complexity was not
> worthwhile. Since this is a user-facing error message, I agree that
> making it more specific is worthwhile. Thanks, I have merged the
> changes.
> The attached v5 version patch has the changes for the same.
>
> Regards,
> Vignesh

RE: Distinguish publication exclusions in object addresses

От:
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
Дата:
Hi,

On Wednesday, September 16, 2026 5:20 PM Manuel Reyes Bravo  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

Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 3:24 PM Zhijie Hou (Fujitsu)
 wrote:
>
> Hi,
>
> On Wednesday, September 16, 2026 5:20 PM Manuel Reyes Bravo  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


RE: Distinguish publication exclusions in object addresses

От:
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
Дата:
Hi,

On Wednesday, September 16, 2026 6:14 PM shveta malik  wrote:
> On Wed, Sep 16, 2026 at 3:24 PM Zhijie Hou (Fujitsu)
> > On Wednesday, September 16, 2026 5:20 PM Manuel Reyes Bravo
>  wrote:
> > >     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"
> > >
> > > 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.

There is no harm, but it is not consistent with the other object
messages used here (e.g., they do not report schema-qualified names):

get_relation_by_qualified_name
get_object_address_attribute
get_object_address_attrdef
get_object_address_unqualified
get_object_address_type
...

So it does not look necessary to me to add it for our publication case.

The column list error message reports schema-qualified names because users can
specify multiple tables with the same name from different schemas, so it's
necessary there. But that's not our case.

Best Regards,
Zhijie Hou

Re: Distinguish publication exclusions in object addresses

От:
Manuel Reyes Bravo <manuelreyesbravo@gmail.com>
Дата:
Вложения:
shveta malik  wrote:
> 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.
[...]
> postgres=# SET search_path = s2;
> postgres=# SELECT pg_get_object_address('publication relation',
> '{t2}', '{pub}');
> ERROR:  publication relation "t2" in publication "pub" does not exist

Zhijie is right that my own example was weak: the schema was right there
in the call.  Your example is the one that matters, and it goes through
the "does not exist" message, which my first delta did not touch.  The
attached 0001 now qualifies all four errors in
get_object_address_publication_rel(), so that case reads:

    ERROR:  publication relation "s2.t2" in publication "pub" does not exist

> If at all we plan to add it, it will be good to use
> 'RelationGetQualifiedRelationName' instead.

I tried it first, and it quotes the name twice when it needs quoting,
because it goes through quote_qualified_identifier() and these messages
already put the name in quotes:

    ERROR:  publication relation ""Sales Q3"."Big Table"" in
publication "pub" does not exist

So 0001 uses "\"%s.%s\"" with get_namespace_name(), which is the form of
55 errmsg() calls in src/backend, against 3 that put a quoted qualified
name inside quotes.

That also shows the same problem in commit a49b9cfd72d, which is in
REL_19_STABLE:

    CREATE TABLE "testpub Part2" PARTITION OF testpub_root FOR VALUES
FROM (100) TO (200);
    CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "testpub Part2");
    ERROR:  cannot specify relation "public."testpub Part2"" in the
publication EXCEPT clause

0002 fixes it by building the name the same way, without changing the
message text, and adds that case to publication.sql.  Without the fix
the new test fails with the output above; with it, it passes.  0002 does
not depend on v5 and applies to both master and REL_19_STABLE.

Zhijie Hou (Fujitsu)  wrote:
> There is no harm, but it is not consistent with the other object
> messages used here (e.g., they do not report schema-qualified names):

That is true of objectaddress.c: none of its messages qualifies the name
today.  The case for doing it here is the one a49b9cfd72d made for the
EXCEPT errors, that the same name can exist in several schemas, plus
shveta's search_path example.  Whether that outweighs consistency with
the rest of objectaddress.c is Amit's call; if not, 0001 can simply be
dropped, and 0002 still stands on its own.

v5 plus 0001 and 0002: all 239 regression tests pass.

> Just a kind suggestion: the community prefers inline replies rather than
> top-posting

Thanks, noted.

Regards,
Manu

El mié, 16 sept 2026 a las 7:23, Zhijie Hou (Fujitsu)
() escribió:
>
> Hi,
>
> On Wednesday, September 16, 2026 6:14 PM shveta malik  wrote:
> > On Wed, Sep 16, 2026 at 3:24 PM Zhijie Hou (Fujitsu)
> > > On Wednesday, September 16, 2026 5:20 PM Manuel Reyes Bravo
> >  wrote:
> > > >     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"
> > > >
> > > > 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.
>
> There is no harm, but it is not consistent with the other object
> messages used here (e.g., they do not report schema-qualified names):
>
> get_relation_by_qualified_name
> get_object_address_attribute
> get_object_address_attrdef
> get_object_address_unqualified
> get_object_address_type
> ...
>
> So it does not look necessary to me to add it for our publication case.
>
> The column list error message reports schema-qualified names because users can
> specify multiple tables with the same name from different schemas, so it's
> necessary there. But that's not our case.
>
> Best Regards,
> Zhijie Hou

Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
On Wed, 16 Sept 2026 at 18:12, Manuel Reyes Bravo
 wrote:
>
> Zhijie is right that my own example was weak: the schema was right there
> in the call.  Your example is the one that matters, and it goes through
> the "does not exist" message, which my first delta did not touch.  The
> attached 0001 now qualifies all four errors in
> get_object_address_publication_rel(), so that case reads:
>
>     ERROR:  publication relation "s2.t2" in publication "pub" does not exist
>
> > If at all we plan to add it, it will be good to use
> > 'RelationGetQualifiedRelationName' instead.
>
> I tried it first, and it quotes the name twice when it needs quoting,
> because it goes through quote_qualified_identifier() and these messages
> already put the name in quotes:
>
>     ERROR:  publication relation ""Sales Q3"."Big Table"" in
> publication "pub" does not exist
>
> So 0001 uses "\"%s.%s\"" with get_namespace_name(), which is the form of
> 55 errmsg() calls in src/backend, against 3 that put a quoted qualified
> name inside quotes.

Thanks, Manu, for the patches. I think it would be better to start a
new thread to discuss this and the other functions listed by Hou-san
at [1]. Since all of the get_XXX functions handle this in a similar
way, we can discuss them together and ensure that the changes are
applied consistently.
get_relation_by_qualified_name
get_object_address_attribute
get_object_address_attrdef
get_object_address_unqualified
get_object_address_type
...

> That also shows the same problem in commit a49b9cfd72d, which is in
> REL_19_STABLE:
>
>     CREATE TABLE "testpub Part2" PARTITION OF testpub_root FOR VALUES
> FROM (100) TO (200);
>     CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "testpub Part2");
>     ERROR:  cannot specify relation "public."testpub Part2"" in the
> publication EXCEPT clause
>
> 0002 fixes it by building the name the same way, without changing the
> message text, and adds that case to publication.sql.  Without the fix
> the new test fails with the output above; with it, it passes.  0002 does
> not depend on v5 and applies to both master and REL_19_STABLE.
>
> Zhijie Hou (Fujitsu)  wrote:
> > There is no harm, but it is not consistent with the other object
> > messages used here (e.g., they do not report schema-qualified names):
>
> That is true of objectaddress.c: none of its messages qualifies the name
> today.  The case for doing it here is the one a49b9cfd72d made for the
> EXCEPT errors, that the same name can exist in several schemas, plus
> shveta's search_path example.  Whether that outweighs consistency with
> the rest of objectaddress.c is Amit's call; if not, 0001 can simply be
> dropped, and 0002 still stands on its own.

Please have a look at the discussion regarding the commit in [1]
thread. If you still feel that it needs further discussion, we can
continue discussing your suggestion in the thread at [2], as it is not
directly related to the topic of this current thread.

[1] - https://www.postgresql.org/message-id/TY4PR01MB17718424B75122A8D12257A5694B92%40TY4PR01MB17718.jpnprd01.prod.outlook.com
[2] - https://www.postgresql.org/message-id/flat/CAFiTN-scG7b11Jsp%2BVoDRT8ZFE84eSKLcDsSB18dZ8AaP%3DR-mw%40mail.gmail.com

Regards,
Vignesh


Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
Вложения:
On Wed, 16 Sept 2026 at 14:26, vignesh C  wrote:
>
> On Wed, 16 Sept 2026 at 13:57, Chao Li  wrote:
> >
> > I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.
>
> Agreed. I had initially thought the additional code complexity was not
> worthwhile. Since this is a user-facing error message, I agree that
> making it more specific is worthwhile. Thanks, I have merged the
> changes.
> The attached v5 version patch has the changes for the same.

While reviewing the patch further, I noticed that the Assert in
get_object_address_publication_rel() can be placed immediately after
the variable declarations, rather than after the subsequent checks.
The attached v6 patch includes this change.

Regards,
Vignesh

Re: Distinguish publication exclusions in object addresses

От:
Manuel Reyes Bravo <manuelreyesbravo@gmail.com>
Дата:
vignesh C  wrote:
> Please have a look at the discussion regarding the commit in [1]
> thread. If you still feel that it needs further discussion, we can
> continue discussing your suggestion in the thread at [2], as it is not
> directly related to the topic of this current thread.

Thanks, I had not seen [2].  Peter raised the nested quotes there on
May 11 with the same kind of example, and you considered them
acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
not a new finding, and I withdraw it.

I also need to correct a number I gave.  I wrote that 55 errmsg() calls
in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
name inside quotes.  My search missed calls whose arguments are on
later lines.  Reading each errmsg/errdetail/errhint call in full on
REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
the EXCEPT message in pg_publication.c.

> Thanks, Manu, for the patches. I think it would be better to start a
> new thread to discuss this and the other functions listed by Hou-san
> at [1].

Agreed, and Peter's list in [2] already goes well beyond these four
messages, so I will leave 0001 out of this thread.

Regards,
Manu

El mié, 16 sept 2026 a las 13:58, vignesh C () escribió:
>
> On Wed, 16 Sept 2026 at 14:26, vignesh C  wrote:
> >
> > On Wed, 16 Sept 2026 at 13:57, Chao Li  wrote:
> > >
> > > I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.
> >
> > Agreed. I had initially thought the additional code complexity was not
> > worthwhile. Since this is a user-facing error message, I agree that
> > making it more specific is worthwhile. Thanks, I have merged the
> > changes.
> > The attached v5 version patch has the changes for the same.
>
> While reviewing the patch further, I noticed that the Assert in
> get_object_address_publication_rel() can be placed immediately after
> the variable declarations, rather than after the subsequent checks.
> The attached v6 patch includes this change.
>
> Regards,
> Vignesh


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 10:27 PM vignesh C  wrote:
>
> On Wed, 16 Sept 2026 at 14:26, vignesh C  wrote:
> >
> > On Wed, 16 Sept 2026 at 13:57, Chao Li  wrote:
> > >
> > > I don’t think the fix would add much complexity, please see the attached diff I tried. This error message is shown to users, so I think improving it is worthwhile.
> >
> > Agreed. I had initially thought the additional code complexity was not
> > worthwhile. Since this is a user-facing error message, I agree that
> > making it more specific is worthwhile. Thanks, I have merged the
> > changes.
> > The attached v5 version patch has the changes for the same.
>
> While reviewing the patch further, I noticed that the Assert in
> get_object_address_publication_rel() can be placed immediately after
> the variable declarations, rather than after the subsequent checks.
> The attached v6 patch includes this change.
>

v6 LGTM.

thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
Вложения:
On Thu, Sep 17, 2026 at 12:17 AM Manuel Reyes Bravo
 wrote:
>
> vignesh C  wrote:
> > Please have a look at the discussion regarding the commit in [1]
> > thread. If you still feel that it needs further discussion, we can
> > continue discussing your suggestion in the thread at [2], as it is not
> > directly related to the topic of this current thread.
>
> Thanks, I had not seen [2].  Peter raised the nested quotes there on
> May 11 with the same kind of example, and you considered them
> acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
> not a new finding, and I withdraw it.
>
> I also need to correct a number I gave.  I wrote that 55 errmsg() calls
> in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
> name inside quotes.  My search missed calls whose arguments are on
> later lines.  Reading each errmsg/errdetail/errhint call in full on
> REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
> the EXCEPT message in pg_publication.c.
>

Seeing the other usage, I am thinking to fix this case for except
tables unless some major change is required. We can consider changing
REFRESH MATERIALIZED VIEW CONCURRENTLY separately. I have few points
for the that patch:

* The existing function
RelationGetQualifiedRelationName()->get_qualified_objname() used
get_namespace_name_or_temp() where as patch used get_namespace_name().
That could create the problem with temp tables as follows:

Before patch:
postgres=# create publication mypub for all tables except(table mytemp);
ERROR:  cannot specify relation "pg_temp.mytemp" in the publication
EXCEPT clause
DETAIL:  This operation is not supported for temporary tables.

After patch:
postgres=# create publication mypub for all tables except(table mytemp);
ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
EXCEPT clause
DETAIL:  This operation is not supported for temporary tables.

You can notice that temp schema name has _0 appended to it after
patch, it seems to append backend's slot number. We can use
get_namespace_name_or_temp() instead of get_namespace_name().

* After this RelationGetQualifiedRelationName() is dead and is
introduced by the commit a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
which introduced this quoting problem. I feel it is better to remove
it.

Attached fixed both the problems.

-- 
With Regards,
Amit Kapila.

Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Thu, Sep 17, 2026 at 11:41 AM Amit Kapila  wrote:
>
> On Thu, Sep 17, 2026 at 12:17 AM Manuel Reyes Bravo
>  wrote:
> >
> > vignesh C  wrote:
> > > Please have a look at the discussion regarding the commit in [1]
> > > thread. If you still feel that it needs further discussion, we can
> > > continue discussing your suggestion in the thread at [2], as it is not
> > > directly related to the topic of this current thread.
> >
> > Thanks, I had not seen [2].  Peter raised the nested quotes there on
> > May 11 with the same kind of example, and you considered them
> > acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
> > not a new finding, and I withdraw it.
> >
> > I also need to correct a number I gave.  I wrote that 55 errmsg() calls
> > in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
> > name inside quotes.  My search missed calls whose arguments are on
> > later lines.  Reading each errmsg/errdetail/errhint call in full on
> > REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
> > the EXCEPT message in pg_publication.c.
> >
>
> Seeing the other usage, I am thinking to fix this case for except
> tables unless some major change is required. We can consider changing
> REFRESH MATERIALIZED VIEW CONCURRENTLY separately. I have few points
> for the that patch:
>
> * The existing function
> RelationGetQualifiedRelationName()->get_qualified_objname() used
> get_namespace_name_or_temp() where as patch used get_namespace_name().
> That could create the problem with temp tables as follows:
>
> Before patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> After patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> You can notice that temp schema name has _0 appended to it after
> patch, it seems to append backend's slot number. We can use
> get_namespace_name_or_temp() instead of get_namespace_name().
>
> * After this RelationGetQualifiedRelationName() is dead and is
> introduced by the commit a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
> which introduced this quoting problem. I feel it is better to remove
> it.
>
> Attached fixed both the problems.

The patch LGTM.

Another option would be to drop the hardcoded quotes from errormsg and
keep RelationGetQualifiedRelationName, but maintaining a consistent
error-messaging style across similar catalog checks is preferable.
Thus, the current patch looks good as-is.

thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
On Thu, Sep 17, 2026 at 4:11 PM Amit Kapila  wrote:
>
> On Thu, Sep 17, 2026 at 12:17 AM Manuel Reyes Bravo
>  wrote:
> >
> > vignesh C  wrote:
> > > Please have a look at the discussion regarding the commit in [1]
> > > thread. If you still feel that it needs further discussion, we can
> > > continue discussing your suggestion in the thread at [2], as it is not
> > > directly related to the topic of this current thread.
> >
> > Thanks, I had not seen [2].  Peter raised the nested quotes there on
> > May 11 with the same kind of example, and you considered them
> > acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
> > not a new finding, and I withdraw it.
> >
> > I also need to correct a number I gave.  I wrote that 55 errmsg() calls
> > in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
> > name inside quotes.  My search missed calls whose arguments are on
> > later lines.  Reading each errmsg/errdetail/errhint call in full on
> > REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
> > the EXCEPT message in pg_publication.c.
> >
>
> Seeing the other usage, I am thinking to fix this case for except
> tables unless some major change is required. We can consider changing
> REFRESH MATERIALIZED VIEW CONCURRENTLY separately. I have few points
> for the that patch:
>
> * The existing function
> RelationGetQualifiedRelationName()->get_qualified_objname() used
> get_namespace_name_or_temp() where as patch used get_namespace_name().
> That could create the problem with temp tables as follows:
>
> Before patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> After patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> You can notice that temp schema name has _0 appended to it after
> patch, it seems to append backend's slot number. We can use
> get_namespace_name_or_temp() instead of get_namespace_name().
>
> * After this RelationGetQualifiedRelationName() is dead and is
> introduced by the commit a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
> which introduced this quoting problem. I feel it is better to remove
> it.
>
> Attached fixed both the problems.
>

Hi Amit.

+ relname = psprintf("%s.%s",
+   get_namespace_name_or_temp(RelationGetNamespace(targetrel)),
+   RelationGetRelationName(targetrel));

I had been working off-list on a similar patch to this, so I like the
direction where this is heading.

OTOH please do not remove the RelationGetQualifiedRelationName function.

Instead, keep the function but replace the body with your
psprint/get_namespace_name_or_temp logic. There are many other places
where the errmsg can benefit from having a common function to output
fully qualified names, but we don't want them all needing to code
their own psprintf/get_namespace_name_or_temp.

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


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Thu, Sep 17, 2026 at 12:22 PM Peter Smith  wrote:
>
> On Thu, Sep 17, 2026 at 4:11 PM Amit Kapila  wrote:
> >
> > On Thu, Sep 17, 2026 at 12:17 AM Manuel Reyes Bravo
> >  wrote:
> > >
> > > vignesh C  wrote:
> > > > Please have a look at the discussion regarding the commit in [1]
> > > > thread. If you still feel that it needs further discussion, we can
> > > > continue discussing your suggestion in the thread at [2], as it is not
> > > > directly related to the topic of this current thread.
> > >
> > > Thanks, I had not seen [2].  Peter raised the nested quotes there on
> > > May 11 with the same kind of example, and you considered them
> > > acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
> > > not a new finding, and I withdraw it.
> > >
> > > I also need to correct a number I gave.  I wrote that 55 errmsg() calls
> > > in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
> > > name inside quotes.  My search missed calls whose arguments are on
> > > later lines.  Reading each errmsg/errdetail/errhint call in full on
> > > REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
> > > the EXCEPT message in pg_publication.c.
> > >
> >
> > Seeing the other usage, I am thinking to fix this case for except
> > tables unless some major change is required. We can consider changing
> > REFRESH MATERIALIZED VIEW CONCURRENTLY separately. I have few points
> > for the that patch:
> >
> > * The existing function
> > RelationGetQualifiedRelationName()->get_qualified_objname() used
> > get_namespace_name_or_temp() where as patch used get_namespace_name().
> > That could create the problem with temp tables as follows:
> >
> > Before patch:
> > postgres=# create publication mypub for all tables except(table mytemp);
> > ERROR:  cannot specify relation "pg_temp.mytemp" in the publication
> > EXCEPT clause
> > DETAIL:  This operation is not supported for temporary tables.
> >
> > After patch:
> > postgres=# create publication mypub for all tables except(table mytemp);
> > ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> > EXCEPT clause
> > DETAIL:  This operation is not supported for temporary tables.
> >
> > You can notice that temp schema name has _0 appended to it after
> > patch, it seems to append backend's slot number. We can use
> > get_namespace_name_or_temp() instead of get_namespace_name().
> >
> > * After this RelationGetQualifiedRelationName() is dead and is
> > introduced by the commit a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
> > which introduced this quoting problem. I feel it is better to remove
> > it.
> >
> > Attached fixed both the problems.
> >
>
> Hi Amit.
>
> + relname = psprintf("%s.%s",
> +   get_namespace_name_or_temp(RelationGetNamespace(targetrel)),
> +   RelationGetRelationName(targetrel));
>
> I had been working off-list on a similar patch to this, so I like the
> direction where this is heading.
>
> OTOH please do not remove the RelationGetQualifiedRelationName function.
>
> Instead, keep the function but replace the body with your
> psprint/get_namespace_name_or_temp logic. There are many other places
> where the errmsg can benefit from having a common function to output
> fully qualified names, but we don't want them all needing to code
> their own psprintf/get_namespace_name_or_temp.
>

Even if we go in that direction, it should be for PG20. In PG19, we
can't extend its usage. So, I prefer to drop it and if we can come up
with a use case for it that is acceptable then we can consider it
again.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Thu, Sep 17, 2026 at 11:41 AM Amit Kapila  wrote:
>
> On Thu, Sep 17, 2026 at 12:17 AM Manuel Reyes Bravo
>  wrote:
> >
> > vignesh C  wrote:
> > > Please have a look at the discussion regarding the commit in [1]
> > > thread. If you still feel that it needs further discussion, we can
> > > continue discussing your suggestion in the thread at [2], as it is not
> > > directly related to the topic of this current thread.
> >
> > Thanks, I had not seen [2].  Peter raised the nested quotes there on
> > May 11 with the same kind of example, and you considered them
> > acceptable, citing REFRESH MATERIALIZED VIEW CONCURRENTLY.  So 0002 is
> > not a new finding, and I withdraw it.
> >
> > I also need to correct a number I gave.  I wrote that 55 errmsg() calls
> > in src/backend use "\"%s.%s\"" against 3 that put a quoted qualified
> > name inside quotes.  My search missed calls whose arguments are on
> > later lines.  Reading each errmsg/errdetail/errhint call in full on
> > REL_19_STABLE, it is 70 against 2: matview.c (the case you cited) and
> > the EXCEPT message in pg_publication.c.
> >
>
> Seeing the other usage, I am thinking to fix this case for except
> tables unless some major change is required. We can consider changing
> REFRESH MATERIALIZED VIEW CONCURRENTLY separately. I have few points
> for the that patch:
>
> * The existing function
> RelationGetQualifiedRelationName()->get_qualified_objname() used
> get_namespace_name_or_temp() where as patch used get_namespace_name().
> That could create the problem with temp tables as follows:
>
> Before patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> After patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.
>
> You can notice that temp schema name has _0 appended to it after
> patch, it seems to append backend's slot number. We can use
> get_namespace_name_or_temp() instead of get_namespace_name().
>
> * After this RelationGetQualifiedRelationName() is dead and is
> introduced by the commit a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
> which introduced this quoting problem. I feel it is better to remove
> it.
>
> Attached fixed both the problems.
>

I reviewed/tested the patch. The changes LGTM.

--
Thanks,
Nisha


RE: Distinguish publication exclusions in object addresses

От:
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
Дата:
Hi,

On Thursday, September 17, 2026 2:11 PM Amit Kapila  wrote:
> Seeing the other usage, I am thinking to fix this case for except tables unless
> some major change is required. We can consider changing REFRESH
> MATERIALIZED VIEW CONCURRENTLY separately. I have few points for the
> that patch:
> 
> * The existing function
> RelationGetQualifiedRelationName()->get_qualified_objname() used
> get_namespace_name_or_temp() where as patch used
> get_namespace_name().
> That could create the problem with temp tables as follows:
> 
> Before patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp.mytemp" in the publication EXCEPT
> clause
> DETAIL:  This operation is not supported for temporary tables.
> 
> After patch:
> postgres=# create publication mypub for all tables except(table mytemp);
> ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> EXCEPT clause
> DETAIL:  This operation is not supported for temporary tables.

I checked the output for temporary objects a bit and found that the current
style is not consistent with other error messages and commands. For example,
other error messages output the actual schema name (pg_temp_xxx), while the
message touched in the patch reports only pg_temp.

I see this was changed since the original a49b9cf, which schema-qualified the
message. Although reporting pg_temp has some merits, it doesn't seem great to
change only one part of the error messages here. Maybe we can use pg_temp_xxx
for now and try to find a more general way to improve it later if needed.

Here are a few examples where pg_temp_XX is reported:

CREATE TEMP TABLE t(a int, b int);
CREATE STATISTICS pg_temp.s1 ON a,b FROM t;
CREATE STATISTICS pg_temp.s2 ON a,b FROM t;
ALTER STATISTICS pg_temp.s1 RENAME TO s2;
ERROR:  statistics object "s2" already exists in schema "pg_temp_0"

CREATE TEXT SEARCH DICTIONARY pg_temp.d1 (TEMPLATE = simple);
CREATE TEXT SEARCH DICTIONARY pg_temp.d2 (TEMPLATE = simple);
ALTER TEXT SEARCH DICTIONARY pg_temp.d1 RENAME TO d2;
ERROR:  text search dictionary "d2" already exists in schema "pg_temp_0"

postgres=# SELECT * FROM pg_identify_object('pg_class'::regclass, 'temp_tbl'::regclass, 0);
 type  |  schema   |   name   |     identity     
-------+-----------+----------+------------------
 table | pg_temp_1 | temp_tbl | pg_temp.temp_tbl

postgres=# \d
        List of relations
  Schema   | Name | Type  | Owner
-----------+------+-------+-------
 pg_temp_0 | test | table | houzj

select * from pg_namespace ;
 16384 | pg_temp_0          |       10 |

Best Regards,
Zhijie Hou

Re: Distinguish publication exclusions in object addresses

От:
vignesh C <vignesh21@gmail.com>
Дата:
Вложения:
On Thu, 17 Sept 2026 at 15:25, Zhijie Hou (Fujitsu)
 wrote:
>
> Hi,
>
> On Thursday, September 17, 2026 2:11 PM Amit Kapila  wrote:
> > Seeing the other usage, I am thinking to fix this case for except tables unless
> > some major change is required. We can consider changing REFRESH
> > MATERIALIZED VIEW CONCURRENTLY separately. I have few points for the
> > that patch:
> >
> > * The existing function
> > RelationGetQualifiedRelationName()->get_qualified_objname() used
> > get_namespace_name_or_temp() where as patch used
> > get_namespace_name().
> > That could create the problem with temp tables as follows:
> >
> > Before patch:
> > postgres=# create publication mypub for all tables except(table mytemp);
> > ERROR:  cannot specify relation "pg_temp.mytemp" in the publication EXCEPT
> > clause
> > DETAIL:  This operation is not supported for temporary tables.
> >
> > After patch:
> > postgres=# create publication mypub for all tables except(table mytemp);
> > ERROR:  cannot specify relation "pg_temp_0.mytemp" in the publication
> > EXCEPT clause
> > DETAIL:  This operation is not supported for temporary tables.
>
> I checked the output for temporary objects a bit and found that the current
> style is not consistent with other error messages and commands. For example,
> other error messages output the actual schema name (pg_temp_xxx), while the
> message touched in the patch reports only pg_temp.
>
> I see this was changed since the original a49b9cf, which schema-qualified the
> message. Although reporting pg_temp has some merits, it doesn't seem great to
> change only one part of the error messages here. Maybe we can use pg_temp_xxx
> for now and try to find a more general way to improve it later if needed.

That seems better, here is an updated v3 version to handle the same.
Same patch applies on pg19 branch and tests passes in both the
branches.

Regards,
Vignesh

Re: Distinguish publication exclusions in object addresses

От:
Manuel Reyes Bravo <manuelreyesbravo@gmail.com>
Дата:
Вложения:
vignesh C  wrote:
> That seems better, here is an updated v3 version to handle the same.
> Same patch applies on pg19 branch and tests passes in both the
> branches.

I tested v3 on master at bca67e5a33b and on REL_19_STABLE at
1d094904bc7: it applies cleanly, builds without warnings, and make check
passes on both.  With a relation name and a schema name that need
quoting, and a temporary table, the message goes from

    cannot specify relation "public."Part One"" in the publication EXCEPT clause
    cannot specify relation ""My Schema"."we""ird"" in the publication
EXCEPT clause
    cannot specify relation "pg_temp.tmp" in the publication EXCEPT clause

to

    cannot specify relation "public.Part One" in the publication EXCEPT clause
    cannot specify relation "My Schema.we"ird" in the publication EXCEPT clause
    cannot specify relation "pg_temp_0.tmp" in the publication EXCEPT clause

and the FOR TABLE message is unchanged.

v3 no longer has the temporary table test that v2 added, I assume because
the pg_temp_N number depends on the backend.  stats_ext.sql already deals
with that by redacting the number, and the attached top-up does the same,
so the case stays covered:

    NOTICE:  cannot specify relation
"pg_temp_REDACTED.testpub_temptbl" in the publication EXCEPT clause
(This operation is not supported for temporary tables.)

It passes on both branches, and the same block run from three sessions
at once, with temp schemas pg_temp_1, pg_temp_2 and pg_temp_3, prints the
same line in each.

Regards,
Manu

Re: Distinguish publication exclusions in object addresses

От:
Peter Smith <smithpb2250@gmail.com>
Дата:
Вложения:
AFAICT, the patch has traded one kind of quoting problem for another.

Before patch v3, the message might show nested quotes.

After patch v3, the message might show mismatched quotes:
CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "schema has
embedded "" quotes"."part has embedded "" quotes");
ERROR:  cannot specify relation "schema has embedded " quotes.part has
embedded " quotes" in the publication EXCEPT clause

~

PSA a v3 top-up patch to address the new problem.

Of course, putting my escape_embedded_quotes() function where I did in
the top-up doesn't seem appropriate. It would be better to associate
that with the original RelationGetQualifiedRelationName() and call it
from there, but RelationGetQualifiedRelationName was removed, so...

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

Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Thu, Sep 17, 2026 at 7:53 PM Manuel Reyes Bravo
 wrote:
>
> vignesh C  wrote:
> > That seems better, here is an updated v3 version to handle the same.
> > Same patch applies on pg19 branch and tests passes in both the
> > branches.
>
> v3 no longer has the temporary table test that v2 added, I assume because
> the pg_temp_N number depends on the backend.  stats_ext.sql already deals
> with that by redacting the number, and the attached top-up does the same,
> so the case stays covered:
>
>     NOTICE:  cannot specify relation
> "pg_temp_REDACTED.testpub_temptbl" in the publication EXCEPT clause
> (This operation is not supported for temporary tables.)
>
> It passes on both branches, and the same block run from three sessions
> at once, with temp schemas pg_temp_1, pg_temp_2 and pg_temp_3, prints the
> same line in each.
>

Thanks for sharing the testcase patch but I don't find compelling to
add it along with current patch due to: (a) it is not necessary to use
temp table to test this patch, (b) I am not sure we want to test all
negative cases especially with some special handling though I am open
to consider it separately as a test to increase code-coverage.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Fri, Sep 18, 2026 at 8:20 AM Peter Smith  wrote:
>
> AFAICT, the patch has traded one kind of quoting problem for another.
>
> Before patch v3, the message might show nested quotes.
>
> After patch v3, the message might show mismatched quotes:
> CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "schema has
> embedded "" quotes"."part has embedded "" quotes");
> ERROR:  cannot specify relation "schema has embedded " quotes.part has
> embedded " quotes" in the publication EXCEPT clause
>

This is not a problem but a general behavior in other cases as well.
For example, see few:
1.
postgres=# CREATE TABLE "a""b"(x int);
CREATE TABLE
postgres=# CREATE TABLE "a""b"(x int);
ERROR:  relation "a"b" already exists

Notice that the ERROR message contains single embedded quotes whereas
while specifying object there were double-quotes.
2.
postgres=# ALTER TABLE "a""b" ADD COLUMN y int;
ERROR:  relation "a"b" does not exist

Here also the behavior is the same as in previous example

pg_class also shows this table with single quotes as follows:
 16462 | a"b

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Fri, Sep 18, 2026 at 8:20 AM Peter Smith  wrote:
>
> AFAICT, the patch has traded one kind of quoting problem for another.
>
> Before patch v3, the message might show nested quotes.
>
> After patch v3, the message might show mismatched quotes:
> CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "schema has
> embedded "" quotes"."part has embedded "" quotes");
> ERROR:  cannot specify relation "schema has embedded " quotes.part has
> embedded " quotes" in the publication EXCEPT clause
>
> ~
>
> PSA a v3 top-up patch to address the new problem.
>
> Of course, putting my escape_embedded_quotes() function where I did in
> the top-up doesn't seem appropriate. It would be better to associate
> that with the original RelationGetQualifiedRelationName() and call it
> from there, but RelationGetQualifiedRelationName was removed, so...
>

At first, I felt it was a problem in the entire code for base Postgres
and thus could be fixed separately.  I tried to find queries on HEAD
where it already works and where it does not. Here are a few samples:

Problematic cases on HEAD:
1)
postgres=# SELECT '"schema has embedded "" quotes".nonexistent_table'::regclass;
ERROR:  relation "schema has embedded " quotes.nonexistent_table" does not exist
LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_table'::...
               ^
2)
postgres=# DROP TABLE "my""table";
ERROR:  table "my"table" does not exist


The case where it is correctly quoted:

1)
postgres=# CREATE MATERIALIZED VIEW "schema has embedded ""
quotes"."my_mv" AS SELECT 1 AS id;
SELECT 1

postgres=# REFRESH MATERIALIZED VIEW CONCURRENTLY "schema has embedded
"" quotes"."my_mv";
ERROR:  cannot refresh materialized view ""schema has embedded ""
quotes".my_mv" concurrently
HINT:  Create a unique index with no WHERE clause on one or more
columns of the materialized view.

2)
postgres=# SELECT '"schema has embedded ""
quotes".nonexistent_func(int)'::regprocedure;
ERROR:  function ""schema has embedded ""
quotes".nonexistent_func(int)" does not exist
LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_func(int...

So, I don't have a strong opinion on whether we should fix it here or
separately. Fixing it here would be slightly better though.

But if we plan to fix it, it would be good to see how
RefreshMatViewByOid() handles it without using the new function (which
Peter has added).

I tried it:
+#if 0
                relname = psprintf("%s.%s",
-
get_namespace_name(RelationGetNamespace(targetrel)),
-
RelationGetRelationName(targetrel));
+
escape_embedded_quotes(get_namespace_name(RelationGetNamespace(targetrel))),
+
escape_embedded_quotes(RelationGetRelationName(targetrel)));
                errormsg = gettext_noop("cannot specify relation
\"%s\" in the publication EXCEPT clause");
+#endif
+               relname = quote_qualified_identifier(
+
get_namespace_name_or_temp(RelationGetNamespace(targetrel)),
+
RelationGetRelationName(targetrel));
+               errormsg = gettext_noop("cannot specify relation %s in
the publication EXCEPT clause");


After this I get correct output here:
postgres=# CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE
"schema has embedded "" quotes"."part has embedded "" quotes");
ERROR:  cannot specify relation "schema has embedded "" quotes"."part
has embedded "" quotes" in the publication EXCEPT clause
DETAIL:  This operation is not supported for individual partitions.

But for existing tests (added in main 001 patch), I get this:
postgres=# CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE
"testpub Part2");
ERROR:  cannot specify relation public."testpub Part2" in the
publication EXCEPT clause
DETAIL:  This operation is not supported for individual partitions.

instead of:
ERROR:  cannot specify relation "public.testpub Part2" in the
publication EXCEPT clause
DETAIL:  This operation is not supported for individual partitions.

(Note: no quotes around public in new output.)


thanks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Fri, Sep 18, 2026 at 9:48 AM shveta malik  wrote:
>
> On Fri, Sep 18, 2026 at 8:20 AM Peter Smith  wrote:
> >
> > AFAICT, the patch has traded one kind of quoting problem for another.
> >
> > Before patch v3, the message might show nested quotes.
> >
> > After patch v3, the message might show mismatched quotes:
> > CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "schema has
> > embedded "" quotes"."part has embedded "" quotes");
> > ERROR:  cannot specify relation "schema has embedded " quotes.part has
> > embedded " quotes" in the publication EXCEPT clause
> >
> > ~
> >
> > PSA a v3 top-up patch to address the new problem.
> >
> > Of course, putting my escape_embedded_quotes() function where I did in
> > the top-up doesn't seem appropriate. It would be better to associate
> > that with the original RelationGetQualifiedRelationName() and call it
> > from there, but RelationGetQualifiedRelationName was removed, so...
> >
>
> At first, I felt it was a problem in the entire code for base Postgres
> and thus could be fixed separately.  I tried to find queries on HEAD
> where it already works and where it does not. Here are a few samples:
>
> Problematic cases on HEAD:
> 1)
> postgres=# SELECT '"schema has embedded "" quotes".nonexistent_table'::regclass;
> ERROR:  relation "schema has embedded " quotes.nonexistent_table" does not exist
> LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_table'::...
>                ^
> 2)
> postgres=# DROP TABLE "my""table";
> ERROR:  table "my"table" does not exist
>
>
> The case where it is correctly quoted:
>
> 1)
> postgres=# CREATE MATERIALIZED VIEW "schema has embedded ""
> quotes"."my_mv" AS SELECT 1 AS id;
> SELECT 1
>
> postgres=# REFRESH MATERIALIZED VIEW CONCURRENTLY "schema has embedded
> "" quotes"."my_mv";
> ERROR:  cannot refresh materialized view ""schema has embedded ""
> quotes".my_mv" concurrently
> HINT:  Create a unique index with no WHERE clause on one or more
> columns of the materialized view.
>
> 2)
> postgres=# SELECT '"schema has embedded ""
> quotes".nonexistent_func(int)'::regprocedure;
> ERROR:  function ""schema has embedded ""
> quotes".nonexistent_func(int)" does not exist
> LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_func(int...
>
> So, I don't have a strong opinion on whether we should fix it here or
> separately. Fixing it here would be slightly better though.
>

At first, I am not sure if this is a problem at all because we don't
use embedded quoting while storing objects and we display like that at
many places. It is better to start a new thread if one really feels
one or or the other way is correct.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Fri, Sep 18, 2026 at 9:56 AM Amit Kapila  wrote:
>
> On Fri, Sep 18, 2026 at 9:48 AM shveta malik  wrote:
> >
> > On Fri, Sep 18, 2026 at 8:20 AM Peter Smith  wrote:
> > >
> > > AFAICT, the patch has traded one kind of quoting problem for another.
> > >
> > > Before patch v3, the message might show nested quotes.
> > >
> > > After patch v3, the message might show mismatched quotes:
> > > CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "schema has
> > > embedded "" quotes"."part has embedded "" quotes");
> > > ERROR:  cannot specify relation "schema has embedded " quotes.part has
> > > embedded " quotes" in the publication EXCEPT clause
> > >
> > > ~
> > >
> > > PSA a v3 top-up patch to address the new problem.
> > >
> > > Of course, putting my escape_embedded_quotes() function where I did in
> > > the top-up doesn't seem appropriate. It would be better to associate
> > > that with the original RelationGetQualifiedRelationName() and call it
> > > from there, but RelationGetQualifiedRelationName was removed, so...
> > >
> >
> > At first, I felt it was a problem in the entire code for base Postgres
> > and thus could be fixed separately.  I tried to find queries on HEAD
> > where it already works and where it does not. Here are a few samples:
> >
> > Problematic cases on HEAD:
> > 1)
> > postgres=# SELECT '"schema has embedded "" quotes".nonexistent_table'::regclass;
> > ERROR:  relation "schema has embedded " quotes.nonexistent_table" does not exist
> > LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_table'::...
> >                ^
> > 2)
> > postgres=# DROP TABLE "my""table";
> > ERROR:  table "my"table" does not exist
> >
> >
> > The case where it is correctly quoted:
> >
> > 1)
> > postgres=# CREATE MATERIALIZED VIEW "schema has embedded ""
> > quotes"."my_mv" AS SELECT 1 AS id;
> > SELECT 1
> >
> > postgres=# REFRESH MATERIALIZED VIEW CONCURRENTLY "schema has embedded
> > "" quotes"."my_mv";
> > ERROR:  cannot refresh materialized view ""schema has embedded ""
> > quotes".my_mv" concurrently
> > HINT:  Create a unique index with no WHERE clause on one or more
> > columns of the materialized view.
> >
> > 2)
> > postgres=# SELECT '"schema has embedded ""
> > quotes".nonexistent_func(int)'::regprocedure;
> > ERROR:  function ""schema has embedded ""
> > quotes".nonexistent_func(int)" does not exist
> > LINE 1: SELECT '"schema has embedded "" quotes".nonexistent_func(int...
> >
> > So, I don't have a strong opinion on whether we should fix it here or
> > separately. Fixing it here would be slightly better though.
> >
>
> At first, I am not sure if this is a problem at all because we don't
> use embedded quoting while storing objects and we display like that at
> many places.

Yes, right.

> It is better to start a new thread if one really feels
> one or or the other way is correct.

I agree.

tahnks
Shveta


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Fri, Sep 18, 2026 at 10:17 AM shveta malik  wrote:
>
> On Fri, Sep 18, 2026 at 9:56 AM Amit Kapila  wrote:
> >
>
> > It is better to start a new thread if one really feels
> > one or or the other way is correct.
>
> I agree.
>

I have pushed the patch.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Вложения:
Hi Amit,

> Thanks for sharing the testcase patch but I don't find compelling to
> add it along with current patch due to: (a) it is not necessary to use
> temp table to test this patch, (b) I am not sure we want to test all
> negative cases especially with some special handling though I am open
> to consider it separately as a test to increase code-coverage.

Fair enough on both counts, and (a) was right: the temporary table was
incidental to that patch. Here it is as the separate coverage patch you
were open to, and with a reason to exist that does not depend on the
quoting fix.

check_publication_add_relation() can report

    cannot specify relation "%s" in the publication EXCEPT clause

from six different ereport() sites: a partition with an incomplete
detach, an individual partition, an unsupported relkind, a system
table, a conflict log table, and a temporary or unlogged relation.

Of those six, the regression tests currently reach one. Grepping the
expected output for that message finds a single DETAIL:

    DETAIL:  This operation is not supported for individual partitions.

The attached patch covers three more, all in publication.sql next to
the existing non-EXCEPT cases for the same relations:

    view          -> not supported for views.
    system table  -> not supported for system tables.
    temp table    -> not supported for temporary tables.

(the DETAIL of each, verbatim: "This operation is ...")

The first two are plain statements. The temporary one prints the
message with the schema number redacted, because pg_temp_N depends on
the backend; stats_ext.sql already does this. I ran the same block from
three concurrent sessions, which got pg_temp_1, pg_temp_2 and pg_temp_3,
and all three printed the identical line.

make check passes, 239/239.

I left the two paths I could not reach cheaply: the incomplete-detach
case needs an interrupted concurrent detach, and the conflict log table
case needs that namespace to exist. Happy to drop any of the three if
you would rather keep publication.sql shorter - the system table and
view cases are the ones that cost nothing.

Regards,
Manu

Re: Distinguish publication exclusions in object addresses

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Correcting myself before you spend time on this: I wrote

> Of those six, the regression tests currently reach one.

and that is wrong. I had inferred it from grepping the expected output
for the EXCEPT message, without measuring the code. I have now built
with --enable-coverage and run make check. The ereport() call sites in
check_publication_add_relation() come out like this (gcov execution
counts, master):

  incomplete detach                 never executed
  individual partitions             2
  relkind not supported             2
  system tables                     1
  conflict log tables               1
  temporary tables                  1
  unlogged tables                   1

So five of the six already execute. They are reached through the
non-EXCEPT path: the same ereport() runs with the other errormsg, from
the existing "cannot add relation ... to publication" cases. Only the
incomplete-detach one is never reached at all.

What my patch actually changes, same measurement with it applied:

  relkind not supported             2 -> 3
  system tables                     1 -> 2
  temporary tables                  1 -> 2

so it adds three executions, but not three uncovered lines.

That weakens the case I made. The honest version is narrower: line
coverage of those sites does not change, what is untested is the
EXCEPT variant of each of them - the message whose quoting vignesh
just fixed, and the schema-qualified name it prints. Today exactly one
of those six paths has an expected output containing "in the
publication EXCEPT clause", the partitions one.

Whether that is worth three test cases is your call, and I would
understand if the answer is no now that the coverage argument is off
the table. If you do want something from this, the incomplete-detach
site is the one genuinely never executed, though reaching it needs an
interrupted concurrent detach and I have not tried to build that.

Sorry for the noise.

Regards,
Manu


Re: Distinguish publication exclusions in object addresses

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Sep 23, 2026 at 5:12 AM Manu  wrote:
>
> Correcting myself before you spend time on this: I wrote
>
> > Of those six, the regression tests currently reach one.
>
> and that is wrong. I had inferred it from grepping the expected output
> for the EXCEPT message, without measuring the code. I have now built
> with --enable-coverage and run make check. The ereport() call sites in
> check_publication_add_relation() come out like this (gcov execution
> counts, master):
>
>   incomplete detach                 never executed
>   individual partitions             2
>   relkind not supported             2
>   system tables                     1
>   conflict log tables               1
>   temporary tables                  1
>   unlogged tables                   1
>
> So five of the six already execute. They are reached through the
> non-EXCEPT path: the same ereport() runs with the other errormsg, from
> the existing "cannot add relation ... to publication" cases. Only the
> incomplete-detach one is never reached at all.
>
> What my patch actually changes, same measurement with it applied:
>
>   relkind not supported             2 -> 3
>   system tables                     1 -> 2
>   temporary tables                  1 -> 2
>
> so it adds three executions, but not three uncovered lines.
>
> That weakens the case I made. The honest version is narrower: line
> coverage of those sites does not change, what is untested is the
> EXCEPT variant of each of them - the message whose quoting vignesh
> just fixed, and the schema-qualified name it prints. Today exactly one
> of those six paths has an expected output containing "in the
> publication EXCEPT clause", the partitions one.
>
> Whether that is worth three test cases is your call, and I would
> understand if the answer is no now that the coverage argument is off
> the table. If you do want something from this, the incomplete-detach
> site is the one genuinely never executed, though reaching it needs an
> interrupted concurrent detach and I have not tried to build that.
>

I am not against adding the tests for code coverage in general but for
negative tests we need to be careful to not add too many. I am content
with the current coverage of the negative cases but if you still want
to pursue, I suggest making a case in a separate email with a
HEAD-only patch. If we see that others see a value in the proposal
then we can consider it.

> Sorry for the noise.
>

No issues, thanks for the detailed analysis.

-- 
With Regards,
Amit Kapila.


Re: Distinguish publication exclusions in object addresses

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Sep 23, 2026 at 10:08 AM Amit Kapila  wrote:
>
> On Wed, Sep 23, 2026 at 5:12 AM Manu  wrote:
> >
> > Correcting myself before you spend time on this: I wrote
> >
> > > Of those six, the regression tests currently reach one.
> >
> > and that is wrong. I had inferred it from grepping the expected output
> > for the EXCEPT message, without measuring the code. I have now built
> > with --enable-coverage and run make check. The ereport() call sites in
> > check_publication_add_relation() come out like this (gcov execution
> > counts, master):
> >
> >   incomplete detach                 never executed
> >   individual partitions             2
> >   relkind not supported             2
> >   system tables                     1
> >   conflict log tables               1
> >   temporary tables                  1
> >   unlogged tables                   1
> >
> > So five of the six already execute. They are reached through the
> > non-EXCEPT path: the same ereport() runs with the other errormsg, from
> > the existing "cannot add relation ... to publication" cases. Only the
> > incomplete-detach one is never reached at all.
> >
> > What my patch actually changes, same measurement with it applied:
> >
> >   relkind not supported             2 -> 3
> >   system tables                     1 -> 2
> >   temporary tables                  1 -> 2
> >
> > so it adds three executions, but not three uncovered lines.
> >
> > That weakens the case I made. The honest version is narrower: line
> > coverage of those sites does not change, what is untested is the
> > EXCEPT variant of each of them - the message whose quoting vignesh
> > just fixed, and the schema-qualified name it prints. Today exactly one
> > of those six paths has an expected output containing "in the
> > publication EXCEPT clause", the partitions one.
> >
> > Whether that is worth three test cases is your call, and I would
> > understand if the answer is no now that the coverage argument is off
> > the table. If you do want something from this, the incomplete-detach
> > site is the one genuinely never executed, though reaching it needs an
> > interrupted concurrent detach and I have not tried to build that.
> >
>
> I am not against adding the tests for code coverage in general but for
> negative tests we need to be careful to not add too many. I am content
> with the current coverage of the negative cases but if you still want
> to pursue, I suggest making a case in a separate email with a
> HEAD-only patch.

+1.

> If we see that others see a value in the proposal
> then we can consider it.
>
> > Sorry for the noise.
> >
>
> No issues, thanks for the detailed analysis.
>
> --
> With Regards,
> Amit Kapila.


FAQ