Re: [PATCH] Introduce array_shuffle() and array_sample()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] Introduce array_shuffle() and array_sample()
Дата
Msg-id 817328.1658178181@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [PATCH] Introduce array_shuffle() and array_sample()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] Introduce array_shuffle() and array_sample()  (Martin Kalcher <martin.kalcher@aboutsource.net>)
Список pgsql-hackers
I wrote:
> Martin had originally proposed (2), which I rejected on the grounds
> that we don't treat multi-dimensional arrays as arrays-of-arrays for
> any other purpose.

Actually, after poking at it for awhile, that's an overstatement.
It's true that the type system doesn't think N-D arrays are
arrays-of-arrays, but there are individual functions/operators that do.

For instance, @> is in the its-a-flat-list-of-elements camp:

regression=# select array[[1,2],[3,4]] @> array[1,3];
 ?column?
----------
 t
(1 row)

but || wants to preserve dimensionality:

regression=# select array[[1,2],[3,4]] || array[1];
ERROR:  cannot concatenate incompatible arrays
DETAIL:  Arrays with differing dimensions are not compatible for concatenation.

Various other functions dodge the issue by refusing to work on arrays
of more than one dimension.

There seem to be more functions that think arrays are flat than
otherwise, but it's not as black-and-white as I was thinking.

            regards, tom lane



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: [Commitfest 2022-07] Begins Now
Следующее
От: Martin Kalcher
Дата:
Сообщение: Re: [PATCH] Introduce array_shuffle() and array_sample()