plperl strict mode and associated fixes
The attached patch completes (I hope) the work begun by Michael Fuhr in
an earlier unapplied patch, and makes strict mode work as recently
discussed. I moved the embedded strings out of the calling functions
into global macros to try to make the code a little more readable.
Unfortunately we can't have regression tests for this because it relies
on a custom variable class.
Illustration of use:
andrew=# set plperl.use_strict = 'true';
SET
andrew=# create function foo() returns text language plperlu as $$
$foo=1; return 'foo';$$;
ERROR: creation of Perl function failed: Global symbol "$foo" requires
explicit package name at (eval 1) line 1.
andrew=# set plperl.use_strict = 'false';
SET
andrew=# create function foo() returns text language plperlu as $$
$foo=1; return 'foo';$$;
CREATE FUNCTION
cheers
andrew
Attachments:
plperl-strict.patchtext/x-patch; name=plperl-strict.patchDownload+109-98
On Tue, Aug 23, 2005 at 09:12:10PM -0400, Andrew Dunstan wrote:
The attached patch completes (I hope) the work begun by Michael Fuhr in
an earlier unapplied patch, and makes strict mode work as recently
discussed. I moved the embedded strings out of the calling functions
into global macros to try to make the code a little more readable.Unfortunately we can't have regression tests for this because it relies
on a custom variable class.
Hmmm...even if the "plperl" custom variable class isn't defined in
postgresql.conf, plperl.use_strict springs into existence when the
interpreter is initialized:
test=> SET plperl.use_strict TO on;
ERROR: unrecognized configuration parameter "plperl.use_strict"
test=> CREATE FUNCTION foo() RETURNS void AS $$$$ LANGUAGE plperl;
CREATE FUNCTION
test=> SET plperl.use_strict TO on;
SET
test=> CREATE OR REPLACE FUNCTION foo() RETURNS void AS $$ $x = 1234; $$ LANGUAGE plperl;
ERROR: creation of Perl function failed: Global symbol "$x" requires explicit package name at (eval 8) line 1.
test=> SET plperl.use_strict TO off;
SET
test=> CREATE OR REPLACE FUNCTION foo() RETURNS void AS $$ $x = 1234; $$ LANGUAGE plperl;
CREATE FUNCTION
Is such automatic creation of a GUC variable intended? If so,
couldn't you exploit that in regression tests?
--
Michael Fuhr
Michael Fuhr <mike@fuhr.org> writes:
Hmmm...even if the "plperl" custom variable class isn't defined in
postgresql.conf, plperl.use_strict springs into existence when the
interpreter is initialized:
Yes, this is per spec. The "custom class" concept is only intended
to allow you to put things into postgresql.conf before the associated
shared library is loaded; it is not intended to stop the shared library
from defining GUC variables that you didn't see fit to put values into
postgresql.conf for.
regards, tom lane