Function with default value not replacing old definition of the function

From: "Rushabh Lathia" <rushabh(dot)lathia(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: rushabh(dot)lathia(at)enterprisedb(dot)com
Subject: Function with default value not replacing old definition of the function
Date: 2008-12-11 06:45:48
Message-ID: 460abcb10812102245n34f05579ree156c9e6b26edde@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

select myfunc(10,10);

myfunc
----------
200
(1 row)

I think second function should replace the old definition of the function,
inputs ?

Thanks,
Rushabh Lathia
www.EnterpriseDB.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-12-11 07:03:22 Re: Function with default value not replacing old definition of the function
Previous Message Heikki Linnakangas 2008-12-11 06:12:30 Re: Multiplexing SUGUSR1