Re: Cannot create perlplu function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thangalin <thangalin(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Cannot create perlplu function
Date: 2013-03-31 03:16:38
Message-ID: 26812.1364699798@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thangalin <thangalin(at)gmail(dot)com> writes:
> When I create the following function:

> CREATE OR REPLACE FUNCTION get_hostname()
> RETURNS text AS
> $BODY$
> use Sys::Hostname;
> return hostname;
> $BODY$
> LANGUAGE plperlu IMMUTABLE
> COST 1;
> ALTER FUNCTION get_hostname()
> OWNER TO account_name;

> I receive the following error:

> ERROR: Unable to load Sys/Hostname.pm into plperl at line 2.

Ok, so it's not finding the module you're trying to "use".

> The following Perl script works as expected from the shell:

> use Sys::Hostname;
> print hostname;

This probably means that your shell environment defines a Perl @INC
search path that finds the Sys::Hostname module, but the postmaster's
environment doesn't have that. I'm not much of a Perl hacker, but
I'd try looking to see if your private ~/.profile or similar file is
setting up a custom Perl search path. If so, you could propagate a
similar setting into the environment of the user ID you're running
the postmaster under.

One trick that might be helpful is to look at the postmaster's stderr
output (which should be getting logged somewhere if you've got a well
configured setup). The underlying Perl message about "Can't locate
Sys/hostname.pm in @INC" might show up there, and if so it'd tell you
just what search path the postmaster is actually seeing.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Henrik Aagaard Sørensen 2013-04-02 08:42:48 Implementing SCD Type 2.
Previous Message Thangalin 2013-03-30 23:36:13 Cannot create perlplu function