Re: Use UNKNOWN with PL/Perl spi_prepare()?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
Subject: Re: Use UNKNOWN with PL/Perl spi_prepare()?
Date: 2010-04-06 23:55:24
Message-ID: 4BBBC9EC.6020305@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David E. Wheeler wrote:
> On Apr 6, 2010, at 4:40 PM, Tom Lane wrote:
>
>
>>> I tried this:
>>> try=# create or replace function try() returns void language plperl as $$
>>> spi_prepare('select length($1)', 'unknown');
>>> $$;
>>> CREATE FUNCTION
>>> try=# select try();
>>> ERROR: error from Perl function "try": failed to find conversion function from unknown to text at line 2.
>>>
>> Why would you think this is useful, considering that plperl has no
>> concept of SQL data types? Everything you could pass to
>> spi_exec_prepared is effectively text, no?
>>
>
> try=# create or replace function try() returns void language plperl as $$
> spi_prepare('select abs($1)', 'text');
> $$;
> CREATE FUNCTION
> try=# select try();
> ERROR: error from Perl function "try": function abs(text) does not exist at line 2.
>
>
>

Indeed it doesn't. But (as documented) the argument will be passed
*from* *perl* as text and converted to the specified type in the glue
code. See plperl.c for details.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-04-07 00:00:48 Re: Proposal: Add JSON support
Previous Message Tom Lane 2010-04-06 23:54:14 Re: Use UNKNOWN with PL/Perl spi_prepare()?