Following up a previous thought I had, yesterday I realised how to return arays nicely without having to make the plperl programmer aware of anything. The attached patch allows plperl to return an arrayref where the function returns an array type. It silently calls a perl function to stringify the array before passing it to the pg array parser. Non-array returns are handled as before (i.e. passed through this process) so it is backwards compatible. I will presently submit regression tests and docs.
Following up a previous thought I had, yesterday I realised how to
return arays nicely without having to make the plperl programmer aware
of anything. The attached patch allows plperl to return an arrayref
where the function returns an array type. It silently calls a perl
function to stringify the array before passing it to the pg array
parser. Non-array returns are handled as before (i.e. passed through
this process) so it is backwards compatible. I will presently submit
regression tests and docs.

example:

andrew=# create or replace function blah() returns text[][] language
plperl as $$ return [['a"b','c,d'],['e\\f','g']]; $$;
CREATE FUNCTION
andrew=# select blah();
            blah
-----------------------------
 {{"a\"b","c,d"},{"e\\f",g}}


This would complete half of the TODO item:

  . Pass arrays natively instead of as text between plperl and postgres

(The other half is translating pg array arguments to perl arrays - that
will have to wait for 8.1).

Some of this patch is adapted from a previously submitted patch from
Sergej Sergeev. Both he and Abhijit Menon-Sen have looked it over
briefly and tentatively said it looks ok.

Andrew Dunstan

0x0FFF/gpdb,rvs/gpdb,greenplum-db/gpdb,techdragon/Postgres-XL,lisakowen/gpdb,janebeckman/gpdb,ahachete/gpdb,janebeckman/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,edespino/gpdb,adam8157/gpdb,randomtask1155/gpdb,janebeckman/gpdb,xuegang/gpdb,rvs/gpdb,postmind-net/postgres-xl,cjcjameson/gpdb,ovr/postgres-xl,randomtask1155/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,Quikling/gpdb,techdragon/Postgres-XL,atris/gpdb,foyzur/gpdb,zaksoup/gpdb,rvs/gpdb,rubikloud/gpdb,adam8157/gpdb,yuanzhao/gpdb,zaksoup/gpdb,tangp3/gpdb,kaknikhil/gpdb,arcivanov/postgres-xl,postmind-net/postgres-xl,lintzc/gpdb,ahachete/gpdb,adam8157/gpdb,foyzur/gpdb,50wu/gpdb,xuegang/gpdb,edespino/gpdb,zeroae/postgres-xl,rubikloud/gpdb,pavanvd/postgres-xl,xinzweb/gpdb,lpetrov-pivotal/gpdb,tpostgres-projects/tPostgres,adam8157/gpdb,kmjungersen/PostgresXL,cjcjameson/gpdb,lpetrov-pivotal/gpdb,adam8157/gpdb,xuegang/gpdb,xuegang/gpdb,yazun/postgres-xl,0x0FFF/gpdb,lisakowen/gpdb,kmjungersen/PostgresXL,pavanvd/postgres-xl,0x0FFF/gpdb,rubikloud/gpdb,atris/gpdb,tpostgres-projects/tPostgres,xuegang/gpdb,Chibin/gpdb,atris/gpdb,CraigHarris/gpdb,kaknikhil/gpdb,xinzweb/gpdb,randomtask1155/gpdb,cjcjameson/gpdb,pavanvd/postgres-xl,50wu/gpdb,cjcjameson/gpdb,rubikloud/gpdb,foyzur/gpdb,Quikling/gpdb,Quikling/gpdb,xuegang/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,kaknikhil/gpdb,royc1/gpdb,edespino/gpdb,edespino/gpdb,CraigHarris/gpdb,edespino/gpdb,Postgres-XL/Postgres-XL,arcivanov/postgres-xl,arcivanov/postgres-xl,techdragon/Postgres-XL,lintzc/gpdb,snaga/postgres-xl,greenplum-db/gpdb,50wu/gpdb,edespino/gpdb,Quikling/gpdb,tpostgres-projects/tPostgres,jmcatamney/gpdb,zeroae/postgres-xl,xinzweb/gpdb,janebeckman/gpdb,chrishajas/gpdb,jmcatamney/gpdb,kaknikhil/gpdb,lisakowen/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,royc1/gpdb,chrishajas/gpdb,50wu/gpdb,ashwinstar/gpdb,snaga/postgres-xl,postmind-net/postgres-xl,atris/gpdb,xinzweb/gpdb,yazun/postgres-xl,Chibin/gpdb,ahachete/gpdb,yuanzhao/gpdb,Quikling/gpdb,50wu/gpdb,lisakowen/gpdb,cjcjameson/gpdb,ovr/postgres-xl,edespino/gpdb,zaksoup/gpdb,yuanzhao/gpdb,yuanzhao/gpdb,arcivanov/postgres-xl,janebeckman/gpdb,yazun/postgres-xl,kmjungersen/PostgresXL,ovr/postgres-xl,zaksoup/gpdb,greenplum-db/gpdb,Chibin/gpdb,tangp3/gpdb,adam8157/gpdb,randomtask1155/gpdb,ashwinstar/gpdb,janebeckman/gpdb,rvs/gpdb,tpostgres-projects/tPostgres,ahachete/gpdb,xuegang/gpdb,snaga/postgres-xl,ashwinstar/gpdb,Postgres-XL/Postgres-XL,chrishajas/gpdb,ashwinstar/gpdb,lintzc/gpdb,0x0FFF/gpdb,lintzc/gpdb,Quikling/gpdb,greenplum-db/gpdb,lintzc/gpdb,CraigHarris/gpdb,rubikloud/gpdb,rubikloud/gpdb,Chibin/gpdb,yuanzhao/gpdb,Quikling/gpdb,royc1/gpdb,atris/gpdb,zaksoup/gpdb,rvs/gpdb,lintzc/gpdb,chrishajas/gpdb,snaga/postgres-xl,yuanzhao/gpdb,tangp3/gpdb,ahachete/gpdb,edespino/gpdb,lisakowen/gpdb,oberstet/postgres-xl,foyzur/gpdb,kmjungersen/PostgresXL,Quikling/gpdb,0x0FFF/gpdb,zaksoup/gpdb,xuegang/gpdb,Chibin/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,atris/gpdb,yazun/postgres-xl,zaksoup/gpdb,ashwinstar/gpdb,zeroae/postgres-xl,greenplum-db/gpdb,royc1/gpdb,rvs/gpdb,lisakowen/gpdb,CraigHarris/gpdb,randomtask1155/gpdb,lpetrov-pivotal/gpdb,ovr/postgres-xl,oberstet/postgres-xl,jmcatamney/gpdb,janebeckman/gpdb,jmcatamney/gpdb,chrishajas/gpdb,techdragon/Postgres-XL,rubikloud/gpdb,cjcjameson/gpdb,0x0FFF/gpdb,lintzc/gpdb,cjcjameson/gpdb,janebeckman/gpdb,lpetrov-pivotal/gpdb,arcivanov/postgres-xl,50wu/gpdb,randomtask1155/gpdb,janebeckman/gpdb,Postgres-XL/Postgres-XL,kaknikhil/gpdb,chrishajas/gpdb,jmcatamney/gpdb,0x0FFF/gpdb,kaknikhil/gpdb,ahachete/gpdb,Postgres-XL/Postgres-XL,lisakowen/gpdb,jmcatamney/gpdb,kaknikhil/gpdb,royc1/gpdb,oberstet/postgres-xl,Chibin/gpdb,yazun/postgres-xl,rvs/gpdb,xinzweb/gpdb,lpetrov-pivotal/gpdb,kaknikhil/gpdb,ovr/postgres-xl,Chibin/gpdb,snaga/postgres-xl,foyzur/gpdb,pavanvd/postgres-xl,xuegang/gpdb,Chibin/gpdb,cjcjameson/gpdb,tangp3/gpdb,50wu/gpdb,edespino/gpdb,ahachete/gpdb,janebeckman/gpdb,xinzweb/gpdb,yuanzhao/gpdb,CraigHarris/gpdb,CraigHarris/gpdb,tangp3/gpdb,randomtask1155/gpdb,Chibin/gpdb,foyzur/gpdb,tangp3/gpdb,Chibin/gpdb,lpetrov-pivotal/gpdb,zaksoup/gpdb,royc1/gpdb,xinzweb/gpdb,Quikling/gpdb,chrishajas/gpdb,chrishajas/gpdb,kmjungersen/PostgresXL,Postgres-XL/Postgres-XL,lintzc/gpdb,ashwinstar/gpdb,pavanvd/postgres-xl,foyzur/gpdb,50wu/gpdb,zeroae/postgres-xl,arcivanov/postgres-xl,adam8157/gpdb,zeroae/postgres-xl,tangp3/gpdb,foyzur/gpdb,postmind-net/postgres-xl,tangp3/gpdb,edespino/gpdb,rvs/gpdb,royc1/gpdb,atris/gpdb,techdragon/Postgres-XL,CraigHarris/gpdb,lpetrov-pivotal/gpdb,lintzc/gpdb,ashwinstar/gpdb,rvs/gpdb,postmind-net/postgres-xl,atris/gpdb,lisakowen/gpdb,randomtask1155/gpdb,rvs/gpdb,tpostgres-projects/tPostgres,cjcjameson/gpdb,Quikling/gpdb,yuanzhao/gpdb,rubikloud/gpdb,greenplum-db/gpdb,CraigHarris/gpdb,adam8157/gpdb,royc1/gpdb,xinzweb/gpdb,lpetrov-pivotal/gpdb,0x0FFF/gpdb,ahachete/gpdb,oberstet/postgres-xl