| 1 |
-- |
| 2 |
-- Install the plperl and plperlu extensions |
| 3 |
-- |
| 4 |
|
| 5 |
-- Before going ahead with the to-be-tested installations, verify that |
| 6 |
-- a non-superuser is allowed to install plperl (but not plperlu) when |
| 7 |
-- suitable permissions have been granted. |
| 8 |
|
| 9 |
CREATE USER regress_plperl_user1; |
| 10 |
CREATE USER regress_plperl_user2; |
| 11 |
|
| 12 |
SET ROLE regress_plperl_user1; |
| 13 |
|
| 14 |
CREATE EXTENSION plperl; -- fail |
| 15 |
CREATE EXTENSION plperlu; -- fail |
| 16 |
|
| 17 |
RESET ROLE; |
| 18 |
|
| 19 |
DO $$ |
| 20 |
begin |
| 21 |
execute format('grant create on database %I to regress_plperl_user1', |
| 22 |
current_database()); |
| 23 |
end; |
| 24 |
$$; |
| 25 |
|
| 26 |
SET ROLE regress_plperl_user1; |
| 27 |
|
| 28 |
CREATE EXTENSION plperl; |
| 29 |
CREATE EXTENSION plperlu; -- fail |
| 30 |
CREATE SCHEMA plperl_setup_scratch; |
| 31 |
SET search_path = plperl_setup_scratch; |
| 32 |
GRANT ALL ON SCHEMA plperl_setup_scratch TO regress_plperl_user2; |
| 33 |
|
| 34 |
CREATE FUNCTION foo1() returns int language plperl as '1;'; |
| 35 |
SELECT foo1(); |
| 36 |
|
| 37 |
-- Must reconnect to avoid failure with non-MULTIPLICITY Perl interpreters |
| 38 |
\c - |
| 39 |
SET search_path = plperl_setup_scratch; |
| 40 |
|
| 41 |
SET ROLE regress_plperl_user1; |
| 42 |
|
| 43 |
-- Should be able to change privileges on the language |
| 44 |
revoke all on language plperl from public; |
| 45 |
|
| 46 |
SET ROLE regress_plperl_user2; |
| 47 |
|
| 48 |
CREATE FUNCTION foo2() returns int language plperl as '2;'; -- fail |
| 49 |
|
| 50 |
SET ROLE regress_plperl_user1; |
| 51 |
|
| 52 |
grant usage on language plperl to regress_plperl_user2; |
| 53 |
|
| 54 |
SET ROLE regress_plperl_user2; |
| 55 |
|
| 56 |
CREATE FUNCTION foo2() returns int language plperl as '2;'; |
| 57 |
SELECT foo2(); |
| 58 |
|
| 59 |
SET ROLE regress_plperl_user1; |
| 60 |
|
| 61 |
-- Should be able to drop the extension, but not the language per se |
| 62 |
DROP LANGUAGE plperl CASCADE; |
| 63 |
DROP EXTENSION plperl CASCADE; |
| 64 |
|
| 65 |
-- Clean up |
| 66 |
RESET ROLE; |
| 67 |
DROP OWNED BY regress_plperl_user1; |
| 68 |
DROP USER regress_plperl_user1; |
| 69 |
DROP USER regress_plperl_user2; |
| 70 |
|
| 71 |
-- Now install the versions that will be used by subsequent test scripts. |
| 72 |
CREATE EXTENSION plperl; |
| 73 |
CREATE EXTENSION plperlu; |