| From: | iihero <iihero(at)qq(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | About the behavior of array_length() for empty array |
| Date: | 2012-04-06 00:35:40 |
| Message-ID: | tencent_5D502954744B7F744ED6F34E@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
----------------------------------------------------------
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2012-04-06 01:24:35 | Re: BUG #6522: PostgreSQL does not start |
| Previous Message | Thom Brown | 2012-04-06 00:24:00 | Re: System catalog typos |