Function with defval returns wrong result

Lists: pgsql-hackers
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 defval returns wrong result
Date: 2009-01-05 10:49:59
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi All,

Following test returns wrong result ..

Testcase ( on 8.4 cvs head )
=======================

CREATE OR REPLACE FUNCTION f1(retval VARCHAR DEFAULT 'Argument') RETURNS
VARCHAR as
$$
BEGIN
return retval;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION f2(p1 IN int, p2 IN VARCHAR DEFAULT f1())
RETURNS VARCHAR AS
$$
BEGIN
RETURN p2;
END;
$$ LANGUAGE plpgsql;

postgres=# select f2(10);
f2
----

(1 row)

When we run the f2() it should return the output as the defvalue of f1()
function, but its returning null.

Thanks,
Rushabh Lathia
www.EnterpriseDB.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rushabh Lathia" <rushabh(dot)lathia(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, rushabh(dot)lathia(at)enterprisedb(dot)com
Subject: Re: Function with defval returns wrong result
Date: 2009-01-06 01:24:10
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

"Rushabh Lathia" <rushabh(dot)lathia(at)gmail(dot)com> writes:
> Following test returns wrong result ..

Ooops, seems we forgot to add default arguments recursively.
Fixed, thanks for the report!

regards, tom lane