Re: casting strings to multidimensional arrays yields strange results

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: casting strings to multidimensional arrays yields strange results
Дата
Msg-id 28217.1090937292@sss.pgh.pa.us
обсуждение исходный текст
Ответ на casting strings to multidimensional arrays yields strange results  (Kris Jurka <books@ejurka.com>)
Ответы Re: casting strings to multidimensional arrays yields strange  (Joe Conway <mail@joeconway.com>)
Список pgsql-bugs
Kris Jurka <books@ejurka.com> writes:
> Casting strings to multidimensional arrays yields strange results.

array_in has fairly bizarre behavior when presented with non-rectangular
input data, such as your examples:

> jurka=# SELECT '{{1,2},{2,3},{4}}'::int[][];

> jurka=# SELECT '{{1},{2,3},{4,5}}'::int[][];

I don't recall the details right now of how it chooses the actual array
dimensions, but it's weird.  I've been tempted to rewrite it but have
refrained for fear of breaking existing applications.  Also, it's not
entirely clear what the behavior *should* be.

Right now I think the sanest behavior would be to throw an error on
non-rectangular input.  Once we have support for null elements in
arrays, however, it would arguably be reasonable to pad with NULLs
where needed, so that the above would be read as

    {{1,2},{2,3},{4,NULL}}

    {{1,NULL},{2,3},{4,5}}

respectively.  If that's the direction we want to head in, it would
probably be best to leave array_in alone until we can do that; users
tend to get unhappy when we change behavior repeatedly.

What's your thoughts?

            regards, tom lane

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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: casting strings to multidimensional arrays yields strange
Следующее
От: Joe Conway
Дата:
Сообщение: Re: casting strings to multidimensional arrays yields strange