Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
254aecb7
Commit
254aecb7
authored
Nov 04, 2008
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD array_ndims function
Author: Robert Haas <robertmhaas@gmail.com>
parent
9beb9e76
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
6 deletions
+47
-6
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+12
-1
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/arrayfuncs.c
+17
-1
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+2
-1
src/include/utils/array.h
src/include/utils/array.h
+2
-1
src/test/regress/expected/arrays.out
src/test/regress/expected/arrays.out
+9
-0
src/test/regress/sql/arrays.sql
src/test/regress/sql/arrays.sql
+3
-0
No files found.
doc/src/sgml/func.sgml
View file @
254aecb7
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.45
4 2008/11/04 00:59:45 momjian
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.45
5 2008/11/04 14:49:11 petere
Exp $ -->
<chapter
id=
"functions"
>
<title>
Functions and Operators
</title>
...
...
@@ -9373,6 +9373,17 @@ SELECT NULLIF(value, '(none)') ...
<entry><literal>
array_cat(ARRAY[1,2,3], ARRAY[4,5])
</literal></entry>
<entry><literal>
{1,2,3,4,5}
</literal></entry>
</row>
<row>
<entry>
<literal>
<function>
array_ndims
</function>
(
<type>
anyarray
</type>
)
</literal>
</entry>
<entry><type>
int
</type></entry>
<entry>
returns the number of dimensions of the array
</entry>
<entry><literal>
array_ndims(ARRAY[[1,2,3], [4,5,6]])
</literal></entry>
<entry><literal>
2
</literal></entry>
</row>
<row>
<entry>
<literal>
...
...
src/backend/utils/adt/arrayfuncs.c
View file @
254aecb7
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.14
7 2008/07/21 04:47:00 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.14
8 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"
...
...
src/include/catalog/catversion.h
View file @
254aecb7
...
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.50
1 2008/11/03 17:51:13 tgl
Exp $
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.50
2 2008/11/04 14:49:11 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 2008110
3
1
#define CATALOG_VERSION_NO 2008110
4
1
#endif
src/include/catalog/pg_proc.h
View file @
254aecb7
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.52
3 2008/11/03 21:09:17 tgl
Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.52
4 2008/11/04 14:49:11 petere
Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -985,6 +985,7 @@ DATA(insert OID = 393 ( array_le PGNSP PGUID 12 1 0 0 f f t f i 2 16 "2277
DESCR
(
"array less than or equal"
);
DATA
(
insert
OID
=
396
(
array_ge
PGNSP
PGUID
12
1
0
0
f
f
t
f
i
2
16
"2277 2277"
_null_
_null_
_null_
array_ge
_null_
_null_
_null_
));
DESCR
(
"array greater than or equal"
);
DATA
(
insert
OID
=
748
(
array_ndims
PGNSP
PGUID
12
1
0
0
f
f
t
f
i
1
23
"2277"
_null_
_null_
_null_
array_ndims
_null_
_null_
_null_
));
DATA
(
insert
OID
=
747
(
array_dims
PGNSP
PGUID
12
1
0
0
f
f
t
f
i
1
25
"2277"
_null_
_null_
_null_
array_dims
_null_
_null_
_null_
));
DESCR
(
"array dimensions"
);
DATA
(
insert
OID
=
750
(
array_in
PGNSP
PGUID
12
1
0
0
f
f
t
f
s
3
2277
"2275 26 23"
_null_
_null_
_null_
array_in
_null_
_null_
_null_
));
...
...
src/include/utils/array.h
View file @
254aecb7
...
...
@@ -49,7 +49,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.6
8 2008/07/16 00:48:54 momjian
Exp $
* $PostgreSQL: pgsql/src/include/utils/array.h,v 1.6
9 2008/11/04 14:49:12 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -195,6 +195,7 @@ extern Datum btarraycmp(PG_FUNCTION_ARGS);
extern
Datum
arrayoverlap
(
PG_FUNCTION_ARGS
);
extern
Datum
arraycontains
(
PG_FUNCTION_ARGS
);
extern
Datum
arraycontained
(
PG_FUNCTION_ARGS
);
extern
Datum
array_ndims
(
PG_FUNCTION_ARGS
);
extern
Datum
array_dims
(
PG_FUNCTION_ARGS
);
extern
Datum
array_lower
(
PG_FUNCTION_ARGS
);
extern
Datum
array_upper
(
PG_FUNCTION_ARGS
);
...
...
src/test/regress/expected/arrays.out
View file @
254aecb7
...
...
@@ -68,6 +68,15 @@ SELECT a[1:3],
{} | {} | {foo,bar} | {}
(3 rows)
SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c
FROM arrtest;
a | b | c
---+---+---
1 | 3 |
1 | 2 | 1
| 1 | 1
(3 rows)
SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c
FROM arrtest;
a | b | c
...
...
src/test/regress/sql/arrays.sql
View file @
254aecb7
...
...
@@ -53,6 +53,9 @@ SELECT a[1:3],
d
[
1
:
1
][
1
:
2
]
FROM
arrtest
;
SELECT
array_ndims
(
a
)
AS
a
,
array_ndims
(
b
)
AS
b
,
array_ndims
(
c
)
AS
c
FROM
arrtest
;
SELECT
array_dims
(
a
)
AS
a
,
array_dims
(
b
)
AS
b
,
array_dims
(
c
)
AS
c
FROM
arrtest
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment