1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

ADD array_ndims function

Author: Robert Haas <robertmhaas@gmail.com>
This commit is contained in:
Peter Eisentraut
2008-11-04 14:49:12 +00:00
parent 9beb9e761b
commit 254aecb704
7 changed files with 47 additions and 6 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.147 2008/07/21 04:47:00 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.148 2008/11/04 14:49:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -1530,6 +1530,22 @@ array_send(PG_FUNCTION_ARGS)
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
/*
* array_ndims :
* returns the number of dimensions of the array pointed to by "v"
*/
Datum
array_ndims(PG_FUNCTION_ARGS)
{
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
/* Sanity check: does it look like an array at all? */
if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM)
PG_RETURN_NULL();
PG_RETURN_INT32(ARR_NDIM(v));
}
/*
* array_dims :
* returns the dimensions of the array pointed to by "v", as a "text"