Re: Function sugnature with default parameter

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, salah jubeh <s_jubeh(at)yahoo(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Function sugnature with default parameter
Date: 2014-02-26 19:40:31
Message-ID: CAFj8pRCpjxOZ+MDvwcThCom6as42ovpGXsu89_tL0ciq3F6_Xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2014-02-26 20:36 GMT+01:00 Andrew Dunstan <andrew(at)dunslane(dot)net>:

>
> On 02/26/2014 01:51 PM, Josh Berkus wrote:
>
>> On 02/26/2014 10:15 AM, salah jubeh wrote:
>>
>>> I think, there is a difference between optional parameters and default
>>> parameter values. So, my suggestion would be something like this.
>>> SELECT default_test(1,3, DEFAULT); -- match function number 1
>>>
>>> SELECT default_test(1,3); -- match the function number 2
>>>
>>> SELECT default_test(1); -- ERROR
>>> Regards
>>>
>> This would break at least 4 major applications which I personally have
>> worked on, and the benefit to users is unclear at best.
>>
>> One of the main reasons to *have* default parameters is to allow adding
>> new parameters to existing functions without breaking old application
>> code. So, -1 from me.
>>
>>
> me too.
>
> The OP's statement that there is a difference between default params and
> optional params doesn't compute. The only way params are optional is that
> they have a default. Treating these as somehow independent is a nonsense.
>
> Furthermore, if we dropped function 2, then
>
> select default_test(1,3)
>
> would be a call to function 1. Then, if we followed this proposal,
> creating function 2 would magically steer that call to function 2 instead.
> Talk about a footgun, and possibly a security risk too.
>
>
more overloaded functions with similar type signature is just dangerous and
bad practice.

We would to disallow it.

Regards

Pavel

>
> cheers
>
> andrew
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Johnston 2014-02-26 19:52:39 Re: Simplified VALUES parameters
Previous Message Merlin Moncure 2014-02-26 19:39:41 Re: jsonb and nested hstore