Skip to content

Commit acbcb32

Browse files
committed
Docs: clarify treatment of variadic functions with zero variadic arguments.
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.
1 parent f8c51fe commit acbcb32

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/src/sgml/xfunc.sgml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,20 @@ SELECT mleast(VARIADIC ARRAY[10, -1, 5, 4.4]);
739739
actual argument of a function call.
740740
</para>
741741

742+
<para>
743+
Specifying <literal>VARIADIC</> in the call is also the only way to
744+
pass an empty array to a variadic function, for example:
745+
746+
<screen>
747+
SELECT mleast(VARIADIC ARRAY[]::numeric[]);
748+
</screen>
749+
750+
Simply writing <literal>SELECT mleast()</> does not work because a
751+
variadic parameter must match at least one actual argument.
752+
(You could define a second function also named <literal>mleast</>,
753+
with no parameters, if you wanted to allow such calls.)
754+
</para>
755+
742756
<para>
743757
The array element parameters generated from a variadic parameter are
744758
treated as not having any names of their own. This means it is not

0 commit comments

Comments
 (0)