Re: PL/Python adding support for multi-dimensional arrays

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alexey Grishchenko <programmerag(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/Python adding support for multi-dimensional arrays
Date: 2016-09-26 18:52:02
Message-ID: CADK3HH+vgKqwRDgRgVv+2dBUrRuNabBu5ZBEZaQnsNSKon1Z0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> 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.

Dave Cramer

davec(at)postgresintl(dot)com
www.postgresintl.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-09-26 18:54:51 Re: Allowing GIN array_ops to work on anyarray
Previous Message Tomas Vondra 2016-09-26 18:48:55 Re: Speed up Clog Access by increasing CLOG buffers