pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedAdd Optional Variadic Invocation Explanation to 35.4.5 (xfunc-sql)
2+ messages / 2 participants
[nested] [flat]
* Add Optional Variadic Invocation Explanation to 35.4.5 (xfunc-sql)
@ 2014-12-19 21:33 David Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: David Johnston @ 2014-12-19 21:33 UTC (permalink / raw)
To: pgsql-docs
CREATE FUNCTION varfunc (fixed1 text, VARIADIC vars text[]) [...]
SELECT varfunc('text fixed 1'); -- error: function signature not found;
thus the number of supplied variadic values must be >= 1
This:
http://www.postgresql.org/docs/9.4/static/xfunc-sql.html
Describes how to invoke a function defined with VARIADIC with an actual
array as input instead of supplying ONE-or-more individual arguments to the
call.
AFAICS the only way to get the called function to see an empty array is to
call it like:
SELECT varchar('text fixed 1', VARIADIC ARRAY[]::text[])
While this is a logical solution to the problem, given the above knowledge,
it would be nice if both points were made explicitly in the documentation
in the section linked above.
Existing: "Sometimes it is useful to be able to pass an already-constructed
array to a variadic function; this is particularly handy when one variadic
function wants to pass on its array parameter to another one."
Change that to:
"Sometimes it is useful to be able to pass an already-constructed array to
a variadic function."
<move existing sample to here>
"While this is particularly handy when one variadic function wants to pass
on its array parameter to another[/cut] it is required if you wish to
invoke the function without passing any optional arguments. The following
example's first attempt to omit the variadic argument fails since the
planner looks for a different function signature. By using the variadic
invocation the second attempt succeeds. The alternative is to define an
overloaded function without a VARIADIC parameter but with the same
non-optional ones."
<better example maybe...but show/explain the two queries above>
Thoughts? Am I missing something?
David J.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Add Optional Variadic Invocation Explanation to 35.4.5 (xfunc-sql)
@ 2014-12-21 20:35 Tom Lane <tgl@sss.pgh.pa.us>
parent: David Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2014-12-21 20:35 UTC (permalink / raw)
To: David Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-docs
David Johnston <david.g.johnston@gmail.com> writes:
> This:
> http://www.postgresql.org/docs/9.4/static/xfunc-sql.html
> Describes how to invoke a function defined with VARIADIC with an actual
> array as input instead of supplying ONE-or-more individual arguments to the
> call.
Right, and it does specifically say that there must be at least one
actual argument matching the VARIADIC parameter. Still, an example
to clarify that isn't a bad idea.
> AFAICS the only way to get the called function to see an empty array is to
> call it like:
> SELECT varchar('text fixed 1', VARIADIC ARRAY[]::text[])
> While this is a logical solution to the problem, given the above knowledge,
> it would be nice if both points were made explicitly in the documentation
> in the section linked above.
I did not like your proposed wording, as it seemed to complicate matters
unduly by treating two independent points in the same para. I went with
just adding a separate para instead:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=699300a146c04e207a8fdec407538cdf53...
regards, tom lane
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-12-21 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19 21:33 Add Optional Variadic Invocation Explanation to 35.4.5 (xfunc-sql) David Johnston <david.g.johnston@gmail.com>
2014-12-21 20:35 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox