doc: add examples for array_length() and jsonb_array_length()
authorBruce Momjian
Sat, 9 Jul 2022 00:23:34 +0000 (20:23 -0400)
committerBruce Momjian
Sat, 9 Jul 2022 00:23:34 +0000 (20:23 -0400)
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

doc/src/sgml/func.sgml

index 98a6b264388826848710fd88da843bf7f58de6fa..560b6d7d33501f24d3a2dba74876cbba4ffc5306 100644 (file)
@@ -15261,6 +15261,10 @@ table2-mapping
        
         json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]')
         5
+       
+       
+        jsonb_array_length('[]')
+        0
        
       
 
@@ -17756,10 +17760,19 @@ SELECT NULLIF(value, '(none)') ...
        
        
         Returns the length of the requested array dimension.
+        (Produces NULL instead of 0 for empty or missing array dimensions.)
        
        
         array_length(array[1,2,3], 1)
         3
+       
+       
+        array_length(array[]::int[], 1)
+        NULL
+       
+       
+        array_length(array['text'], 2)
+        NULL