Re: array_length(anyarray)

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, PostGreSql hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_length(anyarray)
Date: 2014-01-12 04:53:14
Message-ID: 52D21FBA.4000501@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2014-01-12 05:32:55 have to do move ready for commit patch from previous commitfest?
Previous Message Amit Kapila 2014-01-12 04:52:33 Re: Standalone synchronous master