Re: arrays as pl/perl input arguments [PATCH] - Mailing list pgsql-hackers

From Alex Hunsaker
Subject Re: arrays as pl/perl input arguments [PATCH]
Date
Msg-id AANLkTikq-Y2=jNx-mVK5GYkgY-xrTOgHQQqy2Qpg9Qti@mail.gmail.com
Whole thread Raw
In response to Re: arrays as pl/perl input arguments [PATCH]  (Andrew Dunstan <andrew@dunslane.net>)
List 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.


pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: Spread checkpoint sync
Next
From: Tom Lane
Date:
Subject: Re: Extensions support for pg_dump, patch v27