diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2010-01-26 23:11:56 +0000 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2010-01-26 23:11:56 +0000 |
commit | 1a7c2f9dea3682987a741f559ecf5e38b4ba5432 (patch) | |
tree | e75895535794f2a1fcd56bf177a82e850d1f85a9 /doc/src | |
parent | d879697cd291a31c635edf17c4b8c170ac40ffc1 (diff) |
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.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plperl.sgml | 63 |
1 files changed, 31 insertions, 32 deletions
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 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.74 2010/01/20 03:37:10 rhaas Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.75 2010/01/26 23:11:56 adunstan Exp $ --> <chapter id="plperl"> <title>PL/Perl - Perl Procedural Language</title> @@ -285,29 +285,39 @@ SELECT * FROM perl_set(); </para> <para> - If you wish to use the <literal>strict</> pragma with your code, - the easiest way to do so is to <command>SET</> - <literal>plperl.use_strict</literal> to true. This parameter affects - subsequent compilations of <application>PL/Perl</> functions, but not - functions already compiled in the current session. To set the - parameter before <application>PL/Perl</> has been loaded, it is - necessary to have added <quote><literal>plperl</></> to the <xref - linkend="guc-custom-variable-classes"> list in - <filename>postgresql.conf</filename>. + If you wish to use the <literal>strict</> pragma with your code you have a few options. + For temporary global use you can <command>SET</> <literal>plperl.use_strict</literal> + to true (see <xref linkend="plperl.use_strict">). + This will affect subsequent compilations of <application>PL/Perl</> + functions, but not functions already compiled in the current session. + For permanent global use you can set <literal>plperl.use_strict</literal> + to true in the <filename>postgresql.conf</filename> file. </para> <para> - Another way to use the <literal>strict</> pragma is to put: + For permanent use in specific functions you can simply put: <programlisting> use strict; </programlisting> - in the function body. But this only works in <application>PL/PerlU</> - functions, since the <literal>use</> triggers a <literal>require</> - which is not a trusted operation. In - <application>PL/Perl</> functions you can instead do: -<programlisting> -BEGIN { strict->import(); } -</programlisting> + at the top of the function body. + </para> + + <para> + The <literal>feature</> pragma is also available to <function>use</> if your Perl is version 5.10.0 or higher. + </para> + + </sect1> + + <sect1 id="plperl-data"> + <title>Data Values in PL/Perl</title> + + <para> + 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 <command>SELECT</command> statement). + Conversely, the <function>return</function> and <function>return_next</function> + commands will accept any string that is acceptable input format + for the function's declared return type. </para> </sect1> @@ -682,18 +692,6 @@ SELECT done(); </sect2> </sect1> - <sect1 id="plperl-data"> - <title>Data Values in PL/Perl</title> - - <para> - 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 <command>SELECT</command> statement). - Conversely, the <literal>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. - </para> </sect1> <sect1 id="plperl-global"> @@ -1042,8 +1040,7 @@ CREATE TRIGGER test_valid_id_trig <itemizedlist> <listitem> <para> - PL/Perl functions cannot call each other directly (because they - are anonymous subroutines inside Perl). + PL/Perl functions cannot call each other directly. </para> </listitem> @@ -1072,6 +1069,8 @@ CREATE TRIGGER test_valid_id_trig </listitem> </itemizedlist> </para> + </sect2> + </sect1> </chapter> |