Re: arrays as pl/perl input arguments [PATCH]
Alex Hunsaker <badalex@gmail.com>
From: Alex Hunsaker <badalex@gmail.com>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Alexey Klyukin <alexk@commandprompt.com>, "David E. Wheeler" <david@kineticode.com>, pgsql-hackers@postgresql.org
Date: 2011-02-04T18:43:34Z
Lists: pgsql-hackers
On Fri, Feb 4, 2011 at 10:29, Andrew Dunstan <andrew@dunslane.net> wrote:
>> Anyone object to fixing the above as part of this patch? That is
>> making plperl_(build_tuple_result, modify_tuple, return_next,
>> hash_from_tuple) handle array and hash (composite/row) types
>> consistently? And _that_ would be to recurse and turn them from/into
>> perl objects. Thoughts?
>>
>
>
> I have no objection to making the whole thing work recursively, in
> principle, but will it break legacy code?
It will certainly change how nested composites are represented on the
'input side'. I would argue its a bug the way it is now and also
violates the POLA. I think we should also remain backwards compatible
on the output side so you could still return a string:
-- how things are currently, manually assigning a composite-literal
(would continue to work)
=> create or replace function trigger_func() returns trigger as $$
$_TD->{'new'}{'nested_composite'} = {'a'=>'(1,2)'}';
return 'MODIFY';
-- it would also work with perl nested structures (currently broken)
=> create or replace function trigger_func() returns trigger as $$
$_TD->{'new'}{'nested_composite'} = {'a'=>{'b'=>1, 'c'=>2}};
return 'MODIFY';
$$
Or perhaps you are saying we should do something similar with what we
now do with arrays? The pseudo array dance that is.