1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-11 10:01:57 +03:00

Fix user mapping object description

We were using "user mapping for user XYZ" as description for user mappings, but
that's ambiguous because users can have mappings on multiple foreign
servers; therefore change it to "for user XYZ on server UVW" instead.
Object identities for user mappings are also updated in the same way, in
branches 9.3 and above.

The incomplete description string was introduced together with the whole
SQL/MED infrastructure by commit cae565e503 of 8.4 era, so backpatch all
the way back.
This commit is contained in:
Alvaro Herrera
2015-03-05 18:03:16 -03:00
parent bf22d2707a
commit cf34e373fc
2 changed files with 32 additions and 22 deletions

View File

@ -2510,14 +2510,17 @@ getObjectDescription(const ObjectAddress *object)
HeapTuple tup;
Oid useid;
char *usename;
Form_pg_user_mapping umform;
ForeignServer *srv;
tup = SearchSysCache1(USERMAPPINGOID,
ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for user mapping %u",
object->objectId);
useid = ((Form_pg_user_mapping) GETSTRUCT(tup))->umuser;
umform = (Form_pg_user_mapping) GETSTRUCT(tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
ReleaseSysCache(tup);
@ -2526,7 +2529,8 @@ getObjectDescription(const ObjectAddress *object)
else
usename = "public";
appendStringInfo(&buffer, _("user mapping for %s"), usename);
appendStringInfo(&buffer, _("user mapping for %s on server %s"), usename,
srv->servername);
break;
}
@ -3906,19 +3910,18 @@ getObjectIdentityParts(const ObjectAddress *object,
{
HeapTuple tup;
Oid useid;
Form_pg_user_mapping umform;
ForeignServer *srv;
const char *usename;
/* no objname support */
if (objname)
*objname = NIL;
tup = SearchSysCache1(USERMAPPINGOID,
ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for user mapping %u",
object->objectId);
useid = ((Form_pg_user_mapping) GETSTRUCT(tup))->umuser;
umform = (Form_pg_user_mapping) GETSTRUCT(tup);
useid = umform->umuser;
srv = GetForeignServer(umform->umserver);
ReleaseSysCache(tup);
@ -3927,7 +3930,14 @@ getObjectIdentityParts(const ObjectAddress *object,
else
usename = "public";
appendStringInfoString(&buffer, usename);
if (objname)
{
*objname = list_make1(pstrdup(usename));
*objargs = list_make1(pstrdup(srv->servername));
}
appendStringInfo(&buffer, "%s on server %s", usename,
srv->servername);
break;
}