arrays as input parameters in plperl
От | Alexey Klyukin |
---|---|
Тема | arrays as input parameters in plperl |
Дата | |
Msg-id | C523222B-9466-4E7D-8247-DDA3CC1BAA15@commandprompt.com обсуждение исходный текст |
Список | pgsql-hackers |
Hi, I'd like to improve the way PL/Perl handles arrays as function input parameters. In PL/Perl arrays are passed as plain textstrings, and getting a value of an array element requires additional perl code to parse that string. I'd like to makethis easier by converting each postgresq array passed as an input parameter to the reference to the corresponding perlarray. The patch in attachment illustrates this. it's limited to one-dimensional array output. The list of upcomingimprovements 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 triggersthe 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 functionplperl_ref_from_pg_array does the actual job of converting array input parameter to the perl array reference. I consideredwriting a perl routine instead of a C function, although I though it would be less readable, more complex and slowerdue to double conversion of input. The disadvantage of a C function is a code duplication with array_out, on whichmy 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
Вложения
В списке pgsql-hackers по дате отправления: