From 2f34a4428820d054184e73e048cde2f39c3475d1 Mon Sep 17 00:00:00 2001 From: tgl Date: Thu, 9 Apr 2009 17:39:50 +0000 Subject: [PATCH] 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. --- doc/src/sgml/func.sgml | 16 ---------------- doc/src/sgml/release.sgml | 5 ----- src/backend/utils/adt/arrayfuncs.c | 22 ---------------------- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.h | 2 -- src/include/utils/array.h | 1 - src/test/regress/expected/arrays.out | 26 -------------------------- src/test/regress/sql/arrays.sql | 4 ---- 8 files changed, 1 insertion(+), 77 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3075d510bc..67a69561c5 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -9369,9 +9369,6 @@ SELECT NULLIF(value, '(none)') ... array_upper - cardinality - - string_to_array @@ -9506,19 +9503,6 @@ SELECT NULLIF(value, '(none)') ... - cardinality(anyarray) - - - int - returns the length of the first dimension of the array - (special case of array_length for SQL - compatibility) - cardinality(array[1,2,3]) - 3 - - - - string_to_array(text, text) diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index 6102d91953..180a55873f 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1624,11 +1624,6 @@ do it for earlier branch release files. of an array for the specified dimensions (Jim Nasby, Robert Haas, Peter Eisentraut) - - - Also add identically-functioning SQL-standard - function cardinality(). - diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index b94eae228f..85f860a32a 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -1669,28 +1669,6 @@ array_length(PG_FUNCTION_ARGS) } /* - * 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 * the referenced item as a Datum. Note that for a pass-by-reference diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index cd9f52bc5a..9a3304bde3 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200904061 +#define CATALOG_VERSION_NO 200904091 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 28d3a52804..b6127e1a5c 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -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_ )); diff --git a/src/include/utils/array.h b/src/include/utils/array.h index d49c5f3ef3..24f8f32b65 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -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); diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index ec2fd52c7f..c7ddc2d7aa 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -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 ----------- diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index a4a91b034c..5e4933c31d 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -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]); -- 2.11.4.GIT