1 -- test warnings and errors from plperl
3 create or replace function perl_elog(text) returns void language plperl as $$
10 select perl_elog('explicit elog');
12 create or replace function perl_warn(text) returns void language plperl as $$
19 select perl_warn('implicit elog via warn');
21 -- test strict mode on/off
23 SET plperl.use_strict = true;
25 create or replace function uses_global() returns text language plperl as $$
29 return 'uses_global worked';
35 SET plperl.use_strict = false;
37 create or replace function uses_global() returns text language plperl as $$
41 return 'uses_global worked';
47 -- make sure we don't choke on readonly values
48 do language plperl $$ elog(NOTICE, ${^TAINT}); $$;
50 -- test recovery after "die"
52 create or replace function just_die() returns void language plperl AS $$
58 create or replace function die_caller() returns int language plpgsql as $$
62 EXCEPTION WHEN OTHERS THEN
63 RAISE NOTICE 'caught die';
71 create or replace function indirect_die_caller() returns int language plperl as $$
72 my $prepared = spi_prepare('SELECT die_caller() AS fx');
73 my $a = spi_exec_prepared($prepared)->{rows}->[0]->{fx};
74 my $b = spi_exec_prepared($prepared)->{rows}->[0]->{fx};
78 select indirect_die_caller();
80 -- Test non-ASCII error messages
82 -- Note: this test case is known to fail if the database encoding is
83 -- EUC_CN, EUC_JP, EUC_KR, or EUC_TW, for lack of any equivalent to
84 -- U+00A0 (no-break space) in those encodings. However, testing with
85 -- plain ASCII data would be rather useless, so we must live with that.
87 SET client_encoding TO UTF8;
89 create or replace function error_with_nbsp() returns void language plperl as $$
90 elog(ERROR, "this message contains a no-break space");
93 select error_with_nbsp();