postgresql/src/pl/plperl
Peter Eisentraut 424f0edcb8 Fix relative path references so that make knowns which dependencies refer
to one another. Sort out builddir vs srcdir variable namings. Remove some
now obsoleted make variables.
2000-08-31 16:12:35 +00:00
..
GNUmakefile Fix relative path references so that make knowns which dependencies refer 2000-08-31 16:12:35 +00:00
Makefile.PL Moved the intricacies of the perl interface build into its own makefile 2000-06-10 18:02:12 +00:00
README Well, I finally solved the linking problem 2000-01-20 05:08:58 +00:00
SPI.xs Attached is a uuencoded tarball that contains 2000-01-29 01:58:50 +00:00
eloglvl.c Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
eloglvl.h Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
plperl.c Update textin() and textout() to new fmgr style. This is just phase 2000-07-05 23:12:09 +00:00

README

>perl Makefile.pl
>make

copy the resulting library somewhere that
the postgresql backend can see it. assume
that path is /usr/local/pgsql/modules/plperl.so

CREATE FUNCTION plperl_call_handler() RETURNS opaque
AS '/usr/local/pgsql/modules/plperl.so' LANGUAGE 'C';

CREATE TRUSTED PROCEDURAL LANGUAGE 'plperl'
HANDLER plperl_call_handler
LANCOMPILER 'PL/Perl';

-- here is simple example
CREATE FUNCTION addints(int4, int4) RETURNS int4 AS '
return $_[0] + $_[1]
' LANGUAGE 'plperl';

SELECT addints(3,4);

-- of course, you can pass tuples;
CREATE TABLE twoints ( a integer, b integer);
CREATE FUNCTION addtwoints(twoints) RETURNS integer AS '
$tup = shift;
return $tup->{"a"} + $tup->{"b"};
' LANGUAGE 'plperl';

SELECT addtwoints(twoints) from twoints;

-- here is one that will fail. Creating the function
-- will work, but using it will fail.
CREATE FUNCTION badfunc() RETURNS int4 AS '
open(TEMP, ">/tmp/badfile");
print TEMP "Gotcha!\n";
return 1;
' LANGUAGE 'plperl';

SELECT badfunc();