Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXspt-000481-PZ for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2020 21:18:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXsps-0000Ru-Hj for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2020 21:18:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXsps-0000Rm-BW for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2020 21:18:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXspo-0007vk-6l for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2020 21:18:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09SLIJ8s1449499; Wed, 28 Oct 2020 17:18:19 -0400 From: Tom Lane To: Wolfgang Walther cc: pgsql-bugs@lists.postgresql.org Subject: Re: Calling variadic function with default value in named notation In-reply-to: <5a80bcdb-e92a-5c21-d923-f3813543771b@technowledgy.de> References: <5a80bcdb-e92a-5c21-d923-f3813543771b@technowledgy.de> Comments: In-reply-to Wolfgang Walther message dated "Wed, 28 Oct 2020 22:02:02 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1449497.1603919899.1@sss.pgh.pa.us> Date: Wed, 28 Oct 2020 17:18:19 -0400 Message-ID: <1449498.1603919899@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Wolfgang Walther 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