提交 01eeed0f authored 作者: Thomas Mueller's avatar Thomas Mueller

For compatibility with other databases, support for (double and float) -0.0 has…

For compatibility with other databases, support for (double and float) -0.0 has been removed. 0.0 is used instead.
上级 5f05037a
...@@ -21,6 +21,9 @@ Change Log ...@@ -21,6 +21,9 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>For compatibility with other databases, support for (double and float)
-0.0 has been removed. 0.0 is used instead.
</li>
<li>In version 1.4.186, "order by" was broken in some cases <li>In version 1.4.186, "order by" was broken in some cases
due to the change "Make the planner use indexes for sorting when doing a GROUP BY". due to the change "Make the planner use indexes for sorting when doing a GROUP BY".
The change was reverted. The change was reverted.
......
...@@ -92,11 +92,7 @@ public class ValueDouble extends Value { ...@@ -92,11 +92,7 @@ public class ValueDouble extends Value {
} else if (Double.isNaN(value)) { } else if (Double.isNaN(value)) {
return "SQRT(-1)"; return "SQRT(-1)";
} }
String s = getString(); return getString();
if (s.equals("-0.0")) {
return "-CAST(0 AS DOUBLE)";
}
return s;
} }
@Override @Override
...@@ -162,11 +158,8 @@ public class ValueDouble extends Value { ...@@ -162,11 +158,8 @@ public class ValueDouble extends Value {
if (d == 1.0) { if (d == 1.0) {
return ONE; return ONE;
} else if (d == 0.0) { } else if (d == 0.0) {
// unfortunately, -0.0 == 0.0, but we don't want to return // -0.0 == 0.0, and we want to return 0.0 for both
// 0.0 in this case
if (Double.doubleToLongBits(d) == ZERO_BITS) {
return ZERO; return ZERO;
}
} else if (Double.isNaN(d)) { } else if (Double.isNaN(d)) {
return NAN; return NAN;
} }
......
...@@ -92,11 +92,7 @@ public class ValueFloat extends Value { ...@@ -92,11 +92,7 @@ public class ValueFloat extends Value {
// NaN // NaN
return "SQRT(-1)"; return "SQRT(-1)";
} }
String s = getString(); return getString();
if (s.equals("-0.0")) {
return "-CAST(0 AS REAL)";
}
return s;
} }
@Override @Override
...@@ -162,12 +158,9 @@ public class ValueFloat extends Value { ...@@ -162,12 +158,9 @@ public class ValueFloat extends Value {
if (d == 1.0F) { if (d == 1.0F) {
return ONE; return ONE;
} else if (d == 0.0F) { } else if (d == 0.0F) {
// unfortunately, -0.0 == 0.0, but we don't want to return // -0.0 == 0.0, and we want to return 0.0 for both
// 0.0 in this case
if (Float.floatToIntBits(d) == ZERO_BITS) {
return ZERO; return ZERO;
} }
}
return (ValueFloat) Value.cache(new ValueFloat(d)); return (ValueFloat) Value.cache(new ValueFloat(d));
} }
......
...@@ -407,14 +407,14 @@ select * from dual where cast('xx' as varchar_ignorecase(1)) = 'X' and cast('x x ...@@ -407,14 +407,14 @@ select * from dual where cast('xx' as varchar_ignorecase(1)) = 'X' and cast('x x
explain select -cast(0 as real), -cast(0 as double); explain select -cast(0 as real), -cast(0 as double);
> PLAN > PLAN
> -------------------------------------------------------------------------------------------- > ----------------------------------------------------------------
> SELECT -CAST(0 AS REAL), -CAST(0 AS DOUBLE) FROM SYSTEM_RANGE(1, 1) /* PUBLIC.RANGE_INDEX */ > SELECT 0.0, 0.0 FROM SYSTEM_RANGE(1, 1) /* PUBLIC.RANGE_INDEX */
> rows: 1 > rows: 1
select -cast(0 as double) nz; select -cast(0 as double) nz;
> NZ > NZ
> ---- > ---
> -0.0 > 0.0
> rows: 1 > rows: 1
select () empty; select () empty;
...@@ -7927,7 +7927,7 @@ SELECT ID++0, -X1, -XT, -X_SM, -XB, -XD, -XD2, -XR FROM TEST; ...@@ -7927,7 +7927,7 @@ SELECT ID++0, -X1, -XT, -X_SM, -XB, -XD, -XD2, -XR FROM TEST;
> ID + 0 - X1 - XT - X_SM - XB - XD - XD2 - XR > ID + 0 - X1 - XT - X_SM - XB - XD - XD2 - XR
> ------ ----- ---- ------ ---- ----- ----- ---- > ------ ----- ---- ------ ---- ----- ----- ----
> -1 TRUE 1 1 1 1.00 1.0 1.0 > -1 TRUE 1 1 1 1.00 1.0 1.0
> 0 TRUE 0 0 0 0.00 -0.0 -0.0 > 0 TRUE 0 0 0 0.00 0.0 0.0
> 1 FALSE -1 -1 -1 -1.00 -1.0 -1.0 > 1 FALSE -1 -1 -1 -1.00 -1.0 -1.0
> 4 FALSE -4 -4 -4 -4.00 -4.0 -4.0 > 4 FALSE -4 -4 -4 -4.00 -4.0 -4.0
> null null null null null null null null > null null null null null null null null
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论