Hi,

I'd like to improve the way PL/Perl handles arrays as function input 
parameters. In PL/Perl arrays are passed as plain text strings, and getting a 
value of an array element requires additional perl code to parse that string. 
I'd like to make this easier by converting each postgresq array passed as an 
input parameter to the reference to the corresponding perl array. The patch in 
attachment illustrates this. it's limited to one-dimensional array output. The 
list  of upcoming improvements is:

-  convert n-dimensional array to the perl equivalent (a reference to a list of 
references)
-  proper support for arrays of composite types
-  compatibility with existing plperl functions by introducing a new custom 
variable, i.e. plperl.pass_array_refs that triggers the new behavior. I think 
it should be disabled by default.
 - documentation and additional tests

The patch adds a new attribute to the plperl_proc_desc struct, that records 
whether Nth argument is an array. The function plperl_ref_from_pg_array does 
the actual job of converting array input parameter to the perl array reference. 
I considered writing a perl routine instead of a C function, although I though 
it would be less readable, more complex and slower due to double conversion of 
input. The disadvantage of a C function is a code duplication with array_out, 
on which my function is based, although it can be avoided by putting a relevant 
part of array_out into a separate function. 

The patch is attached.

Anybody interested in this feature ? Ideas, improvements, suggestions ?

Regards,
--
Alexey Klyukin                              http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc

Attachment: plperl_array.diff
Description: Binary data

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

Reply via email to