summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <vva@eagle.mysql.r18.ru>2004-01-12 22:47:26 -0400
committerunknown <vva@eagle.mysql.r18.ru>2004-01-12 22:47:26 -0400
commit024328953d54431a0fe0dc1dee21d8b5d4dac21f (patch)
tree9a2d1d70ecd1146084719b4ef4ae1d796c10ecea
parentae13e464af11613462cd341361ab342a24da57e9 (diff)
downloadmariadb-git-024328953d54431a0fe0dc1dee21d8b5d4dac21f.tar.gz
Fixed Bug #2338 Trigonometric arithmetic problem
by fixing optimizer bug with help of 'volatile' keyword mysql-test/r/func_math.result: added tests for BUG #2338 Trigonometric arithmetic problems mysql-test/t/func_math.test: added tests for BUG #2338 Trigonometric arithmetic problems sql/item_func.cc: added keyword volatile in Item_func_acos::val and Item_func_asin::val to calm optimizer down and to avoid it's bug
-rw-r--r--mysql-test/r/func_math.result12
-rw-r--r--mysql-test/t/func_math.test11
-rw-r--r--sql/item_func.cc6
3 files changed, 27 insertions, 2 deletions
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index e2723311682..5e774fe9886 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -20,3 +20,15 @@ PI() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1)
3.141593 1.000000 0.000000 0.000000 0.64209262 1.570796 1.570796 0.785398
degrees(pi()) radians(360)
180 6.2831853071796
+ACOS(1.0)
+0.000000
+ASIN(1.0)
+1.570796
+ACOS(0.2*5.0)
+0.000000
+ACOS(0.5*2.0)
+0.000000
+ASIN(0.8+0.2)
+1.570796
+ASIN(1.2-0.2)
+1.570796
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index 5299897d0f0..42ba8c73f69 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -13,3 +13,14 @@ select pow(10,log10(10)),power(2,4);
select rand(999999),rand();
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
select degrees(pi()),radians(360);
+
+#
+# Bug #2338 Trignometric arithmatic problems
+#
+
+SELECT ACOS(1.0);
+SELECT ASIN(1.0);
+SELECT ACOS(0.2*5.0);
+SELECT ACOS(0.5*2.0);
+SELECT ASIN(0.8+0.2);
+SELECT ASIN(1.2-0.2);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 217768db2c5..28a1c428cab 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -456,7 +456,8 @@ double Item_func_pow::val()
double Item_func_acos::val()
{
- double value=args[0]->val();
+ // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down
+ volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
return fix_result(acos(value));
@@ -464,7 +465,8 @@ double Item_func_acos::val()
double Item_func_asin::val()
{
- double value=args[0]->val();
+ // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down
+ volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
return fix_result(asin(value));