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

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: PL/Python adding support for multi-dimensional arrays
Дата
Msg-id CADK3HH+vgKqwRDgRgVv+2dBUrRuNabBu5ZBEZaQnsNSKon1Z0g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PL/Python adding support for multi-dimensional arrays  (Heikki Linnakangas <hlinnaka@iki.fi>)
Ответы Re: PL/Python adding support for multi-dimensional arrays  (Dave Cramer <pg@fastcrypt.com>)
Список 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. 
 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Speed up Clog Access by increasing CLOG buffers
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Allowing GIN array_ops to work on anyarray