Re: cardinality()

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: cardinality()
Date: 2009-03-01 18:23:19
Message-ID: 20090301095134.X96146@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 1 Mar 2009, Tom Lane wrote:

> I wrote:
> > The standard doesn't have multi-dimensional arrays, so it's entirely
> > possible that somewhere in it there is wording that makes cardinality()
> > equivalent to the length of the first dimension. But I concur with
> > Andrew that this is flat wrong when extended to m-d arrays.
>
> I poked around in the SQL:2008 draft a bit. AFAICT the most precise
> statement about cardinality() is in 6.27 <numeric value function>:
>
> <cardinality expression> ::=
> CARDINALITY<left paren> <collection value expression> <right paren>
>
> 7) The result of <cardinality expression> is the number of elements of
> the result of the <collection value expression>.
>
> Now the standard is only considering 1-D arrays, but I fail to see any
> way that it could be argued that the appropriate reading of "number of
> elements" for a multi-D array is the length of the first dimension.

Does the standard allow you to make arrays of arrays, for example with
something like ARRAY[ARRAY[1,2], ARRAY[3,4]]? If so, it might be possible
that cardinality(<that expression>) would be returning the number of
arrays in the outer array.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2009-03-01 21:49:58 WIP: named and mixed notation support
Previous Message Heikki Linnakangas 2009-03-01 17:52:51 Re: encoding conversion functions versus zero-length inputs