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

Commit4626245

Browse files
committed
For REASSIGN OWNED for foreign user mappings
As reported in bug #13809 by Alexander Ashurkov, the code for REASSIGNOWNED hadn't gotten word about user mappings. Deal with them in thesame way default ACLs do, which is to ignore them altogether; they arehandled just fine by DROP OWNED. The other foreign object cases arealready handled correctly by both commands.Also add a REASSIGN OWNED statement to foreign_data test to exercise theforeign 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 parent1ebe75a commit4626245

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
@@ -43,6 +43,7 @@
4343
#include"catalog/pg_ts_config.h"
4444
#include"catalog/pg_ts_dict.h"
4545
#include"catalog/pg_type.h"
46+
#include"catalog/pg_user_mapping.h"
4647
#include"commands/alter.h"
4748
#include"commands/dbcommands.h"
4849
#include"commands/collationcmds.h"
@@ -1374,6 +1375,10 @@ shdepReassignOwned(List *roleids, Oid newrole)
13741375
*/
13751376
break;
13761377

1378+
caseUserMappingRelationId:
1379+
/* ditto */
1380+
break;
1381+
13771382
caseForeignServerRelationId:
13781383
AlterForeignServerOwner_oid(sdepForm->objid,newrole);
13791384
break;

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,21 +1164,23 @@ ERROR: foreign table "no_table" does not exist
11641164
DROP FOREIGN TABLE IF EXISTS no_table;
11651165
NOTICE: foreign table "no_table" does not exist, skipping
11661166
DROP FOREIGN TABLE foreign_schema.foreign_table_1;
1167+
-- REASSIGN OWNED/DROP OWNED of foreign objects
1168+
REASSIGN OWNED BY regress_test_role TO regress_test_role2;
1169+
DROP OWNED BY regress_test_role2;
1170+
ERROR: cannot drop desired object(s) because other objects depend on them
1171+
DETAIL: user mapping for regress_test_role on server s5 depends on server s5
1172+
HINT: Use DROP ... CASCADE to drop the dependent objects too.
1173+
DROP OWNED BY regress_test_role2 CASCADE;
1174+
NOTICE: drop cascades to user mapping for regress_test_role on server s5
11671175
-- Cleanup
11681176
DROP SCHEMA foreign_schema CASCADE;
11691177
DROP ROLE regress_test_role; -- ERROR
11701178
ERROR: role "regress_test_role" cannot be dropped because some objects depend on it
11711179
DETAIL: privileges for server s4
11721180
privileges for foreign-data wrapper foo
11731181
owner of user mapping for regress_test_role on server s6
1174-
owner of user mapping for regress_test_role on server s5
1175-
owner of server s5
1176-
owner of server t2
1177-
DROP SERVER s5 CASCADE;
1178-
NOTICE: drop cascades to user mapping for regress_test_role on server s5
11791182
DROP SERVER t1 CASCADE;
11801183
NOTICE: drop cascades to user mapping for public on server t1
1181-
DROP SERVER t2;
11821184
DROP USER MAPPING FOR regress_test_role SERVER s6;
11831185
-- This test causes some order dependent cascade detail output,
11841186
-- 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
@@ -475,12 +475,15 @@ DROP FOREIGN TABLE no_table; -- ERROR
475475
DROP FOREIGN TABLE IF EXISTS no_table;
476476
DROP FOREIGN TABLEforeign_schema.foreign_table_1;
477477

478+
-- REASSIGN OWNED/DROP OWNED of foreign objects
479+
REASSIGN OWNED BY regress_test_role TO regress_test_role2;
480+
DROP OWNED BY regress_test_role2;
481+
DROP OWNED BY regress_test_role2 CASCADE;
482+
478483
-- Cleanup
479484
DROPSCHEMA foreign_schema CASCADE;
480485
DROP ROLE regress_test_role;-- ERROR
481-
DROP SERVER s5 CASCADE;
482486
DROP SERVER t1 CASCADE;
483-
DROP SERVER t2;
484487
DROPUSER MAPPING FOR regress_test_role SERVER s6;
485488
-- This test causes some order dependent cascade detail output,
486489
-- so switch to terse mode for it.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp