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

From Marko Tiikkaja
Subject Re: array_length(anyarray)
Date
Msg-id 52D21FBA.4000501@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/9/14, 2:57 PM, Dean Rasheed wrote:
> Yes, this should just return the number of elements, and 0 for an empty array.
>
> 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].

Ignoring my proposal, this seems like the most reasonable option.  I'll 
send an updated patch along these lines.


Regards,
Marko Tiikkaja



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Standalone synchronous master
Next
From: Pavel Stehule
Date:
Subject: have to do move ready for commit patch from previous commitfest?