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

From Tom Lane
Subject Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
Date
Msg-id 32402.1436450457@sss.pgh.pa.us
Whole thread Raw
In response to ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)  (Michael Herold <quabla@hemio.de>)
Responses Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)  (Michael Herold <quabla@hemio.de>)
Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)  (Michael Herold <quabla@hemio.de>)
List pgsql-docs
Michael Herold <quabla@hemio.de> writes:
> A few minutes ago I got bitten by the following PostgreSQL (9.4) behavior
> SELECT ARRAY[1] || NULL, array_append(ARRAY[1], NULL);
>   ?column? | array_append
> ----------+--------------
>   {1}      | {1,NULL}

> I expected that array_append and || are equivalent in this case but
> obviously they are not.

Yeah, the first case turns out to be array_cat not array_append.

> Sure, this is not too surprising since "||" has
> to guess which operation is appropriate. However, I would have highly
> appreciated ARRAY[1,2] || NULL as an example in [Table 9-45].

Hm.  I don't think there is really room for such an example in that table,
and certainly not room for a discursive discussion.  What would make more
sense to me is to add a paragraph and example concerning this issue at the
bottom of section 8.15.4, right after array_append and array_cat are
introduced.  Since there's already a pointer to 8.15 just below that
table, people would hopefully find the example from that vicinity as well.

Seem reasonable?

            regards, tom lane


pgsql-docs by date:

Previous
From: Michael Herold
Date:
Subject: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL)
Next
From: amul sul
Date:
Subject: typo in synchronous_commit description