Go back to public user mappings
This commit is contained in:
parent
38d8a470bc
commit
64e185b841
@ -250,7 +250,7 @@ BEGIN
|
||||
EXECUTE FORMAT('GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO %I', role_name);
|
||||
EXECUTE FORMAT('GRANT USAGE ON FOREIGN SERVER %I TO %I', server_internal, role_name);
|
||||
EXECUTE FORMAT('ALTER SERVER %I OWNER TO %I', server_internal, role_name);
|
||||
EXECUTE FORMAT ('CREATE USER MAPPING FOR %I SERVER %I', role_name, server_internal);
|
||||
EXECUTE FORMAT ('CREATE USER MAPPING FOR PUBLIC SERVER %I', server_internal);
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RAISE EXCEPTION 'Could not create server %: %', server, SQLERRM
|
||||
USING HINT = 'Please clean the left over objects';
|
||||
@ -276,12 +276,12 @@ BEGIN
|
||||
LOOP
|
||||
IF NOT EXISTS (
|
||||
WITH a AS (
|
||||
SELECT split_part(unnest(umoptions), '=', 1) as options from pg_user_mappings WHERE srvname = server_internal AND usename = role_name
|
||||
SELECT split_part(unnest(umoptions), '=', 1) as options from pg_user_mappings WHERE srvname = server_internal AND usename = 'public'
|
||||
) SELECT * from a where options = option.key)
|
||||
THEN
|
||||
EXECUTE FORMAT('ALTER USER MAPPING FOR %I SERVER %I OPTIONS (ADD %I %L)', role_name, server_internal, option.key, option.value);
|
||||
EXECUTE FORMAT('ALTER USER MAPPING FOR PUBLIC SERVER %I OPTIONS (ADD %I %L)', server_internal, option.key, option.value);
|
||||
ELSE
|
||||
EXECUTE FORMAT('ALTER USER MAPPING FOR %I SERVER %I OPTIONS (SET %I %L)', role_name, server_internal, option.key, option.value);
|
||||
EXECUTE FORMAT('ALTER USER MAPPING FOR PUBLIC SERVER %I OPTIONS (SET %I %L)', server_internal, option.key, option.value);
|
||||
END IF;
|
||||
END LOOP;
|
||||
END
|
||||
@ -300,7 +300,7 @@ DECLARE
|
||||
BEGIN
|
||||
SET client_min_messages = ERROR;
|
||||
BEGIN
|
||||
EXECUTE FORMAT ('DROP USER MAPPING FOR %I SERVER %I', role_name, server_internal);
|
||||
EXECUTE FORMAT ('DROP USER MAPPING FOR PUBLIC SERVER %I', server_internal);
|
||||
EXECUTE FORMAT ('DROP OWNED BY %I', role_name);
|
||||
EXECUTE FORMAT ('DROP ROLE %I', role_name);
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
|
@ -306,9 +306,13 @@ BEGIN
|
||||
END IF;
|
||||
END;
|
||||
|
||||
EXECUTE format('ALTER VIEW %1$I OWNER TO %I',
|
||||
local_name,
|
||||
cartodb.__CDB_FS_Generate_Server_Role_Name(server_internal));
|
||||
BEGIN
|
||||
EXECUTE format('ALTER VIEW %1$I OWNER TO %I',
|
||||
local_name,
|
||||
cartodb.__CDB_FS_Generate_Server_Role_Name(server_internal));
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RAISE WARNING 'View "%" could not be shared with other users: %', local_name, SQLERRM;
|
||||
END;
|
||||
END
|
||||
$$
|
||||
LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE;
|
||||
|
Loading…
Reference in New Issue
Block a user