Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a31baf

Browse files
committed
Fix objectaddress.c code for publication relations.
getObjectDescription and getObjectIdentity failed to schema-qualifythe name of the published table, which is bad in getObjectDescription andunforgivable in getObjectIdentity. Actually, getObjectIdentity failed toemit the table's name at all unless "objname" output is requested, whichaccidentally works for some (all?) extant callers but is clearly not theintended API. Somebody had also not gotten the memo that the output ofgetObjectIdentity is not to be translated.To fix getObjectDescription, I made it call getRelationDescription, whichrequired refactoring the translatable string for the case, but is morefuture-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 Xin 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 parent056f52d commit1a31baf

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,7 @@ getObjectDescription(const ObjectAddress *object)
34673467
HeapTupletup;
34683468
char*pubname;
34693469
Form_pg_publication_relprform;
3470+
StringInfoDatarel;
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
staticvoid
35423550
getRelationDescription(StringInfobuffer,Oidrelid)
@@ -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

Lines changed: 1 addition & 1 deletion
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)

[8]ページ先頭

©2009-2025 Movatter.jp