pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Wolfgang Walther <walther@technowledgy.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Calling variadic function with default value in named notation
Date: Wed, 28 Oct 2020 17:18:19 -0400
Message-ID: <1449498.1603919899@sss.pgh.pa.us> (raw)
In-Reply-To: <5a80bcdb-e92a-5c21-d923-f3813543771b@technowledgy.de>
References: <5a80bcdb-e92a-5c21-d923-f3813543771b@technowledgy.de>

Wolfgang Walther <walther@technowledgy.de> writes:
> create function b(x int, variadic y int[] default '{}')
> returns void language sql as '';

> select b(x=>1, variadic y=>'{2}');
> [ ok ]

> select b(x=>1);
> ERROR: function b(x => integer) does not exist

> I could not find anything in the documentation that points this out as a 
> limitation, so I expected this to work. Did I miss anything?

You can't write positional arguments after named arguments, so the
failure to match isn't all that surprising; that is, to accept this
call we'd have to interpret it as a named argument and then an empty
list of things to match positionally to the variadic parameter.
Perhaps a better error message could be wished for, but given the
current rules this can't succeed.

One could imagine saying that if the function has a variadic last
parameter, then we can match that to zero or more positional arguments
after the last named argument.  Not sure that that would be a good
idea though, or how hard it'd be to implement.  It'd be a pretty
radical departure from the rules for non-variadic functions.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <1449498.1603919899@sss.pgh.pa.us>
Permalink:  ../1449498.1603919899@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1449498.1603919899@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, walther@technowledgy.de, pgsql-bugs@lists.postgresql.org
  Subject: Re: Calling variadic function with default value in named notation
  In-Reply-To: <1449498.1603919899@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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