Bugs item #2791361, was opened at 2009-05-13 21:28
Message generated for change (Comment added) made by mlkersten
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: 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

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to