File tree 4 files changed +30
-7
lines changed
4 files changed +30
-7
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.153 2009/01/30 21:21:18 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.154 2009/04/05 22:28:59 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1668,6 +1668,28 @@ array_length(PG_FUNCTION_ARGS)
1668
1668
PG_RETURN_INT32 (result );
1669
1669
}
1670
1670
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
+ int result ;
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
+
1671
1693
/*
1672
1694
* array_ref :
1673
1695
* This routine takes an array pointer and a subscript array and returns
Original file line number Diff line number Diff line change 37
37
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
38
38
* Portions Copyright (c) 1994, Regents of the University of California
39
39
*
40
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.527 2009/03/31 17:59:56 tgl Exp $
40
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.528 2009/04/05 22:28:59 tgl Exp $
41
41
*
42
42
*-------------------------------------------------------------------------
43
43
*/
53
53
*/
54
54
55
55
/* yyyymmddN */
56
- #define CATALOG_VERSION_NO 200903311
56
+ #define CATALOG_VERSION_NO 200904051
57
57
58
58
#endif
Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.539 2009/03/25 22:19:02 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.540 2009/04/05 22:28:59 tgl Exp $
11
11
*
12
12
* NOTES
13
13
* The script catalog/genbki.sh reads this file and generates .bki
@@ -1005,8 +1005,8 @@ DATA(insert OID = 2092 ( array_upper PGNSP PGUID 12 1 0 0 f f f t f i 2 0 23
1005
1005
DESCR ("array upper dimension" );
1006
1006
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_ ));
1007
1007
DESCR ("array length" );
1008
- DATA (insert OID = 2179 ( cardinality PGNSP PGUID 14 1 0 0 f f f t f i 1 0 23 "2277" _null_ _null_ _null_ _null_ "select pg_catalog.array_length($1, 1)" _null_ _null_ _null_ ));
1009
- DESCR ("array length " );
1008
+ 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_ ));
1009
+ DESCR ("array cardinality " );
1010
1010
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_ ));
1011
1011
DESCR ("append element onto end of array" );
1012
1012
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_ ));
Original file line number Diff line number Diff line change 49
49
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
50
50
* Portions Copyright (c) 1994, Regents of the University of California
51
51
*
52
- * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.74 2009/01/01 17:24:02 momjian Exp $
52
+ * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.75 2009/04/05 22:28:59 tgl Exp $
53
53
*
54
54
*-------------------------------------------------------------------------
55
55
*/
@@ -200,6 +200,7 @@ extern Datum array_dims(PG_FUNCTION_ARGS);
200
200
extern Datum array_lower (PG_FUNCTION_ARGS );
201
201
extern Datum array_upper (PG_FUNCTION_ARGS );
202
202
extern Datum array_length (PG_FUNCTION_ARGS );
203
+ extern Datum array_cardinality (PG_FUNCTION_ARGS );
203
204
extern Datum array_larger (PG_FUNCTION_ARGS );
204
205
extern Datum array_smaller (PG_FUNCTION_ARGS );
205
206
extern Datum generate_subscripts (PG_FUNCTION_ARGS );
You can’t perform that action at this time.
0 commit comments