Kind people,
Please find enclosed a patch that matches the PL/Perl documentation
(fairly closely, I hope) to the current PL/Perl implementation.
Cheers,
D
--
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
Index: doc/src/sgml/plperl.sgml
===
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/plperl.sgml,v
retrieving revision 2.23
diff -u -r2.23 plperl.sgml
--- doc/src/sgml/plperl.sgml16 May 2004 23:22:06 - 2.23
+++ doc/src/sgml/plperl.sgml20 Jul 2004 03:04:05 -
@@ -34,9 +34,10 @@
Users of source packages must specially enable the build of
-PL/Perl during the installation process. (Refer to the installation
-instructions for more information.) Users of binary packages
-might find PL/Perl in a separate subpackage.
+PL/Perl during the installation process. (Refer to for more information.) Users of
+binary packages might find PL/Perl in a separate subpackage.
+
@@ -54,7 +55,7 @@
The body of the function is ordinary Perl code. Since the body of
the function is treated as a string by
PostgreSQL, it can be specified using
- dollar quoting (as shown above), or via the usual single quote
+ dollar quoting (as shown above), or via the legacy single quote
syntax (see for more
information).
@@ -79,19 +80,22 @@
- If an SQL null valuenull valuein PL/Perl is passed to a function,
- the argument value will appear as undefined in Perl. The
- above function definition will not behave very nicely with null
- inputs (in fact, it will act as though they are zeroes). We could
- add STRICT to the function definition to make
- PostgreSQL do something more reasonable:
- if a null value is passed, the function will not be called at all,
- but will just return a null result automatically. Alternatively,
- we could check for undefined inputs in the function body. For
- example, suppose that we wanted perl_max with
- one null and one non-null argument to return the non-null argument,
- rather than a null value:
+ If an SQL NULL valuenull
+valuein PL/Perl is
+passed to a function, the argument value will appear as
+undefined in Perl. The above function definition will not
+behave very nicely with NULL inputs (in fact, it
+will act as though they are zeroes). We could add STRICT
+to the function definition to make
+PostgreSQL do something more reasonable: if
+a NULL value is passed, the function will not be
+called at all, but will just return a NULL result
+automatically. Alternatively, we could check for undefined inputs in
+the function body. For example, suppose that we wanted
+perl_max with one NULL and one
+non-NULL argument to return the
+non-NULL argument, rather than a
+NULL value:
CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $$
@@ -108,9 +112,9 @@
- As shown above, to return an SQL null value from a PL/Perl
- function, return an undefined value. This can be done whether the
- function is strict or not.
+As shown above, to return an SQL NULL value from
+a PL/Perl function, return an undefined value. This can be done
+whether the function is strict or not.
@@ -127,7 +131,7 @@
CREATE FUNCTION empcomp(employee) RETURNS integer AS $$
my ($emp) = @_;
-return $emp->{'basesalary'} + $emp->{'bonus'};
+return $emp->{basesalary} + $emp->{bonus};
$$ LANGUAGE plperl;
SELECT name, empcomp(employee) FROM employee;
@@ -135,35 +139,9 @@
- There is currently no support for returning a composite-type result
- value.
+ There is now support for returning a composite-type result value.
-
-
-Because the function body is passed as an SQL string literal to
-CREATE FUNCTION, you have to use dollar quoting
-or escape single quotes and backslashes within your Perl source,
-typically by doubling them. Another possible approach is to avoid
-writing single quotes by using Perl's extended quoting operators
-(q[], qq[],
-qw[]).
-
-
-
-
-
- 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, the PL/Perl programmer can manipulate data values as if
- they were just text.
-
@@ -171,25 +149,77 @@
Access to the database itself from your Perl function can be done via
- an experimental module http://www.cpan.org/modules/by-module/DBD/APILOS/";>DBD::PgSPI
(also available at http://www.cpan.org/SITES.html";>CPAN
- mirror sites). This module makes available a
+