From: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
---|---|
To: | Amit Khandekar <amit(dot)khandekar(at)enterprisedb(dot)com> |
Cc: | hackers(at)postgresql(dot)org |
Subject: | Re: pl/perl example in the doc no longer works in 9.1 |
Date: | 2011-10-12 16:10:25 |
Message-ID: | 3B70E555-91A3-4B7D-8034-7CBAEBA71399@kineticode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Oct 12, 2011, at 2:16 AM, Amit Khandekar wrote:
> CREATE OR REPLACE FUNCTION myfuncs() RETURNS void AS $$
> $_SHARED{myquote} = sub {
> my $arg = shift;
> $arg =~ s/(['\\])/\\$1/g;
> return "'$arg'";
> };
> $$ LANGUAGE plperl;
>
> SELECT myfuncs(); /* initializes the function */
>
> ERROR: PL/Perl function must return reference to hash or array
> CONTEXT: PL/Perl function "myfuncs"
>
> Not sure if this is now an expected behaviour. Is it? Accordingly, I
> can open this in pgsql-bugs or put this issue in pgsql-docs.
Seems like there should be a bar return at the end of the function, otherwise it returns the last expression, which happens to be a code reference. Not very useful in a function that should return VOID. New version:
CREATE OR REPLACE FUNCTION myfuncs() RETURNS void AS $$
$_SHARED{myquote} = sub {
my $arg = shift;
$arg =~ s/(['\\])/\\$1/g;
return "'$arg'";
};
return;
$$ LANGUAGE plperl;
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-10-12 16:15:29 | Re: pl/perl example in the doc no longer works in 9.1 |
Previous Message | Tom Lane | 2011-10-12 15:59:27 | Re: COUNT(*) and index-only scans |