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

From Florian Pflug
Subject Re: array_length(anyarray)
Date
Msg-id 938B40F2-5CB2-4740-A557-532E1090AC2E@phlo.org
Whole thread Raw
In response to Re: array_length(anyarray)  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: array_length(anyarray)  (Marko Tiikkaja <marko@joh.to>)
List pgsql-hackers
On Jan9, 2014, at 14:57 , Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> On 19 December 2013 08:05, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> length should be irrelevant to fact so array starts from 1, 0 or anything
>> else
>
> Yes, this should just return the number of elements, and 0 for an empty array.

+1. Anything that complains about arrays whose lower bound isn't 1 really
needs a *way* less generic name than array_length().

>
> How it should behave for multi-dimensional arrays is less clear, but
> I'd argue that it should return the total number of elements, i.e.
> cardinality('{{1,2},{3,4}}'::int[][]) = 4. That would make it
> consistent with the choices we've already made for unnest() and
> ordinality:
> - cardinality(foo) = (select count(*) from unnest(foo)).
> - unnest with ordinality would always result in ordinals in the range
> [1, cardinality].

+1

best regards,
Florian Pflug






pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Next
From: Robert Haas
Date:
Subject: Re: