On Wed, Jan 12, 2011 at 13:04, Alexey Klyukin <al...@commandprompt.com> wrote: > > On Jan 12, 2011, at 8:52 PM, David E. Wheeler wrote: > >> On Jan 12, 2011, at 5:14 AM, Alexey Klyukin wrote: >> >>> You mean packing both a string representation and a reference to a single >>> SV * value? >> >> Dunno, I'm not a guts guy. > > Well, neither me (I haven't used much of the guts api there).
Find attached a proof of concept that modifies Alexey's patch to do the above (using the overload example I and others posted). Arrays have a reference of 'PostgreSQL::InServer::ARRAY'-- mainly to be consistent with the other PL/Perl packages we have. It also lets you match ref() =~ m/ARRAY$/ to make it a tad easier to figure out if something is an array. The other thing to note is I only applied this to the 'top' array. That is when you have a multidimensional array, its children are 'real' arrays: create or replace function takes_array(text[]) returns void as $$ my $array = shift; elog(NOTICE, ref $array); elog(NOTICE, ref $_) for (@$array); $$ language plperl; select takes_array('{{1}, {2, 3}}'::text[]); NOTICE: PostgreSQL::InServer::ARRAY CONTEXT: PL/Perl function "takes_array" NOTICE: ARRAY CONTEXT: PL/Perl function "takes_array" NOTICE: ARRAY CONTEXT: PL/Perl function "takes_array" We could change that so _all_ arrays have a ref of PostgreSQL::InServer::ARRAY. However I thought it would be nice to easily use built-ins, this way you can just 'cast' away just the top level without having to recurse to children (my @arr = @$array). This also will create a string representation if and when you try to use it as a string. It currently lacks row support in the stringify case (and I left the regression test Alexey added for that failing) so we would need to fix that up if we want to go down this road. Thoughts? Should I polish this a bit more? Or do we like the GUC better?
pg_to_perl_arrays_kind_of.patch.gz
Description: GNU Zip compressed data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers