Re: array_length(anyarray) - Mailing list pgsql-hackers

From Marko Tiikkaja
Subject Re: array_length(anyarray)
Date
Msg-id 52B21420.9090801@joh.to
Whole thread Raw
In response to Re: array_length(anyarray)  (Marko Tiikkaja <marko@joh.to>)
List pgsql-hackers
On 2013-12-18 22:19, I wrote:
> On 2013-12-18 22:13, Andrew Dunstan wrote:
>> On 12/18/2013 03:27 PM, Marko Tiikkaja wrote:
>>> Attached is a patch to add support for array_length(anyarray), which
>>> only works for one-dimensional arrays, returns 0 for empty arrays and
>>> complains if the array's lower bound isn't 1.  In other words, does
>>> the right thing when used with the arrays people use 99% of the time.
>>
>> Why the heck would it complain if the lower bound isn't 1?
>
> Because then you're free to assume that the first element is [1] and the
> last one is [array_length()].  Which is what 99% of the code using
> array_length(anyarray, int) does anyway.

Just to clarify, I mean that array_lower(.., 1) must be 1.  Whatever 
that's called.  "The lower bound of the only dimension of the array"?


Regards,
Marko Tiikkaja



pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: array_length(anyarray)
Next
From: Andrew Dunstan
Date:
Subject: Re: array_length(anyarray)