Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
| От | Michael Herold |
|---|---|
| Тема | Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL) |
| Дата | |
| Msg-id | 562DFAB8.9050507@hemio.de обсуждение исходный текст |
| Ответ на | Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL) (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
|
| Список | pgsql-docs |
I just got confused by another behavior of the || operator. I thought it
might be appropriate to report it here.
The docs say "the result retains the lower bound subscript of the
left-hand operand’s outer dimension" [1]. That's again not true for
corner cases.
Expected:
# SELECT '{0}'::int[] || '[15:16]={1,2}';
----------
{0,1,2}
Unexpected (lower bound is untouched):
# SELECT '{}'::int[] || '[15:16]={1,2}';
---------------
[15:16]={1,2}
Actually, I was looking for a way to reset the index lower bound of an
array to the default. I didn't found a solution documented anywhere, [2]
only works for known array sizes. So, it might also be worth stating
ARRAY(SELECT UNNEST(...)) as a solution?
[1]: <http://www.postgresql.org/docs/9.5/static/arrays.html>
[2]: <http://www.postgresql.org/message-id/40854D0B.6000005@cromwell.co.uk>
В списке pgsql-docs по дате отправления: