Skip site navigation (1) Skip section navigation (2)

BUG #2037: user function call unexpected "input out of range"

From: "Tom" <lackey(at)ltu(dot)edu>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2037: user function call unexpected "input out of range"
Date: 2005-11-11 21:26:47
Message-ID: 20051111212647.381D3F0CD9@svr2.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2037
Logged by:          Tom
Email address:      lackey(at)ltu(dot)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

*/

Responses

pgsql-bugs by date

Next:From: apple sucksDate: 2005-11-12 02:55:14
Subject: dyld: Library not loaded: /server_sw/lib/libpq.4.dylib
Previous:From: Reuben PasquiniDate: 2005-11-11 02:26:55
Subject: BUG #2036: 8.1 JDBC busted date with INTERVAL update

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group