1 -- test plperl/plperlu interaction
2 -- the language and call ordering of this test sequence is useful
3 CREATE OR REPLACE FUNCTION bar() RETURNS integer AS $$
4 #die 'BANG!'; # causes server process to exit(2)
5 # alternative - causes server process to exit(255)
6 spi_exec_query("invalid sql statement");
7 $$ language plperl; -- compile plperl code
8 CREATE OR REPLACE FUNCTION foo() RETURNS integer AS $$
9 spi_exec_query("SELECT * FROM bar()");
11 $$ LANGUAGE plperlu; -- compile plperlu code
12 SELECT * FROM bar(); -- throws exception normally (running plperl)
13 ERROR: syntax error at or near "invalid" at line 4.
14 CONTEXT: PL/Perl function "bar"
15 SELECT * FROM foo(); -- used to cause backend crash (after switching to plperlu)
16 ERROR: syntax error at or near "invalid" at line 4. at line 2.
17 CONTEXT: PL/Perl function "foo"
18 -- test redefinition of specific SP switching languages
19 -- http://archives.postgresql.org/pgsql-bugs/2010-01/msg00116.php
21 create or replace function foo(text) returns text language plperl as 'shift';
28 create or replace function foo(text) returns text language plperlu as 'shift';
35 create or replace function foo(text) returns text language plperl as 'shift';
43 create or replace function bar(text) returns text language plperlu as 'shift';
50 create or replace function bar(text) returns text language plperl as 'shift';
57 create or replace function bar(text) returns text language plperlu as 'shift';
65 -- Make sure we can't use/require things in plperl
67 CREATE OR REPLACE FUNCTION use_plperlu() RETURNS void LANGUAGE plperlu
71 CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
75 ERROR: Unable to load Errno.pm into plperl at line 2.
76 BEGIN failed--compilation aborted at line 2.
77 CONTEXT: compilation of PL/Perl function "use_plperl"
78 -- make sure our overloaded require op gets restored/set correctly
85 CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
89 ERROR: Unable to load Errno.pm into plperl at line 2.
90 BEGIN failed--compilation aborted at line 2.
91 CONTEXT: compilation of PL/Perl function "use_plperl"