diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index bc176e67973..90f68ec7070 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -2599,6 +2599,8 @@ getObjectDescription(const ObjectAddress *object) HeapTuple tup; Oid useid; char *usename; + Form_pg_user_mapping umform; + ForeignServer *srv; tup = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(object->objectId)); @@ -2606,7 +2608,9 @@ getObjectDescription(const ObjectAddress *object) 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); @@ -2615,7 +2619,9 @@ 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; } diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index fcc1d7cceac..4c348d04ac4 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -238,7 +238,7 @@ CREATE USER MAPPING FOR current_user SERVER s1; DROP FOREIGN DATA WRAPPER foo; -- ERROR ERROR: cannot drop foreign-data wrapper foo because other objects depend on it 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. SET ROLE regress_test_role; DROP FOREIGN DATA WRAPPER foo CASCADE; -- ERROR @@ -248,7 +248,7 @@ RESET ROLE; DROP FOREIGN DATA WRAPPER foo CASCADE; NOTICE: drop cascades to 2 other objects 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+ List of foreign-data wrappers Name | Owner | Validator | Access privileges | Options @@ -500,10 +500,10 @@ CREATE USER MAPPING FOR current_user SERVER s3; DROP SERVER s3; -- ERROR 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. 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 List of foreign servers Name | Owner | Foreign-data wrapper @@ -924,8 +924,8 @@ GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role; CREATE USER MAPPING FOR current_user SERVER s9; DROP SERVER s9 CASCADE; NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for public -drop cascades to user mapping for unprivileged_role +DETAIL: drop cascades to user mapping for public on server s9 +drop cascades to user mapping for unprivileged_role on server s9 RESET ROLE; CREATE SERVER s9 FOREIGN DATA WRAPPER foo; GRANT USAGE ON FOREIGN SERVER s9 TO unprivileged_role; @@ -943,27 +943,27 @@ DROP ROLE regress_test_role; -- ERROR ERROR: role "regress_test_role" cannot be dropped because some objects depend on it DETAIL: privileges for server s4 privileges for foreign-data wrapper foo -owner of user mapping for regress_test_role -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 on server s5 owner of server s5 owner of server t2 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; -NOTICE: drop cascades to user mapping for public +NOTICE: drop cascades to user mapping for public on server t1 DROP SERVER t2; DROP USER MAPPING FOR regress_test_role SERVER s6; DROP FOREIGN DATA WRAPPER foo CASCADE; NOTICE: drop cascades to 5 other objects DETAIL: drop cascades to server s4 -drop cascades to user mapping for foreign_data_user +drop cascades to user mapping for foreign_data_user on server s4 drop cascades to server s6 drop cascades to server s9 -drop cascades to user mapping for unprivileged_role +drop cascades to user mapping for unprivileged_role on server s9 DROP SERVER s8 CASCADE; NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for foreign_data_user -drop cascades to user mapping for public +DETAIL: drop cascades to user mapping for foreign_data_user on server s8 +drop cascades to user mapping for public on server s8 DROP ROLE regress_test_indirect; DROP ROLE regress_test_role; DROP ROLE unprivileged_role; -- ERROR