About the behavior of array_length() for empty array - Mailing list pgsql-hackers

From iihero
Subject About the behavior of array_length() for empty array
Date
Msg-id tencent_5D502954744B7F744ED6F34E@qq.com
Whole thread Raw
Responses Re: About the behavior of array_length() for empty array  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers

postgres=# select '{}'::integer[] = array[[]]::integer[][];
 ?column?
----------
 t
postgres=# select '{}'::integer[] = array[[[]]]::integer[][][];
 ?column?
----------
 t
From this point of view, seems N dimensions of empty array all are equivalent.

But the result of array_length of them always are null.

postgres=# select array_length('{}'::integer[],0);
 array_length
--------------

postgres=# select array_length(array[[[]]]::integer[][][],0);
 array_length
--------------
postgres=# select array_length(array[[[]]]::integer[][][],3) is null;
 ?column?
----------
 t

I just think any "empty" array length should return 0, but not null.  It's not a NULL array.

Is there standard definition of this behavior? 

------------------
----------------------------------------------------------
iihero(Xiong He)  http://www.sql9.com
----------------------------------------------------------

 

pgsql-hackers by date:

Previous
From: Thom Brown
Date:
Subject: Re: System catalog typos
Next
From: Robert Haas
Date:
Subject: Re: parallel dump/restore code on WIndows