Lists: | pgsql-general |
---|
From: | John R Pierce <pierce(at)hogranch(dot)com> |
---|---|
To: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | array_length of an empty array |
Date: | 2012-07-29 08:03:04 |
Message-ID: | 5014EE38.30202@hogranch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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
From: | Ryan Kelly <rpkelly22(at)gmail(dot)com> |
---|---|
To: | John R Pierce <pierce(at)hogranch(dot)com> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: array_length of an empty array |
Date: | 2012-07-29 13:55:57 |
Message-ID: | 20120729135557.GA3145@llserver.lakeliving.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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 <empty specification> specifies a collection whose cardinality
> is zero.
-Ryan Kelly
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | John R Pierce <pierce(at)hogranch(dot)com> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: array_length of an empty array |
Date: | 2012-07-29 15:10:01 |
Message-ID: | 21633.1343574601@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
John R Pierce <pierce(at)hogranch(dot)com> 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