Re: cardinality() - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: cardinality()
Date
Msg-id 200903012350.03474.peter_e@gmx.net
Whole thread Raw
In response to Re: cardinality()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: cardinality()  (Gregory Stark <stark@enterprisedb.com>)
List 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.


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: WIP: named and mixed notation support
Next
From: Sushant Sinha
Date:
Subject: patch for space around the FragmentDelimiter