Re: PL/Python adding support for multi-dimensional arrays - Mailing list pgsql-hackers

From Dave Cramer
Subject Re: PL/Python adding support for multi-dimensional arrays
Date
Msg-id CADK3HHJ+LzpTg-T5CwjoRMLiNx6mcw=Hk3gbFHa8cpPF-y=XwQ@mail.gmail.com
Whole thread Raw
In response to Re: PL/Python adding support for multi-dimensional arrays  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: PL/Python adding support for multi-dimensional arrays  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers

On 26 September 2016 at 14:52, Dave Cramer <pg@fastcrypt.com> wrote:




This crashes with arrays with non-default lower bounds:

postgres=# SELECT * FROM test_type_conversion_array_int4('[2:4]={1,2,3}');
INFO:  ([1, 2, <NULL>], <type 'list'>)
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

Attached patch fixes this bug, and adds a test for it. 

I'd like to see some updates to the docs for this. The manual doesn't currently say anything about multi-dimensional arrays in pl/python, but it should've mentioned that they're not supported. Now that it is supported, should mention that, and explain briefly that a multi-dimensional array is mapped to a python list of lists.

If the code passes I'll fix the docs 
It seems we don't have any mention in the docs about arrays with non-default lower-bounds ATM. That's not this patch's fault, but it would be good to point out that the lower bounds are discarded when an array is passed to python.

I find the loop in PLyList_FromArray() quite difficult to understand. Are the comments there mixing up the "inner" and "outer" dimensions? I wonder if that would be easier to read, if it was written in a recursive-style, rather than iterative with stacks for the dimensions.

Yes, it is fairly convoluted. 
 


Attachment

pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: Speed up Clog Access by increasing CLOG buffers
Next
From: Jeevan Ladhe
Date:
Subject: Re: pgbench more operators & functions