Bugs item #2791361, was opened at 2009-05-13 21:28
Message generated for change (Comment added) made by stmane
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 Manegold (stmane)
Date: 2009-08-11 13:11
Message:
added test for
ID: 2791356 "Floating point exception"
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2791356&group_id=56967
in Aug2009 release branch as
sql/src/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.*
Appears to work fine.
----------------------------------------------------------------------
Comment By: Martin Kersten (mlkersten)
Date: 2009-08-06 16:25
Message:
Patched batcalc.mx to take care of runtime division by zero, turning the
result into a nil.
----------------------------------------------------------------------
Comment By: Stefan Manegold (stmane)
Date: 2009-06-08 10:54
Message:
A to-be-added test should also cover
ID: 2791356 "Floating point exception"
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2791356&group_id=56967
----------------------------------------------------------------------
Comment By: Martin Kersten (mlkersten)
Date: 2009-06-07 17:01
Message:
Unfortunately, the MAL plan can not prohibit such an exception to be
raised
in sequential mode either
----------------------------------------------------------------------
Comment By: Martin Kersten (mlkersten)
Date: 2009-06-07 16:47
Message:
The effect is a result of dataflow execution. There is no dependency code
between the two blocks that forces a sequential execution.
select case when (2 - 2) > 0 then (3 - 2)/(2 - 2) else 0 end as "test";
barrier _50 := language.dataflow();
_10 := calc.-(A0,A1);
_11 := calc.>(_10,A2);
_12 := calc.isnil(_11);
_14 := calc.ifthenelse(_12,false,_11);
_15 := calc.-(A3,A4);
_16 := calc.-(A5,A6);
_17 := calc./(_15,_16);
_18 := calc.ifthenelse(_14,_17,A7);
exit _50;
----------------------------------------------------------------------
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
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs