Re: cardinality() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: cardinality()
Date
Msg-id 13073.1235929216@sss.pgh.pa.us
Whole thread Raw
In response to Re: cardinality()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: cardinality()  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: cardinality()  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: cardinality()  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
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.
So I think Andrew is right and we need to fix our implementation of
cardinality() while we still can.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: cardinality()
Next
From: Pavel Stehule
Date:
Subject: Re: cardinality()