Re: array_length(anyarray)

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, PostGreSql hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_length(anyarray)
Date: 2014-01-19 11:43:24
Message-ID: 52DBBA5C.3030307@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/19/14, 9:12 AM, Dean Rasheed wrote:
> On 18 January 2014 03:07, Marko Tiikkaja <marko(at)joh(dot)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 Content-Type Size
cardinality_v4.patch text/plain 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2014-01-19 12:04:40 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message Emre Hasegeli 2014-01-19 10:10:12 Re: GiST support for inet datatypes