1.0 in function call not regarded as REAL in 7.3.2

Lists: pgsql-bugs
From: Boris Folgmann <misc(at)folgmann(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: 1.0 in function call not regarded as REAL in 7.3.2
Date: 2003-08-21 14:04:38
Message-ID: 3F44D176.9020805@folgmann.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi!

I've triggered a type related problem in postgresql-7.3.2-3
It worked in postgresql-7.2.3-5.80.

CREATE OR REPLACE FUNCTION _rmin(REAL, REAL)
RETURNS REAL AS '
BEGIN
IF $1 <= $2 THEN
RETURN $1;
ELSE
RETURN $2;
END IF;
END;
' LANGUAGE 'plpgsql' WITH (ISCACHABLE);

This works:

SELECT _rmin(1.0, CAST(123 AS REAL));
_rmin
-------
1
(1 Zeile)

This not:

SELECT _rmin(1.0, CAST(123 AS REAL)/25);
ERROR: Funktion _rmin(numeric, double precision) existiert nicht
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts

Look closely: postmaster now thinks that the first argument 1.0 is NUMERIC,
but I added only the /25 for the _second_ argument!

cu,
boris

--
Dipl.-Inf. Boris Folgmann mailto:boris(at)folgmann(dot)de
TeamForge GmbH http://www.teamforge.de


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Boris Folgmann <misc(at)folgmann(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: 1.0 in function call not regarded as REAL in 7.3.2
Date: 2003-08-21 14:49:10
Message-ID: 8052.1061477350@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Boris Folgmann <misc(at)folgmann(dot)com> writes:
> Look closely: postmaster now thinks that the first argument 1.0 is NUMERIC,

Yup. This is not a bug, it's intentional (and per SQL spec, AFAICT).

Your problem is that 123::real/25 yields a double precision result,
which is not implicitly castable to real anymore. I'd suggest
switching the function arguments to double precision.

regards, tom lane