diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2008-11-04 14:49:12 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2008-11-04 14:49:12 +0000 |
commit | 254aecb7047579a0de21181823bf8d52343e61ca (patch) | |
tree | b518bc56b3463916f5de4b737ec9555eecba03dd /src/backend/utils/adt | |
parent | 9beb9e761bb6159293301ba82048e8bc047fe5e7 (diff) | |
download | postgresql-254aecb7047579a0de21181823bf8d52343e61ca.tar.gz |
ADD array_ndims function
Author: Robert Haas <robertmhaas@gmail.com>
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 5f3356f560..97dc3dc6c8 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -1531,6 +1531,22 @@ array_send(PG_FUNCTION_ARGS) } /* + * 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" */ |