Commit 035a5e1e authored by Tom Lane's avatar Tom Lane

Add semicolons to eval'd strings to hide a minor Perl behavioral change.

"eval q{foo}" used to complain that the error was on line 2 of the eval'd
string, because eval internally tacked on "\n;" so that the end of the
erroneous command was indeed on line 2.  But as of Perl 5.18 it more
sanely says that the error is on line 1.  To avoid Perl-version-dependent
regression test results, use "eval q{foo;}" instead in the two places
where this matters.  Per buildfarm.

Since people might try to use newer Perl versions with older PG releases,
back-patch as far as 9.0 where these test cases were added.
parent 15386281
...@@ -626,8 +626,8 @@ DO $$ open my $fh, "</nonesuch"; $$ LANGUAGE plperl; ...@@ -626,8 +626,8 @@ DO $$ open my $fh, "</nonesuch"; $$ LANGUAGE plperl;
ERROR: 'open' trapped by operation mask at line 1. ERROR: 'open' trapped by operation mask at line 1.
CONTEXT: PL/Perl anonymous code block CONTEXT: PL/Perl anonymous code block
-- check that eval is allowed and eval'd restricted ops are caught -- check that eval is allowed and eval'd restricted ops are caught
DO $$ eval q{chdir '.'}; warn "Caught: $@"; $$ LANGUAGE plperl; DO $$ eval q{chdir '.';}; warn "Caught: $@"; $$ LANGUAGE plperl;
WARNING: Caught: 'chdir' trapped by operation mask at line 2. WARNING: Caught: 'chdir' trapped by operation mask at line 1.
CONTEXT: PL/Perl anonymous code block CONTEXT: PL/Perl anonymous code block
-- check that compiling do (dofile opcode) is allowed -- check that compiling do (dofile opcode) is allowed
-- but that executing it for a file not already loaded (via require) dies -- but that executing it for a file not already loaded (via require) dies
......
-- test plperl.on_plperl_init errors are fatal -- test plperl.on_plperl_init errors are fatal
-- This test tests setting on_plperl_init after loading plperl -- This test tests setting on_plperl_init after loading plperl
LOAD 'plperl'; LOAD 'plperl';
SET SESSION plperl.on_plperl_init = ' system("/nonesuch") '; SET SESSION plperl.on_plperl_init = ' system("/nonesuch"); ';
SHOW plperl.on_plperl_init; SHOW plperl.on_plperl_init;
plperl.on_plperl_init plperl.on_plperl_init
----------------------- ------------------------
system("/nonesuch") system("/nonesuch");
(1 row) (1 row)
DO $$ warn 42 $$ language plperl; DO $$ warn 42 $$ language plperl;
ERROR: 'system' trapped by operation mask at line 2. ERROR: 'system' trapped by operation mask at line 1.
CONTEXT: while executing plperl.on_plperl_init CONTEXT: while executing plperl.on_plperl_init
PL/Perl anonymous code block PL/Perl anonymous code block
...@@ -405,7 +405,7 @@ DO $$ qx("/nonesuch"); $$ LANGUAGE plperl; ...@@ -405,7 +405,7 @@ DO $$ qx("/nonesuch"); $$ LANGUAGE plperl;
DO $$ open my $fh, "</nonesuch"; $$ LANGUAGE plperl; DO $$ open my $fh, "</nonesuch"; $$ LANGUAGE plperl;
-- check that eval is allowed and eval'd restricted ops are caught -- check that eval is allowed and eval'd restricted ops are caught
DO $$ eval q{chdir '.'}; warn "Caught: $@"; $$ LANGUAGE plperl; DO $$ eval q{chdir '.';}; warn "Caught: $@"; $$ LANGUAGE plperl;
-- check that compiling do (dofile opcode) is allowed -- check that compiling do (dofile opcode) is allowed
-- but that executing it for a file not already loaded (via require) dies -- but that executing it for a file not already loaded (via require) dies
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-- This test tests setting on_plperl_init after loading plperl -- This test tests setting on_plperl_init after loading plperl
LOAD 'plperl'; LOAD 'plperl';
SET SESSION plperl.on_plperl_init = ' system("/nonesuch") '; SET SESSION plperl.on_plperl_init = ' system("/nonesuch"); ';
SHOW plperl.on_plperl_init; SHOW plperl.on_plperl_init;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment