summaryrefslogtreecommitdiffstats
path: root/src/pl/plperl/expected/plperl_setup.out
blob: 5537a95ccc21f6201a6bffbcd178fd4f3170d81b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--
-- Install the plperl and plperlu extensions
--
-- Before going ahead with the to-be-tested installations, verify that
-- a non-superuser is allowed to install plperl (but not plperlu) when
-- suitable permissions have been granted.
CREATE USER regress_plperl_user1;
CREATE USER regress_plperl_user2;
SET ROLE regress_plperl_user1;
CREATE EXTENSION plperl;  -- fail
ERROR:  permission denied to create extension "plperl"
HINT:  Must have CREATE privilege on current database to create this extension.
CREATE EXTENSION plperlu;  -- fail
ERROR:  permission denied to create extension "plperlu"
HINT:  Must be superuser to create this extension.
RESET ROLE;
DO $$
begin
  execute format('grant create on database %I to regress_plperl_user1',
                 current_database());
end;
$$;
SET ROLE regress_plperl_user1;
CREATE EXTENSION plperl;
CREATE EXTENSION plperlu;  -- fail
ERROR:  permission denied to create extension "plperlu"
HINT:  Must be superuser to create this extension.
CREATE SCHEMA plperl_setup_scratch;
SET search_path = plperl_setup_scratch;
GRANT ALL ON SCHEMA plperl_setup_scratch TO regress_plperl_user2;
CREATE FUNCTION foo1() returns int language plperl as '1;';
SELECT foo1();
 foo1 
------
    1
(1 row)

-- Must reconnect to avoid failure with non-MULTIPLICITY Perl interpreters
\c -
SET search_path = plperl_setup_scratch;
SET ROLE regress_plperl_user1;
-- Should be able to change privileges on the language
revoke all on language plperl from public;
SET ROLE regress_plperl_user2;
CREATE FUNCTION foo2() returns int language plperl as '2;';  -- fail
ERROR:  permission denied for language plperl
SET ROLE regress_plperl_user1;
grant usage on language plperl to regress_plperl_user2;
SET ROLE regress_plperl_user2;
CREATE FUNCTION foo2() returns int language plperl as '2;';
SELECT foo2();
 foo2 
------
    2
(1 row)

SET ROLE regress_plperl_user1;
-- Should be able to drop the extension, but not the language per se
DROP LANGUAGE plperl CASCADE;
ERROR:  cannot drop language plperl because extension plperl requires it
HINT:  You can drop extension plperl instead.
DROP EXTENSION plperl CASCADE;
NOTICE:  drop cascades to 2 other objects
DETAIL:  drop cascades to function foo1()
drop cascades to function foo2()
-- Clean up
RESET ROLE;
DROP OWNED BY regress_plperl_user1;
DROP USER regress_plperl_user1;
DROP USER regress_plperl_user2;
-- Now install the versions that will be used by subsequent test scripts.
CREATE EXTENSION plperl;
CREATE EXTENSION plperlu;