Re: plperl return array support revisited

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: plperl return array support revisited
Date: 2005-07-10 15:32:51
Message-ID: 200507101532.j6AFWpa06654@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
> Following up a previous thought I had, yesterday I realised how to
> return arays nicely without having to make the plperl programmer aware
> of anything. The attached patch allows plperl to return an arrayref
> where the function returns an array type. It silently calls a perl
> function to stringify the array before passing it to the pg array
> parser. Non-array returns are handled as before (i.e. passed through
> this process) so it is backwards compatible. I will presently submit
> regression tests and docs.
>
> example:
>
> andrew=# create or replace function blah() returns text[][] language
> plperl as $$ return [['a"b','c,d'],['e\\f','g']]; $$;
> CREATE FUNCTION
> andrew=# select blah();
> blah
> -----------------------------
> {{"a\"b","c,d"},{"e\\f",g}}
>
>
> This would complete half of the TODO item:
>
> . Pass arrays natively instead of as text between plperl and postgres
>
> (The other half is translating pg array arguments to perl arrays - that
> will have to wait for 8.1).
>
> Some of this patch is adapted from a previously submitted patch from
> Sergej Sergeev. Both he and Abhijit Menon-Sen have looked it over
> briefly and tentatively said it looks ok.
>
> cheers
>
> andrew

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2005-07-10 16:49:38 Re: regexp_replace
Previous Message Bruce Momjian 2005-07-10 15:19:47 Re: spi_query/spi_fetchrow for pl/perl