1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

array_length() function, and for SQL compatibility also cardinality()

function as a special case.

This version still has the suspicious behavior of returning null for an
empty array (rather than zero), but this may need a wholesale revision of
empty array behavior, currently under discussion.

Jim Nasby, Robert Haas, Peter Eisentraut
This commit is contained in:
Peter Eisentraut
2008-11-12 13:09:28 +00:00
parent 4c22564471
commit f98f6ee064
8 changed files with 135 additions and 7 deletions

View File

@ -386,3 +386,12 @@ select string_to_array('1|2|3', NULL);
select string_to_array(NULL, '|');
select array_to_string(string_to_array('1|2|3', '|'), '|');
select array_length(array[1,2,3], 1);
select array_length(array[[1,2,3], [4,5,6]], 0);
select array_length(array[[1,2,3], [4,5,6]], 1);
select array_length(array[[1,2,3], [4,5,6]], 2);
select array_length(array[[1,2,3], [4,5,6]], 3);
select cardinality(array[1,2,3]);
select cardinality(array[[1,2,3], [4,5,6]]);
select c, cardinality(c), d, cardinality(d) from arrtest;