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