diff options
author | Bruce Momjian <bruce@momjian.us> | 2022-07-08 20:23:35 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2022-07-08 20:23:35 -0400 |
commit | 2373fe78dfc9d4aa2348a86fffdf8eb9d757e9d5 (patch) | |
tree | 26562b68ccf8cf90cf3507c30e9598b9fb3b20ae | |
parent | aa31b29375b9afbe1330d7726855645ff82a2e51 (diff) |
doc: add examples for array_length() and jsonb_array_length()
The examples show the output of array_length() and jsonb_array_length()
for empty arrays.
Discussion: https://postgr.es/m/CAKFQuwaoBmRuWdMLzLHDCFDJDX3wvfQ7egAF0bpik_BFgG1KWg@mail.gmail.com
Author: David G. Johnston
Backpatch-through: 13
-rw-r--r-- | doc/src/sgml/func.sgml | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 1705b0b4eac..b6783b7ad08 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -15867,6 +15867,10 @@ table2-mapping <para> <literal>json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]')</literal> <returnvalue>5</returnvalue> + </para> + <para> + <literal>jsonb_array_length('[]')</literal> + <returnvalue>0</returnvalue> </para></entry> </row> @@ -19238,10 +19242,19 @@ SELECT NULLIF(value, '(none)') ... </para> <para> Returns the length of the requested array dimension. + (Produces NULL instead of 0 for empty or missing array dimensions.) </para> <para> <literal>array_length(array[1,2,3], 1)</literal> <returnvalue>3</returnvalue> + </para> + <para> + <literal>array_length(array[]::int[], 1)</literal> + <returnvalue>NULL</returnvalue> + </para> + <para> + <literal>array_length(array['text'], 2)</literal> + <returnvalue>NULL</returnvalue> </para></entry> </row> |