mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Remove SQL-compatibility function cardinality(). It is not exactly clear
how this ought to behave for multi-dimensional arrays. Per discussion, not having it at all seems better than having it with what might prove to be the wrong behavior. We can always add it later when we have consensus on the correct behavior.
This commit is contained in:
parent
78f58f0f70
commit
06e2757277
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.475 2009/04/07 00:31:25 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.476 2009/04/09 17:39:47 tgl Exp $ -->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions and Operators</title>
|
||||
@ -9368,9 +9368,6 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<indexterm>
|
||||
<primary>array_upper</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>cardinality</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>string_to_array</primary>
|
||||
</indexterm>
|
||||
@ -9503,19 +9500,6 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<entry><literal>array_upper(ARRAY[1,2,3,4], 1)</literal></entry>
|
||||
<entry><literal>4</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>
|
||||
<function>cardinality</function>(<type>anyarray</type>)
|
||||
</literal>
|
||||
</entry>
|
||||
<entry><type>int</type></entry>
|
||||
<entry>returns the length of the first dimension of the array
|
||||
(special case of <function>array_length</function> for SQL
|
||||
compatibility)</entry>
|
||||
<entry><literal>cardinality(array[1,2,3])</literal></entry>
|
||||
<entry><literal>3</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.624 2009/04/07 21:30:01 momjian Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.625 2009/04/09 17:39:47 tgl Exp $ -->
|
||||
<!--
|
||||
|
||||
Typical markup:
|
||||
@ -1624,11 +1624,6 @@ do it for earlier branch release files.
|
||||
of an array for the specified dimensions (Jim Nasby, Robert
|
||||
Haas, Peter Eisentraut)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Also add identically-functioning <acronym>SQL</>-standard
|
||||
function <function>cardinality()</>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.154 2009/04/05 22:28:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.155 2009/04/09 17:39:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1668,28 +1668,6 @@ array_length(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* array_cardinality :
|
||||
* SQL-spec alias for array_length(v, 1)
|
||||
*/
|
||||
Datum
|
||||
array_cardinality(PG_FUNCTION_ARGS)
|
||||
{
|
||||
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
|
||||
int *dimv;
|
||||
int result;
|
||||
|
||||
/* Sanity check: does it look like an array at all? */
|
||||
if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
dimv = ARR_DIMS(v);
|
||||
|
||||
result = dimv[0];
|
||||
|
||||
PG_RETURN_INT32(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* array_ref :
|
||||
* This routine takes an array pointer and a subscript array and returns
|
||||
|
@ -37,7 +37,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.529 2009/04/07 00:31:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.530 2009/04/09 17:39:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 200904061
|
||||
#define CATALOG_VERSION_NO 200904091
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.541 2009/04/07 00:31:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.542 2009/04/09 17:39:48 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The script catalog/genbki.sh reads this file and generates .bki
|
||||
@ -1005,8 +1005,6 @@ DATA(insert OID = 2092 ( array_upper PGNSP PGUID 12 1 0 0 f f f t f i 2 0 23
|
||||
DESCR("array upper dimension");
|
||||
DATA(insert OID = 2176 ( array_length PGNSP PGUID 12 1 0 0 f f f t f i 2 0 23 "2277 23" _null_ _null_ _null_ _null_ array_length _null_ _null_ _null_ ));
|
||||
DESCR("array length");
|
||||
DATA(insert OID = 2179 ( cardinality PGNSP PGUID 12 1 0 0 f f f t f i 1 0 23 "2277" _null_ _null_ _null_ _null_ array_cardinality _null_ _null_ _null_ ));
|
||||
DESCR("array cardinality");
|
||||
DATA(insert OID = 378 ( array_append PGNSP PGUID 12 1 0 0 f f f f f i 2 0 2277 "2277 2283" _null_ _null_ _null_ _null_ array_push _null_ _null_ _null_ ));
|
||||
DESCR("append element onto end of array");
|
||||
DATA(insert OID = 379 ( array_prepend PGNSP PGUID 12 1 0 0 f f f f f i 2 0 2277 "2283 2277" _null_ _null_ _null_ _null_ array_push _null_ _null_ _null_ ));
|
||||
|
@ -49,7 +49,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.75 2009/04/05 22:28:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.76 2009/04/09 17:39:50 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -200,7 +200,6 @@ extern Datum array_dims(PG_FUNCTION_ARGS);
|
||||
extern Datum array_lower(PG_FUNCTION_ARGS);
|
||||
extern Datum array_upper(PG_FUNCTION_ARGS);
|
||||
extern Datum array_length(PG_FUNCTION_ARGS);
|
||||
extern Datum array_cardinality(PG_FUNCTION_ARGS);
|
||||
extern Datum array_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum array_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum generate_subscripts(PG_FUNCTION_ARGS);
|
||||
|
@ -1105,26 +1105,6 @@ select array_length(array[[1,2,3], [4,5,6]], 3);
|
||||
|
||||
(1 row)
|
||||
|
||||
select cardinality(array[1,2,3]);
|
||||
cardinality
|
||||
-------------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
select cardinality(array[[1,2,3], [4,5,6]]);
|
||||
cardinality
|
||||
-------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
select c, cardinality(c), d, cardinality(d) from arrtest;
|
||||
c | cardinality | d | cardinality
|
||||
-------------------+-------------+---------------+-------------
|
||||
{} | | {} |
|
||||
{foobar,new_word} | 2 | {{elt1,elt2}} | 1
|
||||
{foo,new_word} | 2 | {bar,foo} | 2
|
||||
(3 rows)
|
||||
|
||||
select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss;
|
||||
array_agg
|
||||
--------------------------------------
|
||||
@ -1143,12 +1123,6 @@ select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15
|
||||
{0,1,2,3,NULL,5,6,7,8,9,0,1,2,3,NULL}
|
||||
(1 row)
|
||||
|
||||
select cardinality(array_agg(unique1)) from tenk1 where unique1 < 15;
|
||||
cardinality
|
||||
-------------
|
||||
15
|
||||
(1 row)
|
||||
|
||||
select array_agg(unique1) from tenk1 where unique1 < -15;
|
||||
array_agg
|
||||
-----------
|
||||
|
@ -392,14 +392,10 @@ select array_length(array[[1,2,3], [4,5,6]], 0);
|
||||
select array_length(array[[1,2,3], [4,5,6]], 1);
|
||||
select array_length(array[[1,2,3], [4,5,6]], 2);
|
||||
select array_length(array[[1,2,3], [4,5,6]], 3);
|
||||
select cardinality(array[1,2,3]);
|
||||
select cardinality(array[[1,2,3], [4,5,6]]);
|
||||
select c, cardinality(c), d, cardinality(d) from arrtest;
|
||||
|
||||
select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss;
|
||||
select array_agg(ten) from (select ten from tenk1 where unique1 < 15 order by unique1) ss;
|
||||
select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15 order by unique1) ss;
|
||||
select cardinality(array_agg(unique1)) from tenk1 where unique1 < 15;
|
||||
select array_agg(unique1) from tenk1 where unique1 < -15;
|
||||
|
||||
select unnest(array[1,2,3]);
|
||||
|
Loading…
Reference in New Issue
Block a user