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

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: PL/Python adding support for multi-dimensional arrays
Дата
Msg-id b1e7823a-7d43-6f03-4188-8ee3985e751b@iki.fi
обсуждение исходный текст
Ответ на Re: PL/Python adding support for multi-dimensional arrays  (Dave Cramer <pg@fastcrypt.com>)
Ответы Re: PL/Python adding support for multi-dimensional arrays  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-hackers
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!

- Heikki


Вложения

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

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Floating point comparison inconsistencies of the geometric types
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Detect supported SET parameters when pg_restore is run