aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-12-11 18:39:09 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-12-11 18:39:09 -0300
commit8c1615531f4945e5af78ddf1d43af11b6d7b48fd (patch)
tree8ff6a8cb99f9d1f785728ec3471a591f57d5432c
parentdccf8e9e608824ce15d3b2d7ee63afbf1147c5e9 (diff)
downloadpostgresql-8c1615531f4945e5af78ddf1d43af11b6d7b48fd.tar.gz
postgresql-8c1615531f4945e5af78ddf1d43af11b6d7b48fd.zip
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.
-rw-r--r--src/backend/catalog/pg_shdepend.c5
-rw-r--r--src/test/regress/expected/foreign_data.out14
-rw-r--r--src/test/regress/sql/foreign_data.sql7
3 files changed, 18 insertions, 8 deletions
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index eeb231be7e6..cfd43a8ddfc 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -43,6 +43,7 @@
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_type.h"
+#include "catalog/pg_user_mapping.h"
#include "commands/alter.h"
#include "commands/dbcommands.h"
#include "commands/collationcmds.h"
@@ -1389,6 +1390,10 @@ shdepReassignOwned(List *roleids, Oid newrole)
*/
break;
+ case UserMappingRelationId:
+ /* ditto */
+ break;
+
case ForeignServerRelationId:
AlterForeignServerOwner_oid(sdepForm->objid, newrole);
break;
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index 73c02bb10f0..660840cd903 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -1743,6 +1743,14 @@ ERROR: foreign table "no_table" does not exist
DROP FOREIGN TABLE IF EXISTS no_table;
NOTICE: foreign table "no_table" does not exist, skipping
DROP FOREIGN TABLE foreign_schema.foreign_table_1;
+-- REASSIGN OWNED/DROP OWNED of foreign objects
+REASSIGN OWNED BY regress_test_role TO regress_test_role2;
+DROP OWNED BY regress_test_role2;
+ERROR: cannot drop desired object(s) because other objects depend on them
+DETAIL: user mapping for regress_test_role on server s5 depends on server s5
+HINT: Use DROP ... CASCADE to drop the dependent objects too.
+DROP OWNED BY regress_test_role2 CASCADE;
+NOTICE: drop cascades to user mapping for regress_test_role on server s5
-- Cleanup
DROP SCHEMA foreign_schema CASCADE;
DROP ROLE regress_test_role; -- ERROR
@@ -1750,14 +1758,8 @@ ERROR: role "regress_test_role" cannot be dropped because some objects depend o
DETAIL: privileges for server s4
privileges for foreign-data wrapper foo
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 on server s5
DROP SERVER t1 CASCADE;
NOTICE: drop cascades to user mapping for public on server t1
-DROP SERVER t2;
DROP USER MAPPING FOR regress_test_role SERVER s6;
-- This test causes some order dependent cascade detail output,
-- so switch to terse mode for it.
diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql
index af3d531289a..384e155fcb0 100644
--- a/src/test/regress/sql/foreign_data.sql
+++ b/src/test/regress/sql/foreign_data.sql
@@ -679,12 +679,15 @@ DROP FOREIGN TABLE no_table; -- ERROR
DROP FOREIGN TABLE IF EXISTS no_table;
DROP FOREIGN TABLE foreign_schema.foreign_table_1;
+-- REASSIGN OWNED/DROP OWNED of foreign objects
+REASSIGN OWNED BY regress_test_role TO regress_test_role2;
+DROP OWNED BY regress_test_role2;
+DROP OWNED BY regress_test_role2 CASCADE;
+
-- Cleanup
DROP SCHEMA foreign_schema CASCADE;
DROP ROLE regress_test_role; -- ERROR
-DROP SERVER s5 CASCADE;
DROP SERVER t1 CASCADE;
-DROP SERVER t2;
DROP USER MAPPING FOR regress_test_role SERVER s6;
-- This test causes some order dependent cascade detail output,
-- so switch to terse mode for it.