Re: cardinality()

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Subject: Re: cardinality()
Date: 2009-03-01 21:50:02
Message-ID: 200903012350.03474.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sunday 01 March 2009 19:40:16 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,

The standard represents multidimensional arrays as arrays of arrays (like in
C). But the cardinality is only that of the first level array.

The real question here is how we want to consider mapping what the standard
has to what PostgreSQL has, and might have in the future. For example, will
we ever have arrays of arrays as distinct from multidimensional arrays? Will
we support things like array of multiset of array? What would the results be
there?

I think PostgreSQL multidimensional array support and SQL standard
multidimensional array support are pretty well in line leaving aside minor
syntax issues and the major syntax issue that the subscript order is
reversed. So I think there is not much of a need to do much redefining and
reinterpreting, unless someone has a larger and different plan in mind.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sushant Sinha 2009-03-01 22:21:26 patch for space around the FragmentDelimiter
Previous Message Pavel Stehule 2009-03-01 21:49:58 WIP: named and mixed notation support