diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 8b119c82528..1e24f4b80be 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -1897,6 +1897,9 @@ get_object_address_publication_rel(ObjectType objtype, List *object, /* fetch publication name from input list */ pubname = strVal(lsecond(object)); + Assert(objtype == OBJECT_PUBLICATION_REL || + objtype == OBJECT_PUBLICATION_EXCLUDED_REL); + /* Now look up the pg_publication tuple */ pub = GetPublicationByName(pubname, missing_ok); if (!pub) @@ -1916,10 +1919,18 @@ get_object_address_publication_rel(ObjectType objtype, List *object, 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))); + { + if (objtype == OBJECT_PUBLICATION_EXCLUDED_REL) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("publication excluded relation \"%s\" in 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))); + } relation_close(relation, AccessShareLock); return address; } @@ -1929,9 +1940,6 @@ get_object_address_publication_rel(ObjectType objtype, List *object, isexcept = prform->prexcept; ReleaseSysCache(tup); - Assert(objtype == OBJECT_PUBLICATION_REL || - objtype == OBJECT_PUBLICATION_EXCLUDED_REL); - /* * 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 diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 7ccfb5810a6..d51b27d7d02 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -296,7 +296,7 @@ ERROR: "testpub_tbl1" is not a published relation of publication "testpub_foral -- 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 +ERROR: publication excluded relation "testpub_tbl1" in publication "testpub_default" does not exist -- Check pg_describe_object output for both included and excluded entries SELECT p.pubname, pg_describe_object('pg_publication_rel'::regclass, pr.oid, 0) AS description,