postgres.git / summary / log / commit / refs

commit    ee56e14bbb6f3593e79c1d7e22b02bbc6df4b500
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sun Dec 21 20:30:39 2014 +0000
First released in: 9.5.0, 9.0.19, 9.1.15, 9.2.10, 9.3.6, 9.4.1

    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.


doc/src/sgml/xfunc.sgml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index e2b10703ee9..66e752c3928 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -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 [parent: b71e37c88354]