Re: Install new perl test function in PostgreSQL - Mailing list pgsql-novice
From | Jignesh Shah |
---|---|
Subject | Re: Install new perl test function in PostgreSQL |
Date | |
Msg-id | c11950270908260337t77f9fde9v6b812bcdaa76bed8@mail.gmail.com Whole thread Raw |
In response to | Re: Install new perl test function in PostgreSQL (Michael Wood <esiotrot@gmail.com>) |
Responses |
Re: Install new perl test function in PostgreSQL
(Jignesh Shah <jignesh.shah1980@gmail.com>)
|
List | pgsql-novice |
That was a perfect answer Michael. It worked. Thanks.
On Wed, Aug 26, 2009 at 12:31 PM, Michael Wood <esiotrot@gmail.com> wrote:
2009/8/26 Jignesh Shah <jignesh.shah1980@gmail.com>:> Thanks Jure. I have already plperl installed because I could see that manyIf it PL/Perl is installed in your database then you do not need to
> new perl functions have been installed but I don't know where it plperl
> installed. Could you tell me if there is any way to find out where it is
> installed? Morever, if I get the location plperl install location, how to
> insert/install my perl function? Is there any command available for this. My
> questions might be silly but this is first time I am using PostgreSQL.
know "where it is". It's in your database. So you can just create
your function and it should work. e.g.:
$ psql dbname
Welcome to psql 8.3.1, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
dbname=> SELECT * FROM pg_language;
lanname | lanowner | lanispl | lanpltrusted | lanplcallfoid |
lanvalidator | lanacl
----------+----------+---------+--------------+---------------+--------------+--------
internal | 10 | f | f | 0 | 2246 |
c | 10 | f | f | 0 | 2247 |
sql | 10 | f | t | 0 | 2248 |
(3 rows)
dbname=> CREATE LANGUAGE plperl;
CREATE LANGUAGE
dbname=> SELECT * FROM pg_language;
lanname | lanowner | lanispl | lanpltrusted | lanplcallfoid |
lanvalidator | lanacl
----------+----------+---------+--------------+---------------+--------------+--------
internal | 10 | f | f | 0 | 2246 |
c | 10 | f | f | 0 | 2247 |
sql | 10 | f | t | 0 | 2248 |
plperl | 16386 | t | t | 19193 | 19194 |
(4 rows)
dbname=> CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $$
dbname$> if ($_[0] > $_[1]) { return $_[0]; }
dbname$> return $_[1];
dbname$> $$ LANGUAGE plperl;
CREATE FUNCTION
dbname=> SELECT perl_max(55, 23);
perl_max
----------
55
(1 row)
dbname=> SELECT perl_max(55, 97);
perl_max
----------
97
(1 row)
dbname=>
See also:
http://www.postgresql.org/docs/8.4/static/xplang.html
http://www.postgresql.org/docs/8.4/static/plperl.html
--
Michael Wood <esiotrot@gmail.com>
pgsql-novice by date: