Cannot create perlplu function - Mailing list pgsql-novice

From Thangalin
Subject Cannot create perlplu function
Date
Msg-id CAANrE7qqEPv7k7KjpYRp5Hft0tn8G3pq+sWOK4EH-T=zQoK=Pw@mail.gmail.com
Whole thread Raw
Responses Re: Cannot create perlplu function
List pgsql-novice
Hi, all.

Running PostgreSQL 9.1.8 on Xubuntu 12.04, installed from the repos.

From the shell, I have executed:

    createlang plperl db_name;
    createlang plperlu db_name;

As the superuser running `psql`, I have executed:

    GRANT ALL ON LANGUAGE plperl TO account_name;
    GRANT ALL ON LANGUAGE plperlu TO account_name;

The `pg_language` table reveals:

    select lanname,lanpltrusted from pg_language where lanname like
'plperl%';

    "plperl";t
    "plperlu";t

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.
    BEGIN failed--compilation aborted at line 2.
    CONTEXT:  compilation of PL/Perl function "get_hostname"

Yet the following works:

    CREATE OR REPLACE FUNCTION get_hostname()
      RETURNS text AS
    $BODY$
      return '127.0.0.1';
    $BODY$
      LANGUAGE plperlu IMMUTABLE
      COST 1;
    ALTER FUNCTION get_hostname()
      OWNER TO account_name;

The following Perl script works as expected from the shell:

    use Sys::Hostname;
    print hostname;

I tried to run the function as an anonymous block:

    DO $$
      use Sys::Hostname;
      print hostname;
    $$ LANGUAGE plperlu;

This returned the same error as before, with this additional information:

    ERROR: Unable to load Sys/Hostname.pm into plperl at line 3.
    BEGIN failed--compilation aborted at line 3.
    SQL state: 42601
    Context: PL/Perl anonymous code block

pgsql-novice by date:

Previous
From: kobolds
Date:
Subject: about .pgpass
Next
From: Tom Lane
Date:
Subject: Re: Cannot create perlplu function