| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> | 
|---|---|
| To: | "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org> | 
| Cc: | PL/Perl <plperlng-devel(at)pgfoundry(dot)org> | 
| Subject: | plperl better array support | 
| Date: | 2005-06-20 09:06:32 | 
| Message-ID: | 42B68718.5010209@dunslane.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-patches | 
The attached patch (submitted for comment) is somewhat adapted from one 
submitted last October. This allows returning a perl array where a 
postgres array is expected.
example:
andrew=# create function blurfl() returns text[] language plperl as $$
andrew$# return ['a','b','c','a"b\c'];
andrew$# $$;
CREATE FUNCTION
andrew=# select blurfl();
      blurfl      
-------------------
 {a,b,c,"a\"b\\c"}
Unlike the patch from October, this patch does not implement ANYARRAY or 
ANYELEMENT pseudotypes. However it does escape/quote array elements 
where necessary. It also preserves the old behaviour (if the plperl 
function returns a string it is just passed through).
I'm not happy about constructing a string which we then parse out again 
into an array - that strikes me as quite inefficient. (And there are 
other inelegancies that I'd like to get rid of.) Much better would be to 
use some array contruction calls directly - any pointers on how to do 
that would be apprciated :-)
cheers
andrew
| Attachment | Content-Type | Size | 
|---|---|---|
| plperl-array.patch | text/x-patch | 5.3 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dave Page | 2005-06-20 12:07:17 | Default database patch | 
| Previous Message | Eugen Nedelcu | 2005-06-20 07:11:14 | Thousands commas in psql |