| 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()"); |
| 10 |
return 1; |
| 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 |
| 20 |
-- plperl first |
| 21 |
create or replace function foo(text) returns text language plperl as 'shift'; |
| 22 |
select foo('hey'); |
| 23 |
foo |
| 24 |
----- |
| 25 |
hey |
| 26 |
(1 row) |
| 27 |
|
| 28 |
create or replace function foo(text) returns text language plperlu as 'shift'; |
| 29 |
select foo('hey'); |
| 30 |
foo |
| 31 |
----- |
| 32 |
hey |
| 33 |
(1 row) |
| 34 |
|
| 35 |
create or replace function foo(text) returns text language plperl as 'shift'; |
| 36 |
select foo('hey'); |
| 37 |
foo |
| 38 |
----- |
| 39 |
hey |
| 40 |
(1 row) |
| 41 |
|
| 42 |
-- plperlu first |
| 43 |
create or replace function bar(text) returns text language plperlu as 'shift'; |
| 44 |
select bar('hey'); |
| 45 |
bar |
| 46 |
----- |
| 47 |
hey |
| 48 |
(1 row) |
| 49 |
|
| 50 |
create or replace function bar(text) returns text language plperl as 'shift'; |
| 51 |
select bar('hey'); |
| 52 |
bar |
| 53 |
----- |
| 54 |
hey |
| 55 |
(1 row) |
| 56 |
|
| 57 |
create or replace function bar(text) returns text language plperlu as 'shift'; |
| 58 |
select bar('hey'); |
| 59 |
bar |
| 60 |
----- |
| 61 |
hey |
| 62 |
(1 row) |
| 63 |
|
| 64 |
-- |
| 65 |
-- Make sure we can't use/require things in plperl |
| 66 |
-- |
| 67 |
CREATE OR REPLACE FUNCTION use_plperlu() RETURNS void LANGUAGE plperlu |
| 68 |
AS $$ |
| 69 |
use Errno; |
| 70 |
$$; |
| 71 |
CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl |
| 72 |
AS $$ |
| 73 |
use Errno; |
| 74 |
$$; |
| 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 |
| 79 |
select use_plperlu(); |
| 80 |
use_plperlu |
| 81 |
------------- |
| 82 |
|
| 83 |
(1 row) |
| 84 |
|
| 85 |
CREATE OR REPLACE FUNCTION use_plperl() RETURNS void LANGUAGE plperl |
| 86 |
AS $$ |
| 87 |
use Errno; |
| 88 |
$$; |
| 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" |