Thread: PLPerl not installed correctly?

PLPerl not installed correctly?

From
"Daniel Hutchison"
Date:

I’ve been experiencing problems getting any plperl function working, and I believe the problem lies in the actual plperl installation not due to my rusty perl memories.  For example, the very simple plperl example in the comprehensive documentation (at http://www.postgresql.org/docs/8.4/interactive/plperl-funcs.html):

 

CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $$

    if ($_[0] > $_[1]) { return $_[0]; }

    return $_[1];

$$ LANGUAGE plperl;

 

Returns something odd (at least to me, also with little postgresql experience):

 

prod1=> select perl_max(1,2);

ERROR:  invalid input syntax for integer: "CODE(0x1f6d13c)"

 

I have seen something similar to "CODE(0x...)" show up in other programs, but because the input parameter on those was TEXT I didn’t get an error... the program just behaved very confusingly until I realized that the correct text input was being replaced with “CODE(0x...)".  At least in this example, I get an actual error because the input variable doesn’t match type.

 

Thanks for any help you can tell me on how to fix this!

Daniel

 

My Environment:

 

PostgreSQL: \set: “VERSION = 'PostgreSQL 8.4.3, compiled by Visual C++ build 1400, 32-bit'”

OS: Windows Vista laptop (only for development purposes, I swear ;) )

ActivePerl: perl –v: “This is perl, v5.10.1 built for MSWin32-x86-multi-thread”

 

Re: PLPerl not installed correctly?

From
Tom Lane
Date:
"Daniel Hutchison" <Daniel.Hutchison@rokaconsulting.com> writes:
> I've been experiencing problems getting any plperl function working, and I
> believe the problem lies in the actual plperl installation not due to my
> rusty perl memories.  For example, the very simple plperl example in the
> comprehensive documentation (at
> http://www.postgresql.org/docs/8.4/interactive/plperl-funcs.html):
> Returns something odd (at least to me, also with little postgresql
> experience):
> prod1=> select perl_max(1,2);
> ERROR:  invalid input syntax for integer: "CODE(0x1f6d13c)"

I'm going to guess that your perl installation doesn't match the version
of perl your postgresql installation was built against.  I'm not sure
how you find that out for certain, but maybe the docs that came with the
PG installer would tell you what it's expecting.

            regards, tom lane

Re: PLPerl not installed correctly?

From
Mladen Gogala
Date:
Daniel Hutchison wrote:
>
> I’ve been experiencing problems getting any plperl function working,
> and I believe the problem lies in the actual plperl installation not
> due to my rusty perl memories. For example, the very simple plperl
> example in the comprehensive documentation (at
> http://www.postgresql.org/docs/8.4/interactive/plperl-funcs.html):
>
> CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $$
>
> if ($_[0] > $_[1]) { return $_[0]; }
>
> return $_[1];
>
> $$ LANGUAGE plperl;
>
> Returns something odd (at least to me, also with little postgresql
> experience):
>
> prod1=> select perl_max(1,2);
>
> ERROR: invalid input syntax for integer: "CODE(0x1f6d13c)"
>
> I have seen something similar to "CODE(0x...)" show up in other
> programs, but because the input parameter on those was TEXT I didn’t
> get an error... the program just behaved very confusingly until I
> realized that the correct text input was being replaced with
> “CODE(0x...)". At least in this example, I get an actual error because
> the input variable doesn’t match type.
>
> Thanks for any help you can tell me on how to fix this!
>
> Daniel
>
> My Environment:
>
> PostgreSQL: \set: “VERSION = 'PostgreSQL 8.4.3, compiled by Visual C++
> build 1400, 32-bit'”
>
> OS: Windows Vista laptop (only for development purposes, I swear ;) )
>
> ActivePerl: perl –v: “This is perl, v5.10.1 built for
> MSWin32-x86-multi-thread”
>

mgogala=# create function perl_max(integer,integer) RETURNS integer AS $$
mgogala$# ($x,$y)=@_;
mgogala$# ($x>$y)? return $x : return $y;
mgogala$# $$ LANGUAGE plperl;
CREATE FUNCTION

mgogala=# select perl_max(1,2);
perl_max
----------
2
(1 row)

Time: 27.411 ms

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


Re: PLPerl not installed correctly?

From
"Daniel Hutchison"
Date:
Yes, I tried it that way as well.  Same problem!  Thanks for the suggestion,
however.

-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Mladen Gogala
Sent: Thursday, April 22, 2010 9:14 AM
To: Daniel.Hutchison@rokaconsulting.com
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] PLPerl not installed correctly?

Daniel Hutchison wrote:
>
> I've been experiencing problems getting any plperl function working,
> and I believe the problem lies in the actual plperl installation not
> due to my rusty perl memories. For example, the very simple plperl
> example in the comprehensive documentation (at
> http://www.postgresql.org/docs/8.4/interactive/plperl-funcs.html):
>
> CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $$
>
> if ($_[0] > $_[1]) { return $_[0]; }
>
> return $_[1];
>
> $$ LANGUAGE plperl;
>
> Returns something odd (at least to me, also with little postgresql
> experience):
>
> prod1=> select perl_max(1,2);
>
> ERROR: invalid input syntax for integer: "CODE(0x1f6d13c)"
>
> I have seen something similar to "CODE(0x...)" show up in other
> programs, but because the input parameter on those was TEXT I didn't
> get an error... the program just behaved very confusingly until I
> realized that the correct text input was being replaced with
> "CODE(0x...)". At least in this example, I get an actual error because
> the input variable doesn't match type.
>
> Thanks for any help you can tell me on how to fix this!
>
> Daniel
>
> My Environment:
>
> PostgreSQL: \set: "VERSION = 'PostgreSQL 8.4.3, compiled by Visual C++
> build 1400, 32-bit'"
>
> OS: Windows Vista laptop (only for development purposes, I swear ;) )
>
> ActivePerl: perl -v: "This is perl, v5.10.1 built for
> MSWin32-x86-multi-thread"
>

mgogala=# create function perl_max(integer,integer) RETURNS integer AS $$
mgogala$# ($x,$y)=@_;
mgogala$# ($x>$y)? return $x : return $y;
mgogala$# $$ LANGUAGE plperl;
CREATE FUNCTION

mgogala=# select perl_max(1,2);
perl_max
----------
2
(1 row)

Time: 27.411 ms

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice


Re: PLPerl not installed correctly?

From
Tim Bunce
Date:
On Tue, Apr 20, 2010 at 11:21:55AM -0400, Tom Lane wrote:
> "Daniel Hutchison" <Daniel.Hutchison@rokaconsulting.com> writes:
> > I've been experiencing problems getting any plperl function working, and I
> > believe the problem lies in the actual plperl installation not due to my
> > rusty perl memories.  For example, the very simple plperl example in the
> > comprehensive documentation (at
> > http://www.postgresql.org/docs/8.4/interactive/plperl-funcs.html):
> > Returns something odd (at least to me, also with little postgresql
> > experience):
> > prod1=> select perl_max(1,2);
> > ERROR:  invalid input syntax for integer: "CODE(0x1f6d13c)"
>
> I'm going to guess that your perl installation doesn't match the version
> of perl your postgresql installation was built against.

Or perhaps it's picking up the wrong version of the plperl shared lib.

This should work for finding the perl (not plperl) version:
create function perl_ver() RETURNS void AS $$ warn $] $$ language plperl;
select perl_ver();
NOTICE:  5.008008 at line 1.

Tim.