Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06e2757

Browse files
committed
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 proveto be the wrong behavior. We can always add it later when we have consensuson the correct behavior.
1 parent78f58f0 commit06e2757

File tree

8 files changed

+7
-83
lines changed

8 files changed

+7
-83
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.475 2009/04/07 00:31:25 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.476 2009/04/09 17:39:47 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -9368,9 +9368,6 @@ SELECT NULLIF(value, '(none)') ...
93689368
<indexterm>
93699369
<primary>array_upper</primary>
93709370
</indexterm>
9371-
<indexterm>
9372-
<primary>cardinality</primary>
9373-
</indexterm>
93749371
<indexterm>
93759372
<primary>string_to_array</primary>
93769373
</indexterm>
@@ -9503,19 +9500,6 @@ SELECT NULLIF(value, '(none)') ...
95039500
<entry><literal>array_upper(ARRAY[1,2,3,4], 1)</literal></entry>
95049501
<entry><literal>4</literal></entry>
95059502
</row>
9506-
<row>
9507-
<entry>
9508-
<literal>
9509-
<function>cardinality</function>(<type>anyarray</type>)
9510-
</literal>
9511-
</entry>
9512-
<entry><type>int</type></entry>
9513-
<entry>returns the length of the first dimension of the array
9514-
(special case of <function>array_length</function> for SQL
9515-
compatibility)</entry>
9516-
<entry><literal>cardinality(array[1,2,3])</literal></entry>
9517-
<entry><literal>3</literal></entry>
9518-
</row>
95199503
<row>
95209504
<entry>
95219505
<literal>

‎doc/src/sgml/release.sgml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.624 2009/04/07 21:30:01 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.625 2009/04/09 17:39:47 tgl Exp $ -->
22
<!--
33

44
Typical markup:
@@ -1624,11 +1624,6 @@ do it for earlier branch release files.
16241624
of an array for the specified dimensions (Jim Nasby, Robert
16251625
Haas, Peter Eisentraut)
16261626
</para>
1627-
1628-
<para>
1629-
Also add identically-functioning <acronym>SQL</>-standard
1630-
function <function>cardinality()</>.
1631-
</para>
16321627
</listitem>
16331628

16341629
<listitem>

‎src/backend/utils/adt/arrayfuncs.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.154 2009/04/05 22:28:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.155 2009/04/09 17:39:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1668,28 +1668,6 @@ array_length(PG_FUNCTION_ARGS)
16681668
PG_RETURN_INT32(result);
16691669
}
16701670

1671-
/*
1672-
* array_cardinality :
1673-
*SQL-spec alias for array_length(v, 1)
1674-
*/
1675-
Datum
1676-
array_cardinality(PG_FUNCTION_ARGS)
1677-
{
1678-
ArrayType*v=PG_GETARG_ARRAYTYPE_P(0);
1679-
int*dimv;
1680-
intresult;
1681-
1682-
/* Sanity check: does it look like an array at all? */
1683-
if (ARR_NDIM(v) <=0||ARR_NDIM(v)>MAXDIM)
1684-
PG_RETURN_NULL();
1685-
1686-
dimv=ARR_DIMS(v);
1687-
1688-
result=dimv[0];
1689-
1690-
PG_RETURN_INT32(result);
1691-
}
1692-
16931671
/*
16941672
* array_ref :
16951673
* This routine takes an array pointer and a subscript array and returns

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.529 2009/04/07 00:31:26 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.530 2009/04/09 17:39:48 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200904061
56+
#defineCATALOG_VERSION_NO200904091
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.541 2009/04/07 00:31:26 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.542 2009/04/09 17:39:48 tgl Exp $
1111
*
1212
* NOTES
1313
* 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
10051005
DESCR("array upper dimension");
10061006
DATA(insertOID=2176 (array_lengthPGNSPPGUID12100ffftfi2023"2277 23"_null__null__null__null_array_length_null__null__null_ ));
10071007
DESCR("array length");
1008-
DATA(insertOID=2179 (cardinalityPGNSPPGUID12100ffftfi1023"2277"_null__null__null__null_array_cardinality_null__null__null_ ));
1009-
DESCR("array cardinality");
10101008
DATA(insertOID=378 (array_appendPGNSPPGUID12100fffffi202277"2277 2283"_null__null__null__null_array_push_null__null__null_ ));
10111009
DESCR("append element onto end of array");
10121010
DATA(insertOID=379 (array_prependPGNSPPGUID12100fffffi202277"2283 2277"_null__null__null__null_array_push_null__null__null_ ));

‎src/include/utils/array.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
5050
* Portions Copyright (c) 1994, Regents of the University of California
5151
*
52-
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.75 2009/04/05 22:28:59 tgl Exp $
52+
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.76 2009/04/09 17:39:50 tgl Exp $
5353
*
5454
*-------------------------------------------------------------------------
5555
*/
@@ -200,7 +200,6 @@ extern Datum array_dims(PG_FUNCTION_ARGS);
200200
externDatumarray_lower(PG_FUNCTION_ARGS);
201201
externDatumarray_upper(PG_FUNCTION_ARGS);
202202
externDatumarray_length(PG_FUNCTION_ARGS);
203-
externDatumarray_cardinality(PG_FUNCTION_ARGS);
204203
externDatumarray_larger(PG_FUNCTION_ARGS);
205204
externDatumarray_smaller(PG_FUNCTION_ARGS);
206205
externDatumgenerate_subscripts(PG_FUNCTION_ARGS);

‎src/test/regress/expected/arrays.out

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,26 +1105,6 @@ select array_length(array[[1,2,3], [4,5,6]], 3);
11051105

11061106
(1 row)
11071107

1108-
select cardinality(array[1,2,3]);
1109-
cardinality
1110-
-------------
1111-
3
1112-
(1 row)
1113-
1114-
select cardinality(array[[1,2,3], [4,5,6]]);
1115-
cardinality
1116-
-------------
1117-
2
1118-
(1 row)
1119-
1120-
select c, cardinality(c), d, cardinality(d) from arrtest;
1121-
c | cardinality | d | cardinality
1122-
-------------------+-------------+---------------+-------------
1123-
{} | | {} |
1124-
{foobar,new_word} | 2 | {{elt1,elt2}} | 1
1125-
{foo,new_word} | 2 | {bar,foo} | 2
1126-
(3 rows)
1127-
11281108
select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss;
11291109
array_agg
11301110
--------------------------------------
@@ -1143,12 +1123,6 @@ select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15
11431123
{0,1,2,3,NULL,5,6,7,8,9,0,1,2,3,NULL}
11441124
(1 row)
11451125

1146-
select cardinality(array_agg(unique1)) from tenk1 where unique1 < 15;
1147-
cardinality
1148-
-------------
1149-
15
1150-
(1 row)
1151-
11521126
select array_agg(unique1) from tenk1 where unique1 < -15;
11531127
array_agg
11541128
-----------

‎src/test/regress/sql/arrays.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,10 @@ select array_length(array[[1,2,3], [4,5,6]], 0);
392392
select array_length(array[[1,2,3], [4,5,6]],1);
393393
select array_length(array[[1,2,3], [4,5,6]],2);
394394
select array_length(array[[1,2,3], [4,5,6]],3);
395-
select cardinality(array[1,2,3]);
396-
select cardinality(array[[1,2,3], [4,5,6]]);
397-
select c, cardinality(c), d, cardinality(d)from arrtest;
398395

399396
select array_agg(unique1)from (select unique1from tenk1where unique1<15order by unique1) ss;
400397
select array_agg(ten)from (select tenfrom tenk1where unique1<15order by unique1) ss;
401398
select array_agg(nullif(ten,4))from (select tenfrom tenk1where unique1<15order by unique1) ss;
402-
select cardinality(array_agg(unique1))from tenk1where unique1<15;
403399
select array_agg(unique1)from tenk1where unique1<-15;
404400

405401
select unnest(array[1,2,3]);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp