Re: select array_remove(ARRAY[NULL,NULL,NULL],NULL); returns {} instead of {NULL,NULL,NULL} - Mailing list pgsql-general

From Alban Hertroys
Subject Re: select array_remove(ARRAY[NULL,NULL,NULL],NULL); returns {} instead of {NULL,NULL,NULL}
Date
Msg-id 3635FE2A-A171-468C-ABFA-7EBE40B17BD1@gmail.com
Whole thread Raw
In response to Re: select array_length(array_remove(ARRAY[NULL,NULL,NULL],NULL), 1); returns NULL instead of 0  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: select array_remove(ARRAY[NULL,NULL,NULL],NULL); returns {} instead of {NULL,NULL,NULL}  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
> On 08 Aug 2016, at 20:19, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Alexander Farber <alexander.farber@gmail.com> writes:
>> I wonder, why the following returns NULL and not 0 in 9.5.3?
>
>> # select array_length(array_remove(ARRAY[NULL,NULL,NULL],NULL), 1);
>
> Because the result of the array_remove is an empty array, which is
> defined to be zero-dimensional in PG.

Reading this, I'm a bit confused about why:
select array_remove(ARRAY[NULL, NULL, NULL], NULL);

Results in:

 array_remove
--------------
 {}
(1 row)

How does it now which unknown value to remove from that array of unknown values? Shouldn't the result be:
{NULL,NULL,NULL}?

(Sorry for sort-of hijacking this thread)

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



pgsql-general by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: Column order in multi column primary key
Next
From: "David G. Johnston"
Date:
Subject: Re: select array_remove(ARRAY[NULL,NULL,NULL],NULL); returns {} instead of {NULL,NULL,NULL}