PGError: input out of range

Started by dustovover 18 years ago4 messagesgeneral
Jump to latest
#1dustov
dustov@gmail.com

My database just had this new error, and I have no idea why (because I
haven't intentionally made any changes to this table). Does anyone have an
idea which input is out of range-- or what the problem might be?

Thanks,
Dustin

PGError: ERROR: input is out of range
: SELECT DISTINCT locations.*,
(ACOS(COS(0.739317893219831)*COS(-1.24071147306354)*COS(RADIANS(lat))*COS(RADIANS(lng))+

COS(0.739317893219831)*SIN(-1.24071147306354)*COS(RADIANS(lat))*SIN(RADIANS(lng))+
SIN(0.739317893219831)*SIN(RADIANS(lat)))*3963)
AS distance from locations
ORDER BY distance ASC, locations.name
LIMIT 25 OFFSET 0
--
View this message in context: http://www.nabble.com/PGError%3A-input-out-of-range-tf4291698.html#a12217589
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: dustov (#1)
Re: PGError: input out of range

On Sat, Aug 18, 2007 at 03:21:02PM -0700, dustov wrote:

My database just had this new error, and I have no idea why (because I
haven't intentionally made any changes to this table). Does anyone have an
idea which input is out of range-- or what the problem might be?

The only thing in your query that I can imagine being out of range is
ACOS() which would need to be between -1 and 1 (otherwise the result
would be complex).

I'd try and see what the argument to the ACOS is, but it's probably
some corner case where the rounding is getting you.

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: dustov (#1)
Re: PGError: input out of range

dustov <dustov@gmail.com> writes:

PGError: ERROR: input is out of range

I see no such error string in the current sources ... what Postgres
version are you using?

If you set "\set VERBOSITY verbose" in psql before trying the query,
you should get some extra info about where the message is coming from.

regards, tom lane

#4dustov
dustov@gmail.com
In reply to: Martijn van Oosterhout (#2)
Re: PGError: input out of range

The problem was indeed ACOS() being outside of the [-1,1] range, and this
happened because it was calculating the distance between the same LAT,LONG
pair (the same location)

I added a WHERE L1.ID <> L2.ID to stop the reflexive calculation.

Martijn van Oosterhout wrote:

On Sat, Aug 18, 2007 at 03:21:02PM -0700, dustov wrote:

My database just had this new error, and I have no idea why (because I
haven't intentionally made any changes to this table). Does anyone have
an
idea which input is out of range-- or what the problem might be?

The only thing in your query that I can imagine being out of range is
ACOS() which would need to be between -1 and 1 (otherwise the result
would be complex).

I'd try and see what the argument to the ACOS is, but it's probably
some corner case where the rounding is getting you.

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

From each according to his ability. To each according to his ability to
litigate.

--
View this message in context: http://www.nabble.com/PGError%3A-input-out-of-range-tf4291698.html#a12376732
Sent from the PostgreSQL - general mailing list archive at Nabble.com.