Debian Codegraph @

src/pl/plperl/sql/plperl_plperlu.sql

raw
1 -- test plperl/plperlu interaction
2
3 -- the language and call ordering of this test sequence is useful
4
5 CREATE OR REPLACE FUNCTION bar() RETURNS integer AS $$
6 #die 'BANG!'; # causes server process to exit(2)
7 # alternative - causes server process to exit(255)
8 spi_exec_query("invalid sql statement");
9 $$ language plperl; -- compile plperl code
10
11 CREATE OR REPLACE FUNCTION foo() RETURNS integer AS $$
12 spi_exec_query("SELECT * FROM bar()");
13 return 1;
14 $$ LANGUAGE plperlu; -- compile plperlu code
15
16 SELECT * FROM bar(); -- throws exception normally (running plperl)
17 SELECT * FROM foo(); -- used to cause backend crash (after switching to plperlu)
18
19 -- test redefinition of specific SP switching languages
20 -- http://archives.postgresql.org/pgsql-bugs/2010-01/msg00116.php
21
22 -- plperl first
23 create or replace function foo(text) returns text language plperl as 'shift';
24 select foo('hey');
25 create or replace function foo(text) returns text language plperlu as 'shift';
26 select foo('hey');
27 create or replace function foo(text) returns text language plperl as 'shift';
28 select foo('hey');
29
30 -- plperlu first
31 create or replace function bar(text) returns text language plperlu as 'shift';
32 select bar('hey');
33 create or replace function bar(text) returns text language plperl as 'shift';
34 select bar('hey');
35 create or replace function bar(text) returns text language plperlu as 'shift';
36 select bar('hey');
37
38 --
39 -- Make sure we can't use/require things in plperl
40 --
41
42 CREATE OR REPLACE FUNCTION use_plperlu() RETURNS void LANGUAGE plperlu
43 AS $$
44 use Errno;
45 $$;
46
47 CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
48 AS $$
49 use Errno;
50 $$;
51
52 -- make sure our overloaded require op gets restored/set correctly
53 select use_plperlu();
54
55 CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl
56 AS $$
57 use Errno;
58 $$;