Re: Function with default value not replacing old definition of the function

From: "Rushabh Lathia" <rushabh(dot)lathia(at)gmail(dot)com>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Cc: rushabh(dot)lathia(at)enterprisedb(dot)com
Subject: Re: Function with default value not replacing old definition of the function
Date: 2008-12-11 07:07:49
Message-ID: 460abcb10812102307i2c28104blba2077e31f5f7235@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 11, 2008 at 12:33 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> Rushabh Lathia wrote:
>
>> Hi,
>>
>> Testcase: (8.4 CVS head)
>> ====================
>>
>> CREATE OR REPLACE FUNCTION myfunc(y int)
>> RETURNS INTEGER AS $$
>> select 100;
>> $$ language sql;
>>
>> CREATE OR REPLACE FUNCTION myfunc(y int, x integer DEFAULT 100)
>> RETURNS INTEGER AS $$
>> select 200;
>> $$ language sql;
>>
>> select myfunc(10);
>>
>> myfunc
>> ----------
>> 100
>> (1 row)
>>
>> When create the same function again by added one default value, while
>> calling the function old function getting called.
>>
>> It seems that, function with defval not making any sense, if we want to
>> call the new function then we need to pass defval as well.
>>
>
> Hmm, good point, but I'm not sure that replacing the old function is always
> right. For example, someone recently requested being able to say
>
> select myfunc(10, DEFAULT);

Hmm, good point.

>
>
> so there would be some value to having both variants.
>
> Do you have any comparisons with other systems (Oracle?) or other
> programming languages?

Yes Oracle replace the old definition of the function with the new one.

--
Rushabh Lathia
www.EnterpriseDB.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2008-12-11 07:10:58 Re: Function with default value not replacing old definition of the function
Previous Message Peter Eisentraut 2008-12-11 07:03:22 Re: Function with default value not replacing old definition of the function