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

From Marko Tiikkaja
Subject Re: array_length(anyarray)
Date
Msg-id 52DBBA5C.3030307@joh.to
Whole thread Raw
In response to Re: array_length(anyarray)  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: array_length(anyarray)
Re: array_length(anyarray)
List pgsql-hackers

On 1/19/14, 9:12 AM, Dean Rasheed wrote:
> On 18 January 2014 03:07, Marko Tiikkaja <marko@joh.to> wrote:
>> Here's the patch as promised.  Thoughts?
>>
>
> A couple of points:
>
> The answer for empty (zero dimensional) arrays is wrong --- you need
> special case handling for this case to return 0.

How embarrassing.  I don't know why I removed that check or how I didn't
catch the clearly wrong answer in the test output.

> In fact why not
> simply use ArrayGetNItems()?

Even better.  Changed.

> In the docs, in the table of array functions, I think it would
> probably be useful to make the entry for array_length say "see also
> cardinality", otherwise people might just stop reading there. I
> suspect that in over 90% of cases, cardinality will be the more
> appropriate function to use rather than array_length.

I don't see this as a huge improvement, but even worse, I don't see a
way to naturally fit it into the description.


New version attached, without the doc change.


Regards,
Marko Tiikkaja

Attachment

pgsql-hackers by date:

Previous
From: Emre Hasegeli
Date:
Subject: Re: GiST support for inet datatypes
Next
From: David Rowley
Date:
Subject: Re: [PATCH] Negative Transition Aggregate Functions (WIP)