Skip to content

Commit b27679a

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 fce3a71 commit b27679a

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
@@ -699,6 +699,20 @@ SELECT mleast(VARIADIC ARRAY[10, -1, 5, 4.4]);
699699
actual argument of a function call.
700700
</para>
701701

702+
<para>
703+
Specifying <literal>VARIADIC</> in the call is also the only way to
704+
pass an empty array to a variadic function, for example:
705+
706+
<screen>
707+
SELECT mleast(VARIADIC ARRAY[]::numeric[]);
708+
</screen>
709+
710+
Simply writing <literal>SELECT mleast()</> does not work because a
711+
variadic parameter must match at least one actual argument.
712+
(You could define a second function also named <literal>mleast</>,
713+
with no parameters, if you wanted to allow such calls.)
714+
</para>
715+
702716
<para>
703717
The array element parameters generated from a variadic parameter are
704718
treated as not having any names of their own. This means it is not

0 commit comments

Comments
 (0)