Unix Technical Forum

plperl return array support revisited

This is a discussion on plperl return array support revisited within the Pgsql Patches forums, part of the PostgreSQL category; --> Following up a previous thought I had, yesterday I realised how to return arays nicely without having to make ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 12:35 AM
Andrew Dunstan
 
Posts: n/a
Default plperl return array support revisited


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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 12:40 AM
Bruce Momjian
 
Posts: n/a
Default Re: plperl return array support revisited


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@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com