Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a31baf

Browse files
committed
Fix objectaddress.c code for publication relations.
getObjectDescription and getObjectIdentity failed to schema-qualify the name of the published table, which is bad in getObjectDescription and unforgivable in getObjectIdentity. Actually, getObjectIdentity failed to emit the table's name at all unless "objname" output is requested, which accidentally works for some (all?) extant callers but is clearly not the intended API. Somebody had also not gotten the memo that the output of getObjectIdentity is not to be translated. To fix getObjectDescription, I made it call getRelationDescription, which required refactoring the translatable string for the case, but is more future-proof in case we ever publish relations that aren't plain tables. While at it, I made the English output look like "publication of table X in publication Y"; the added "of" seems to me to make it read much better. Back-patch to v10 where publications were introduced. Discussion: https://postgr.es/m/20180522.182020.114074746.horiguchi.kyotaro@lab.ntt.co.jp
1 parent 056f52d commit 1a31baf

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/backend/catalog/objectaddress.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,7 @@ getObjectDescription(const ObjectAddress *object)
34673467
HeapTuple tup;
34683468
char *pubname;
34693469
Form_pg_publication_rel prform;
3470+
StringInfoData rel;
34703471

34713472
tup = SearchSysCache1(PUBLICATIONREL,
34723473
ObjectIdGetDatum(object->objectId));
@@ -3477,8 +3478,13 @@ getObjectDescription(const ObjectAddress *object)
34773478
prform = (Form_pg_publication_rel) GETSTRUCT(tup);
34783479
pubname = get_publication_name(prform->prpubid);
34793480

3480-
appendStringInfo(&buffer, _("publication table %s in publication %s"),
3481-
get_rel_name(prform->prrelid), pubname);
3481+
initStringInfo(&rel);
3482+
getRelationDescription(&rel, prform->prrelid);
3483+
3484+
/* translator: first %s is, e.g., "table %s" */
3485+
appendStringInfo(&buffer, _("publication of %s in publication %s"),
3486+
rel.data, pubname);
3487+
pfree(rel.data);
34823488
ReleaseSysCache(tup);
34833489
break;
34843490
}
@@ -3537,6 +3543,8 @@ getObjectDescriptionOids(Oid classid, Oid objid)
35373543

35383544
/*
35393545
* subroutine for getObjectDescription: describe a relation
3546+
*
3547+
* The result is appended to "buffer".
35403548
*/
35413549
static void
35423550
getRelationDescription(StringInfo buffer, Oid relid)
@@ -5007,14 +5015,11 @@ getObjectIdentityParts(const ObjectAddress *object,
50075015
prform = (Form_pg_publication_rel) GETSTRUCT(tup);
50085016
pubname = get_publication_name(prform->prpubid);
50095017

5010-
appendStringInfo(&buffer, _("%s in publication %s"),
5011-
get_rel_name(prform->prrelid), pubname);
5018+
getRelationIdentity(&buffer, prform->prrelid, objname);
5019+
appendStringInfo(&buffer, " in publication %s", pubname);
50125020

5013-
if (objname)
5014-
{
5015-
getRelationIdentity(&buffer, prform->prrelid, objname);
5021+
if (objargs)
50165022
*objargs = list_make1(pubname);
5017-
}
50185023

50195024
ReleaseSysCache(tup);
50205025
break;

src/test/regress/expected/object_address.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
477477
text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t
478478
subscription | | addr_sub | addr_sub | t
479479
publication | | addr_pub | addr_pub | t
480-
publication relation | | | gentable in publication addr_pub | t
480+
publication relation | | | addr_nsp.gentable in publication addr_pub | t
481481
(47 rows)
482482

483483
---

0 commit comments

Comments
 (0)