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

Commite8cb8fd

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 parenteb1aa1b commite8cb8fd

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
@@ -3446,6 +3446,7 @@ getObjectDescription(const ObjectAddress *object)
34463446
HeapTupletup;
34473447
char*pubname;
34483448
Form_pg_publication_relprform;
3449+
StringInfoDatarel;
34493450

34503451
tup=SearchSysCache1(PUBLICATIONREL,
34513452
ObjectIdGetDatum(object->objectId));
@@ -3456,8 +3457,13 @@ getObjectDescription(const ObjectAddress *object)
34563457
prform= (Form_pg_publication_rel)GETSTRUCT(tup);
34573458
pubname=get_publication_name(prform->prpubid);
34583459

3459-
appendStringInfo(&buffer,_("publication table %s in publication %s"),
3460-
get_rel_name(prform->prrelid),pubname);
3460+
initStringInfo(&rel);
3461+
getRelationDescription(&rel,prform->prrelid);
3462+
3463+
/* translator: first %s is, e.g., "table %s" */
3464+
appendStringInfo(&buffer,_("publication of %s in publication %s"),
3465+
rel.data,pubname);
3466+
pfree(rel.data);
34613467
ReleaseSysCache(tup);
34623468
break;
34633469
}
@@ -3516,6 +3522,8 @@ getObjectDescriptionOids(Oid classid, Oid objid)
35163522

35173523
/*
35183524
* subroutine for getObjectDescription: describe a relation
3525+
*
3526+
* The result is appended to "buffer".
35193527
*/
35203528
staticvoid
35213529
getRelationDescription(StringInfobuffer,Oidrelid)
@@ -4982,14 +4990,11 @@ getObjectIdentityParts(const ObjectAddress *object,
49824990
prform= (Form_pg_publication_rel)GETSTRUCT(tup);
49834991
pubname=get_publication_name(prform->prpubid);
49844992

4985-
appendStringInfo(&buffer,_("%s in publication %s"),
4986-
get_rel_name(prform->prrelid),pubname);
4993+
getRelationIdentity(&buffer,prform->prrelid,objname);
4994+
appendStringInfo(&buffer," in publication %s",pubname);
49874995

4988-
if (objname)
4989-
{
4990-
getRelationIdentity(&buffer,prform->prrelid,objname);
4996+
if (objargs)
49914997
*objargs=list_make1(pubname);
4992-
}
49934998

49944999
ReleaseSysCache(tup);
49955000
break;

‎src/test/regress/expected/object_address.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
468468
text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t
469469
subscription | | addr_sub | addr_sub | t
470470
publication | | addr_pub | addr_pub | t
471-
publication relation | | | gentable in publication addr_pub | t
471+
publication relation | | |addr_nsp.gentable in publication addr_pub | t
472472
(46 rows)
473473

474474
---

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp