Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL) - Mailing list pgsql-docs

From Michael Herold
Subject Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
Date
Msg-id 562DFAB8.9050507@hemio.de
Whole thread Raw
In response to Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
List 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 by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: Moving documentation to XML
Next
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] max_worker_processes on the standby