diff options
author | unknown <serg@serg.mylan> | 2004-07-31 22:39:10 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-07-31 22:39:10 +0200 |
commit | 9ca47d047e5164515eac6fcae05ae9450cb94213 (patch) | |
tree | cf7939bc79abe785fb770d14f5f7efac88a3349e | |
parent | 42ed0103c8cac51d84c9fdf339058a85667cd19a (diff) | |
download | mariadb-git-9ca47d047e5164515eac6fcae05ae9450cb94213.tar.gz |
BUG#4393, BUG#4356 - incorrect decimals in fix_length_and_dec() in some functions
mysql-test/mysql-test-run.sh:
report failed test name
mysql-test/r/func_math.result:
test results fixed
-rw-r--r-- | mysql-test/mysql-test-run.sh | 2 | ||||
-rw-r--r-- | mysql-test/r/func_math.result | 24 | ||||
-rw-r--r-- | mysql-test/r/type_float.result | 11 | ||||
-rw-r--r-- | mysql-test/t/type_float.test | 9 | ||||
-rw-r--r-- | sql/item_func.cc | 4 | ||||
-rw-r--r-- | sql/item_func.h | 2 | ||||
-rw-r--r-- | sql/item_sum.h | 12 |
7 files changed, 41 insertions, 23 deletions
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 449b7015188..cd6c331687f 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -589,6 +589,8 @@ show_failed_diff () echo "Please follow the instructions outlined at" echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html" echo "to find the reason to this problem and how to report this." + echo "" + echo "Test $1 failed!" fi } diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 46ad7a14e25..d90071e0b56 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -18,44 +18,44 @@ abs(-10) sign(-5) sign(5) sign(0) 10 -1 1 0 select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2) -10.000000 10.000000 NULL NULL NULL 2.000000 NULL NULL +10 10 NULL NULL NULL 2 NULL NULL select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL) -10.000000 10.000000 NULL NULL NULL +10 10 NULL NULL NULL select log2(8),log2(15),log2(-2),log2(0),log2(NULL); log2(8) log2(15) log2(-2) log2(0) log2(NULL) -3.000000 3.906891 NULL NULL NULL +3 3.9068905956085 NULL NULL NULL select log10(100),log10(18),log10(-4),log10(0),log10(NULL); log10(100) log10(18) log10(-4) log10(0) log10(NULL) -2.000000 1.255273 NULL NULL NULL +2 1.2552725051033 NULL NULL NULL select pow(10,log10(10)),power(2,4); pow(10,log10(10)) power(2,4) -10.000000 16.000000 +10 16 set @@rand_seed1=10000000,@@rand_seed2=1000000; select rand(999999),rand(); rand(999999) rand() 0.014231365187309 0.028870999839968 select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); 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 +3.141593 1 6.1230317691119e-17 1.2246063538224e-16 0.64209261593433 1.5707963267949 1.5707963267949 0.78539816339745 select degrees(pi()),radians(360); degrees(pi()) radians(360) 180 6.2831853071796 SELECT ACOS(1.0); ACOS(1.0) -0.000000 +0 SELECT ASIN(1.0); ASIN(1.0) -1.570796 +1.5707963267949 SELECT ACOS(0.2*5.0); ACOS(0.2*5.0) -0.000000 +0 SELECT ACOS(0.5*2.0); ACOS(0.5*2.0) -0.000000 +0 SELECT ASIN(0.8+0.2); ASIN(0.8+0.2) -1.570796 +1.5707963267949 SELECT ASIN(1.2-0.2); ASIN(1.2-0.2) -1.570796 +1.5707963267949 diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index c9996e9c9f3..61b90c8cf2e 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -72,14 +72,17 @@ insert t1 values (121,"16"); select c1 + c1 * (c2 / 100) as col from t1; col 140.36 -create table t2 select c1 + c1 * (c2 / 100) as col from t1; +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; select * from t2; -col -140.36 +col1 col2 col3 col4 +140.36 121.00000 121 3.47850542618522e-07 show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `col` double default NULL + `col1` double default NULL, + `col2` double(22,5) default NULL, + `col3` double default NULL, + `col4` double default NULL ) TYPE=MyISAM drop table t1,t2; create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 65d594387b9..bd6448616dc 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -28,10 +28,14 @@ select a from t1 order by a; select min(a) from t1; drop table t1; +# +# BUG#3612, BUG#4393, BUG#4356, BUG#4394 +# + create table t1 (c1 double, c2 varchar(20)); insert t1 values (121,"16"); select c1 + c1 * (c2 / 100) as col from t1; -create table t2 select c1 + c1 * (c2 / 100) as col from t1; +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; select * from t2; show create table t2; drop table t1,t2; @@ -52,6 +56,7 @@ drop table t1; # Errors -!$1063 create table t1 (f float(54)); # Should give an error +--error 1063 +create table t1 (f float(54)); # Should give an error drop table if exists t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 368c14cc8df..237db890abb 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -684,7 +684,7 @@ void Item_func_round::fix_length_and_dec() if (tmp < 0) decimals=0; else - decimals=tmp; + decimals=min(tmp,NOT_FIXED_DEC); } } @@ -1286,7 +1286,7 @@ udf_handler::fix_fields(THD *thd,TABLE_LIST *tables,Item_result_field *func, func->max_length=min(initid.max_length,MAX_BLOB_WIDTH); func->maybe_null=initid.maybe_null; const_item_cache=initid.const_item; - func->decimals=min(initid.decimals,31); + func->decimals=min(initid.decimals,NOT_FIXED_DEC); } initialized=1; if (error) diff --git a/sql/item_func.h b/sql/item_func.h index 4d171cda490..8a013f42c05 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -295,7 +295,7 @@ class Item_dec_func :public Item_real_func Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {} void fix_length_and_dec() { - decimals=6; max_length=float_length(decimals); + decimals=NOT_FIXED_DEC; max_length=float_length(decimals); maybe_null=1; } inline double fix_result(double value) diff --git a/sql/item_sum.h b/sql/item_sum.h index 6835b1e8fae..802e3f1ba45 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -234,7 +234,11 @@ public: class Item_sum_avg :public Item_sum_num { - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } double sum; ulonglong count; @@ -276,7 +280,11 @@ class Item_sum_std :public Item_sum_num double sum; double sum_sqr; ulonglong count; - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } public: Item_sum_std(Item *item_par) :Item_sum_num(item_par),count(0) {} |