From 1a7c2f9dea3682987a741f559ecf5e38b4ba5432 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 26 Jan 2010 23:11:56 +0000 Subject: Various small improvements and cleanups for PL/Perl. - Allow (ineffective) use of 'require' in plperl If the required module is not already loaded then it dies. So "use strict;" now works in plperl. - Pre-load the feature module if perl >= 5.10. So "use feature :5.10;" now works in plperl. - Stored procedure subs are now given names. The names are not visible in ordinary use, but they make tools like Devel::NYTProf and Devel::Cover much more useful. - Simplified and generalized the subroutine creation code. Now one code path for generating sub source code, not four. Can generate multiple 'use' statements with specific imports (which handles plperl.use_strict currently and can easily be extended to handle a plperl.use_feature=':5.12' in future). - Disallows use of Safe version 2.20 which is broken for PL/Perl. http://rt.perl.org/rt3/Ticket/Display.html?id=72068 - Assorted minor optimizations by pre-growing data structures. Patch from Tim Bunce, reviewed by Alex Hunsaker. --- doc/src/sgml/plperl.sgml | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml index 8c56d56c865..90f63acdded 100644 --- a/doc/src/sgml/plperl.sgml +++ b/doc/src/sgml/plperl.sgml @@ -1,4 +1,4 @@ - + PL/Perl - Perl Procedural Language @@ -285,29 +285,39 @@ SELECT * FROM perl_set(); - If you wish to use the strict pragma with your code, - the easiest way to do so is to SET - plperl.use_strict to true. This parameter affects - subsequent compilations of PL/Perl functions, but not - functions already compiled in the current session. To set the - parameter before PL/Perl has been loaded, it is - necessary to have added plperl to the list in - postgresql.conf. + If you wish to use the strict pragma with your code you have a few options. + For temporary global use you can SET plperl.use_strict + to true (see ). + This will affect subsequent compilations of PL/Perl + functions, but not functions already compiled in the current session. + For permanent global use you can set plperl.use_strict + to true in the postgresql.conf file. - Another way to use the strict pragma is to put: + For permanent use in specific functions you can simply put: use strict; - in the function body. But this only works in PL/PerlU - functions, since the use triggers a require - which is not a trusted operation. In - PL/Perl functions you can instead do: - -BEGIN { strict->import(); } - + at the top of the function body. + + + + The feature pragma is also available to use if your Perl is version 5.10.0 or higher. + + + + + + Data Values in PL/Perl + + + The argument values supplied to a PL/Perl function's code are + simply the input arguments converted to text form (just as if they + had been displayed by a SELECT statement). + Conversely, the return and return_next + commands will accept any string that is acceptable input format + for the function's declared return type. @@ -682,18 +692,6 @@ SELECT done(); - - Data Values in PL/Perl - - - The argument values supplied to a PL/Perl function's code are - simply the input arguments converted to text form (just as if they - had been displayed by a SELECT statement). - Conversely, the return command will accept any string - that is acceptable input format for the function's declared return - type. So, within the PL/Perl function, - all values are just text strings. - @@ -1042,8 +1040,7 @@ CREATE TRIGGER test_valid_id_trig - PL/Perl functions cannot call each other directly (because they - are anonymous subroutines inside Perl). + PL/Perl functions cannot call each other directly. @@ -1072,6 +1069,8 @@ CREATE TRIGGER test_valid_id_trig + + -- cgit v1.2.3