summaryrefslogtreecommitdiffstats
path: root/src/pl/plperl/expected/plperl_plperlu.out
blob: 2be955ff13449c447a74e0dceb7f527d4827da3b (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
-- test plperl/plperlu interaction
-- the language and call ordering of this test sequence is useful
CREATE OR REPLACE FUNCTION bar() RETURNS integer AS $$
    #die 'BANG!'; # causes server process to exit(2)
    # alternative - causes server process to exit(255)
    spi_exec_query("invalid sql statement");
$$ language plperl; -- compile plperl code
CREATE OR REPLACE FUNCTION foo() RETURNS integer AS $$
    spi_exec_query("SELECT * FROM bar()");
    return 1;
$$ LANGUAGE plperlu; -- compile plperlu code
SELECT * FROM bar(); -- throws exception normally (running plperl)
ERROR:  syntax error at or near "invalid" at line 4.
CONTEXT:  PL/Perl function "bar"
SELECT * FROM foo(); -- used to cause backend crash (after switching to plperlu)
ERROR:  syntax error at or near "invalid" at line 4. at line 2.
CONTEXT:  PL/Perl function "foo"
-- test redefinition of specific SP switching languages
-- http://archives.postgresql.org/pgsql-bugs/2010-01/msg00116.php
-- plperl first
create or replace function foo(text) returns text language plperl  as 'shift';
select foo('hey');
 foo 
-----
 hey
(1 row)

create or replace function foo(text) returns text language plperlu as 'shift';
select foo('hey');
 foo 
-----
 hey
(1 row)

create or replace function foo(text) returns text language plperl  as 'shift';
select foo('hey');
 foo 
-----
 hey
(1 row)

-- plperlu first
create or replace function bar(text) returns text language plperlu as 'shift';
select bar('hey');
 bar 
-----
 hey
(1 row)

create or replace function bar(text) returns text language plperl  as 'shift';
select bar('hey');
 bar 
-----
 hey
(1 row)

create or replace function bar(text) returns text language plperlu as 'shift';
select bar('hey');
 bar 
-----
 hey
(1 row)

--
-- Make sure we can't use/require things in plperl
--
CREATE OR REPLACE FUNCTION use_plperlu() RETURNS void LANGUAGE plperlu
AS $$
use Errno;
$$;
CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
AS $$
use Errno;
$$;
ERROR:  Unable to load Errno.pm into plperl at line 2.
BEGIN failed--compilation aborted at line 2.
CONTEXT:  compilation of PL/Perl function "use_plperl"
-- make sure our overloaded require op gets restored/set correctly
select use_plperlu();
 use_plperlu 
-------------
 
(1 row)

CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
AS $$
use Errno;
$$;
ERROR:  Unable to load Errno.pm into plperl at line 2.
BEGIN failed--compilation aborted at line 2.
CONTEXT:  compilation of PL/Perl function "use_plperl"