Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)

From: Michael Herold <quabla(at)hemio(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-docs(at)postgresql(dot)org
Subject: Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
Date: 2015-10-26 10:04:40
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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.

# SELECT '{0}'::int[] || '[15:16]={1,2}';

Unexpected (lower bound is untouched):
# SELECT '{}'::int[] || '[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]: <>
[2]: <>

In response to


Browse pgsql-docs by date

  From Date Subject
Next Message Alexander Lakhin 2015-10-26 10:53:15 Re: Moving documentation to XML
Previous Message Rob Sargent 2015-10-23 17:18:39 Re: ubuntu deb packaging