The following bug has been logged online:
Bug reference: 2037
Logged by: Tom
Email address: lackey@ltu.edu
PostgreSQL version: 8.1-beta4
Operating system: Windows XP
Description: user function call unexpected "input out of range"
Details:
--No database needs to be selected.
--Just cut and paste into a file.
--All remarks are in comments.
--
--From the psql prompt use "\i fileName".
--
create function find (numeric,numeric,numeric,numeric) returns double
precision
as
$$
--Calculate distance
select acos
(
sin($1*pi()/180)*sin($3*pi()/180)
+
cos($1*pi()/180)*cos($3*pi()/180)
*cos(($2-$4)*pi()/180)
)*60*1.1515*180/pi();
$$
language SQL;
--Number 1.
select find(42.3202,-83.2687,42.3202,-83.2687);
--Number 2.
select find(42.320,-83.2687,42.3202,-83.2687);
--Number 3.
select find(42.3338,-83.1818,42.3338,-83.1818);
\df+ find;
drop function find(numeric,numeric,numeric,numeric);
/* This surfaced when calculating the distances between zip codes using
latidtudes and longitudes. When the latitudes and longitudes are the same
the distance should be zero. Number 1 gives the error. Number 2 differs by a
digit in the last decimal place and works. Number 3 is another test with
identical latitudes and longitudes and does calculate zero.
The "DROP FUNCTION" was only put in so I could repeatly re-execute the
script.
The ".msi" was used for the install accepting all of the defaults.
Thanks, Tom
*/