mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-15 08:20:16 +08: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:
parent
bf22d2707a
commit
cf34e373fc
@ -2510,14 +2510,17 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Oid useid;
|
Oid useid;
|
||||||
char *usename;
|
char *usename;
|
||||||
|
Form_pg_user_mapping umform;
|
||||||
|
ForeignServer *srv;
|
||||||
|
|
||||||
tup = SearchSysCache1(USERMAPPINGOID,
|
tup = SearchSysCache1(USERMAPPINGOID,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
if (!HeapTupleIsValid(tup))
|
if (!HeapTupleIsValid(tup))
|
||||||
elog(ERROR, "cache lookup failed for user mapping %u",
|
elog(ERROR, "cache lookup failed for user mapping %u",
|
||||||
object->objectId);
|
object->objectId);
|
||||||
|
umform = (Form_pg_user_mapping) GETSTRUCT(tup);
|
||||||
useid = ((Form_pg_user_mapping) GETSTRUCT(tup))->umuser;
|
useid = umform->umuser;
|
||||||
|
srv = GetForeignServer(umform->umserver);
|
||||||
|
|
||||||
ReleaseSysCache(tup);
|
ReleaseSysCache(tup);
|
||||||
|
|
||||||
@ -2526,7 +2529,8 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
else
|
else
|
||||||
usename = "public";
|
usename = "public";
|
||||||
|
|
||||||
appendStringInfo(&buffer, _("user mapping for %s"), usename);
|
appendStringInfo(&buffer, _("user mapping for %s on server %s"), usename,
|
||||||
|
srv->servername);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3906,19 +3910,18 @@ getObjectIdentityParts(const ObjectAddress *object,
|
|||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Oid useid;
|
Oid useid;
|
||||||
|
Form_pg_user_mapping umform;
|
||||||
|
ForeignServer *srv;
|
||||||
const char *usename;
|
const char *usename;
|
||||||
|
|
||||||
/* no objname support */
|
|
||||||
if (objname)
|
|
||||||
*objname = NIL;
|
|
||||||
|
|
||||||
tup = SearchSysCache1(USERMAPPINGOID,
|
tup = SearchSysCache1(USERMAPPINGOID,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
if (!HeapTupleIsValid(tup))
|
if (!HeapTupleIsValid(tup))
|
||||||
elog(ERROR, "cache lookup failed for user mapping %u",
|
elog(ERROR, "cache lookup failed for user mapping %u",
|
||||||
object->objectId);
|
object->objectId);
|
||||||
|
umform = (Form_pg_user_mapping) GETSTRUCT(tup);
|
||||||
useid = ((Form_pg_user_mapping) GETSTRUCT(tup))->umuser;
|
useid = umform->umuser;
|
||||||
|
srv = GetForeignServer(umform->umserver);
|
||||||
|
|
||||||
ReleaseSysCache(tup);
|
ReleaseSysCache(tup);
|
||||||
|
|
||||||
@ -3927,7 +3930,14 @@ getObjectIdentityParts(const ObjectAddress *object,
|
|||||||
else
|
else
|
||||||
usename = "public";
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ CREATE USER MAPPING FOR current_user SERVER s1;
|
|||||||
DROP FOREIGN DATA WRAPPER foo; -- ERROR
|
DROP FOREIGN DATA WRAPPER foo; -- ERROR
|
||||||
ERROR: cannot drop foreign-data wrapper foo because other objects depend on it
|
ERROR: cannot drop foreign-data wrapper foo because other objects depend on it
|
||||||
DETAIL: server s1 depends on foreign-data wrapper foo
|
DETAIL: server s1 depends on foreign-data wrapper foo
|
||||||
user mapping for foreign_data_user depends on server s1
|
user mapping for foreign_data_user on server s1 depends on server s1
|
||||||
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
||||||
SET ROLE regress_test_role;
|
SET ROLE regress_test_role;
|
||||||
DROP FOREIGN DATA WRAPPER foo CASCADE; -- ERROR
|
DROP FOREIGN DATA WRAPPER foo CASCADE; -- ERROR
|
||||||
@ -256,7 +256,7 @@ RESET ROLE;
|
|||||||
DROP FOREIGN DATA WRAPPER foo CASCADE;
|
DROP FOREIGN DATA WRAPPER foo CASCADE;
|
||||||
NOTICE: drop cascades to 2 other objects
|
NOTICE: drop cascades to 2 other objects
|
||||||
DETAIL: drop cascades to server s1
|
DETAIL: drop cascades to server s1
|
||||||
drop cascades to user mapping for foreign_data_user
|
drop cascades to user mapping for foreign_data_user on server s1
|
||||||
\dew+
|
\dew+
|
||||||
List of foreign-data wrappers
|
List of foreign-data wrappers
|
||||||
Name | Owner | Handler | Validator | Access privileges | FDW Options | Description
|
Name | Owner | Handler | Validator | Access privileges | FDW Options | Description
|
||||||
@ -526,10 +526,10 @@ CREATE USER MAPPING FOR current_user SERVER s3;
|
|||||||
|
|
||||||
DROP SERVER s3; -- ERROR
|
DROP SERVER s3; -- ERROR
|
||||||
ERROR: cannot drop server s3 because other objects depend on it
|
ERROR: cannot drop server s3 because other objects depend on it
|
||||||
DETAIL: user mapping for foreign_data_user depends on server s3
|
DETAIL: user mapping for foreign_data_user on server s3 depends on server s3
|
||||||
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
||||||
DROP SERVER s3 CASCADE;
|
DROP SERVER s3 CASCADE;
|
||||||
NOTICE: drop cascades to user mapping for foreign_data_user
|
NOTICE: drop cascades to user mapping for foreign_data_user on server s3
|
||||||
\des
|
\des
|
||||||
List of foreign servers
|
List of foreign servers
|
||||||
Name | Owner | Foreign-data wrapper
|
Name | Owner | Foreign-data wrapper
|
||||||
@ -1183,8 +1183,8 @@ GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role;
|
|||||||
CREATE USER MAPPING FOR current_user SERVER s9;
|
CREATE USER MAPPING FOR current_user SERVER s9;
|
||||||
DROP SERVER s9 CASCADE;
|
DROP SERVER s9 CASCADE;
|
||||||
NOTICE: drop cascades to 2 other objects
|
NOTICE: drop cascades to 2 other objects
|
||||||
DETAIL: drop cascades to user mapping for public
|
DETAIL: drop cascades to user mapping for public on server s9
|
||||||
drop cascades to user mapping for unprivileged_role
|
drop cascades to user mapping for unprivileged_role on server s9
|
||||||
RESET ROLE;
|
RESET ROLE;
|
||||||
CREATE SERVER s9 FOREIGN DATA WRAPPER foo;
|
CREATE SERVER s9 FOREIGN DATA WRAPPER foo;
|
||||||
GRANT USAGE ON FOREIGN SERVER s9 TO unprivileged_role;
|
GRANT USAGE ON FOREIGN SERVER s9 TO unprivileged_role;
|
||||||
@ -1256,14 +1256,14 @@ DROP ROLE regress_test_role; -- ERROR
|
|||||||
ERROR: role "regress_test_role" cannot be dropped because some objects depend on it
|
ERROR: role "regress_test_role" cannot be dropped because some objects depend on it
|
||||||
DETAIL: privileges for server s4
|
DETAIL: privileges for server s4
|
||||||
privileges for foreign-data wrapper foo
|
privileges for foreign-data wrapper foo
|
||||||
owner of user mapping for regress_test_role
|
owner of user mapping for regress_test_role on server s6
|
||||||
owner of user mapping for regress_test_role
|
owner of user mapping for regress_test_role on server s5
|
||||||
owner of server s5
|
owner of server s5
|
||||||
owner of server t2
|
owner of server t2
|
||||||
DROP SERVER s5 CASCADE;
|
DROP SERVER s5 CASCADE;
|
||||||
NOTICE: drop cascades to user mapping for regress_test_role
|
NOTICE: drop cascades to user mapping for regress_test_role on server s5
|
||||||
DROP SERVER t1 CASCADE;
|
DROP SERVER t1 CASCADE;
|
||||||
NOTICE: drop cascades to user mapping for public
|
NOTICE: drop cascades to user mapping for public on server t1
|
||||||
DROP SERVER t2;
|
DROP SERVER t2;
|
||||||
DROP USER MAPPING FOR regress_test_role SERVER s6;
|
DROP USER MAPPING FOR regress_test_role SERVER s6;
|
||||||
-- This test causes some order dependent cascade detail output,
|
-- This test causes some order dependent cascade detail output,
|
||||||
@ -1274,8 +1274,8 @@ NOTICE: drop cascades to 5 other objects
|
|||||||
\set VERBOSITY default
|
\set VERBOSITY default
|
||||||
DROP SERVER s8 CASCADE;
|
DROP SERVER s8 CASCADE;
|
||||||
NOTICE: drop cascades to 2 other objects
|
NOTICE: drop cascades to 2 other objects
|
||||||
DETAIL: drop cascades to user mapping for foreign_data_user
|
DETAIL: drop cascades to user mapping for foreign_data_user on server s8
|
||||||
drop cascades to user mapping for public
|
drop cascades to user mapping for public on server s8
|
||||||
DROP ROLE regress_test_indirect;
|
DROP ROLE regress_test_indirect;
|
||||||
DROP ROLE regress_test_role;
|
DROP ROLE regress_test_role;
|
||||||
DROP ROLE unprivileged_role; -- ERROR
|
DROP ROLE unprivileged_role; -- ERROR
|
||||||
|
Loading…
Reference in New Issue
Block a user