Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Docs: clarify treatment of variadic functions with zero variadic arguments.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 21 Dec 2014 20:30:39 +0000 (15:30 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 21 Dec 2014 20:31:14 +0000 (15:31 -0500)
Explain that you have to use "VARIADIC ARRAY[]" to pass an empty array
to a variadic parameter position.  This was already implicit in the text
but it seems better to spell it out.

Per a suggestion from David Johnston, though I didn't use his proposed
wording.  Back-patch to all supported branches.

doc/src/sgml/xfunc.sgml

index 1515e649153789bfa962cacd73cc3386d156648f..ccafc9da24ff80c0b0f7df359b7ec28067b880c2 100644 (file)
@@ -739,6 +739,20 @@ SELECT mleast(VARIADIC ARRAY[10, -1, 5, 4.4]);
      actual argument of a function call.
     </para>
 
+    <para>
+     Specifying <literal>VARIADIC</> in the call is also the only way to
+     pass an empty array to a variadic function, for example:
+
+<screen>
+SELECT mleast(VARIADIC ARRAY[]::numeric[]);
+</screen>
+
+     Simply writing <literal>SELECT mleast()</> does not work because a
+     variadic parameter must match at least one actual argument.
+     (You could define a second function also named <literal>mleast</>,
+     with no parameters, if you wanted to allow such calls.)
+    </para>
+
     <para>
      The array element parameters generated from a variadic parameter are
      treated as not having any names of their own.  This means it is not