8000 For REASSIGN OWNED for foreign user mappings · qadahtm/postgres@f44c520 · GitHub
[go: up one dir, main page]

Skip to content

Commit f44c520

Browse files
committed
For REASSIGN OWNED for foreign user mappings
As reported in bug #13809 by Alexander Ashurkov, the code for REASSIGN OWNED hadn't gotten word about user mappings. Deal with them in the same way default ACLs do, which is to ignore them altogether; they are handled just fine by DROP OWNED. The other foreign object cases are already handled correctly by both commands. Also add a REASSIGN OWNED statement to foreign_data test to exercise the foreign data objects. (The changes are just before the "cleanup" phase, so it shouldn't remove any existing live test.) Reported by Alexander Ashurkov, then independently by Jaime Casanova.
1 parent 2a37a10 commit f44c520

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/backend/catalog/pg_shdepend.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "catalog/pg_ts_config.h"
4141
#include "catalog/pg_ts_dict.h"
4242
#include "catalog/pg_type.h"
43+
#include "catalog/pg_user_mapping.h"
4344
#include "commands/dbcommands.h"
4445
#include "commands/collationcmds.h"
4546
#include "commands/conversioncmds.h"
@@ -1389,6 +1390,10 @@ shdepReassignOwned(List *roleids, Oid newrole)
13891390
*/
13901391
break;
13911392

1393+
case UserMappingRelationId:
1394+
/* ditto */
1395+
break;
1396+
13921397
case OperatorClassRelationId:
13931398
AlterOpClassOwner_oid(sdepForm->objid, newrole);
13941399
break;

src/test/regress/expected/foreign_data.out

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,21 +1070,23 @@ ERROR: foreign table "no_table" does not exist
10701070
DROP FOREIGN TABLE IF EXISTS no_table;
10711071
NOTICE: foreign table "no_table" does not exist, skipping
10721072
DROP FOREIGN TABLE foreign_schema.foreign_table_1;
1073+
-- REASSIGN OWNED/DROP OWNED of foreign objects
1074+
REASSIGN OWNED BY regress_test_role TO regress_test_role2;
1075+
DROP OWNED BY regress_test_role2;
1076+
ERROR: cannot drop desired object(s) because other objects depend on them
1077+
DETAIL: user mapping for regress_test_role on server s5 depends on server s5
1078+
HINT: Use DROP ... CASCADE to drop the dependent objects too.
1079+
DROP OWNED BY regress_test_role2 CASCADE;
1080+
NOTICE: drop cascades to user mapping for regress_test_role on server s5
10731081
-- Cleanup
10741082
DROP SCHEMA foreign_schema CASCADE;
10751083
DROP ROLE regress_test_role; -- ERROR
10761084
ERROR: role "regress_test_role" cannot be dropped because some objects depend on it
10771085
DETAIL: privileges for server s4
10781086
privileges for foreign-data wrapper foo
10791087
owner of user mapping for regress_test_role on server s6
1080-
owner of user mapping for regress_test_role on server s5
1081-
owner of server s5
1082-
owner of server t2
1083-
DROP SERVER s5 CASCADE;
1084-
NOTICE: drop cascades to user mapping for regress_test_role on server s5
10851088
DROP SERVER t1 CASCADE;
10861089
NOTICE: drop cascades to user mapping for public on server t1
1087-
DROP SERVER t2;
10881090
DROP USER MAPPING FOR regress_test_role SERVER s6;
10891091
-- This test causes some order dependent cascade detail output,
10901092
-- so switch to terse mode for it.

src/test/regress/sql/foreign_data.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,15 @@ DROP FOREIGN TABLE no_table; -- ERROR
436436
DROP FOREIGN TABLE IF EXISTS no_table;
437437
DROP FOREIGN TABLE foreign_schema.foreign_table_1;
438438

439+
-- REASSIGN OWNED/DROP OWNED of foreign objects
440+
REASSIGN OWNED BY regress_test_role TO regress_test_role2;
441+
DROP OWNED BY regress_test_role2;
442+
DROP OWNED BY regress_test_role2 CASCADE;
443+
439444
-- Cleanup
440445
DROP SCHEMA foreign_schema CASCADE;
441446
DROP ROLE regress_test_role; -- ERROR
442-
DROP SERVER s5 CASCADE;
443447
DROP SERVER t1 CASCADE;
444-
DROP SERVER t2;
445448
DROP USER MAPPING FOR regress_test_role SERVER s6;
446449
-- This test causes some order dependent cascade detail output,
447450
-- so switch to terse mode for it.

0 commit comments

Comments
 (0)
0