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

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: PL/Python adding support for multi-dimensional arrays
Дата
Msg-id CADK3HHLRqFN0bjG0So+fp8k3OntURD2XKBt77OC_WBU22ZFbKw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PL/Python adding support for multi-dimensional arrays  (Heikki Linnakangas <hlinnaka@iki.fi>)
Список pgsql-hackers

On 27 September 2016 at 14:58, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
On 09/27/2016 02:04 PM, Dave Cramer wrote:
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_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 




Вложения

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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Hash Indexes
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Tuplesort merge pre-reading