Bugs item #2791361, was opened at 2009-05-13 21:28
Message generated for change (Comment added) made by skinkie
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2791361&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: SQL/Core
Group: MonetDB5 CVS Head
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stefan de Konink (skinkie)
Assigned to: Niels Nes (nielsnes)
Summary: Division by zero error

Initial Comment:
In a simple example the following works:

create table test2 (bla1 double, bla2 double);
insert into test2 values (1,1);
insert into test2 values (1,2);
insert into test2 values (1,3);
select case when (bla1 - bla2) > 0 then 1/(bla1 - bla2) else 0 end from test2;

select case when (bla1 - bla2) > 0 then 1/(bla1 - bla2) else 0 end from test2;
+------------------------+
| isnull_>_sql_sub_bla1  |
+========================+
|                      0 |
|                      1 |
|                    0.5 |
+------------------------+
3 tuples

According to Martin the following example creates a division by zero because 
they are constants:
select case when (2 - 2) > 0 then (3 - 2)/(2 - 2) else 0 end as "test";
!MALException:calc./:Division by zero

Unlike in PostgreSQL where the output is 0; (Lazy evaluation)


Now in my original query:
select n1.lat, n1.long, n2.lat, n2.long, case when (n2.lat - n1.lat) > 0 then 
(n2.long - n1.long)/(n2.lat - n1.lat) else 0 end from nodes_legacy as n1, 
nodes_legacy as n2, segments where node1 = n1.id and node2 = n2.id limit 10;

Also returns division by zero.

But in this case: !ArithmeticException:batcalc./:Division by zero

CREATE TABLE "sys"."nodes_legacy" (
        "id" int,
        "long" double,
        "lat" double,
        "uid" int,
        "timestamp" timestamptz(7)
);

CREATE TABLE "sys"."segments" (
        "way" int,
        "node1" int,
        "node2" int
);

----------------------------------------------------------------------

>Comment By: Stefan de Konink (skinkie)
Date: 2009-05-24 03:06

Message:
https://sourceforge.net/tracker/?func=detail&aid=2593341&group_id=56967&atid=482468

The above problem was fixed by recognizing unsafe functions...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2791361&group_id=56967

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to