On 27 September 2016 at 14:58, Heikki Linnakangas <hlinn...@iki.fi> wrote:
> On 09/27/2016 02:04 PM, Dave Cramer wrote: > >> On 26 September 2016 at 14:52, Dave Cramer <p...@fastcrypt.com> wrote: >> >>> This crashes with arrays with non-default lower bounds: >>>> >>>> postgres=# SELECT * FROM test_type_conversion_array_int >>>> 4('[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 spent some more time massaging this: > > * Changed the loops from iterative to recursive style. I think this indeed > is slightly easier to understand. > > * Fixed another segfault, with too deeply nested lists: > > CREATE or replace FUNCTION test_type_conversion_mdarray_toodeep() RETURNS > int[] AS $$ > return [[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]] > $$ LANGUAGE plpythonu; > > * Also, in PLySequence_ToArray(), we must check that the 'len' of the > array doesn't overflow. > > * Fixed reference leak in the loop in PLySequence_ToArray() to count the > number of dimensions. > > 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 >>> >> > Please do, thanks! > > see attached Dave Cramer da...@postgresintl.com www.postgresintl.com
0002-WIP-Multi-dimensional-arrays-in-PL-python.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers