Re: Dynamic loading of Perl Code in Postgres functions

From: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
To: "Harpreet Dhaliwal" <harpreet(dot)dhaliwal01(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "John DeSoi" <desoi(at)pgedit(dot)com>, "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dynamic loading of Perl Code in Postgres functions
Date: 2007-01-17 22:45:48
Message-ID: a47902760701171445n707093feqac2c81ad6317bbce@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm kind of confused how this require thing would actually work
because I tried testing it at my end at its really not working with
postgres.
I'm sure there is some fundamental mistake.

I have to do the following:

I have a perl file and need to call and use full functionaily of
this perl file in my postgres function.
For this, the create function script that I wrote is as follows:
CREATE FUNCTION test_perl (int) RETURNS int AS $$
require 'email_parser1.pl'
$$ LANGUAGE plperlu;

really don't know if this is correct because if i try to load a file
that doesn't exist atall, then also postgres doesn't throw any errors.

Also do i need to give the fully qualified path of the perl file in
the create function script?

A quick help would be highly appreciated as I'm badly stuck up here.

Thanks,
Jas

On 1/16/07, Harpreet Dhaliwal <harpreet(dot)dhaliwal01(at)gmail(dot)com> wrote:
> so my syntax is correct? just wondering if there's some fundamental mistake
> in it
> ~Harpreet
>
>
> On 1/16/07, Tom Lane < tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > "Harpreet Dhaliwal" < harpreet(dot)dhaliwal01(at)gmail(dot)com> writes:
> > > I was just wondering if one could use something like this
> >
> > > CREATE FUNCTION *funcname* (*argument-types*) RETURNS *return-type* AS
> $$
> > > require " abc.pl"
> > > $$ LANGUAGE plperl;
> >
> > You'd have to use plperlu, since "require" isn't considered a trusted
> > operation.
> >
> > > To include abc.pl here, how is the path of abc.pl specified.
> >
> > Same as you'd do it in plain Perl.
> >
> > regards, tom lane
> >
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ksherlock@gmail.com 2007-01-17 23:29:39 Re: Alter definition of a column
Previous Message Tom Lane 2007-01-17 22:34:27 Re: FATAL: invalid frontend message type 47 server closed the connection unexpectedly