array_length of an empty array

Поиск
Список
Период
Сортировка
Искать

array_length of an empty array

От:
John R Pierce <pierce@hogranch.com>
Дата:
hmmm.    array[]::integer[]    is an empty array, {}, eg an array with 
zero elements

but array_length(array[]::integer[])   is NULL rather than zero.    this 
seems counterintuitive.


-- 
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast

Re: array_length of an empty array

От:
Ryan Kelly <rpkelly22@gmail.com>
Дата:
On Sun, Jul 29, 2012 at 01:03:04AM -0700, John R Pierce wrote:
> hmmm.    array[]::integer[]    is an empty array, {}, eg an array
> with zero elements
> 
> but array_length(array[]::integer[])   is NULL rather than zero.
> this seems counterintuitive.

It also seems to disagree with the standard:
> 1) An  specifies a collection whose cardinality
> is zero.

-Ryan Kelly

Re: array_length of an empty array

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
John R Pierce  writes:
> hmmm.    array[]::integer[]    is an empty array, {}, eg an array with 
> zero elements

> but array_length(array[]::integer[])   is NULL rather than zero.    this 
> seems counterintuitive.

IIRC, there are a whole bunch of questionable behaviors around empty
arrays.  Somebody should go through the whole list of array-related
functions and come up with a coherent proposal for fixing all of them.

			regards, tom lane
FAQ