2 -- Install the plperl and plperlu extensions
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.
19 execute format('grant create on database %I to regress_plperl_user1',
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;';
38 -- Must reconnect to avoid failure with non-MULTIPLICITY Perl interpreters
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;';
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()
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;