Calling variadic function with default value in named notation

From: Wolfgang Walther <walther(at)technowledgy(dot)de>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Calling variadic function with default value in named notation
Date: 2020-10-28 21:02:02
Message-ID: 5a80bcdb-e92a-5c21-d923-f3813543771b@technowledgy.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I tried the following on PG 12.4 and PG 13.0:

create function a(x int, y int[] default '{}')
returns void language sql as '';

create function b(x int, variadic y int[] default '{}')
returns void language sql as '';

-- 1
select a(1, '{2}');
-- 2
select b(1, 2);
-- 3
select a(x=>1, y=>'{2}');
-- 4
select b(x=>1, variadic y=>'{2}');
-- 5
select a(1);
-- 6
select b(1);
-- 7
select a(x=>1);
-- 8
select b(x=>1);

The first 7 calls succeed, but the last one is failing with:

ERROR: function b(x => integer) does not exist
LINE 1: select b(x=>1);
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

So while I am able to call the variadic function in named notation (call
4) or with the default value (call 6) - I am not able to put both
together in call 8.

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?

Thanks

Wolfgang

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-10-28 21:18:19 Re: Calling variadic function with default value in named notation
Previous Message Bruce Momjian 2020-10-28 20:46:54 Re: BUG #16688: psql removes only LF without CR at end of backquotes on windows.