Commit 148570fc authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0

into  sanja.is.com.ua:/home/bell/mysql/bk/work-bug4-5.0
parents 69c2076c 71908dbc
This diff is collapsed.
...@@ -1051,6 +1051,41 @@ select cast(@non_existing_user_var/2 as DECIMAL); ...@@ -1051,6 +1051,41 @@ select cast(@non_existing_user_var/2 as DECIMAL);
--error 1427 --error 1427
create table t (d decimal(0,10)); create table t (d decimal(0,10));
#
# Bug #14268 (bad FLOAT->DECIMAL conversion)
#
CREATE TABLE t1 (
my_float FLOAT,
my_double DOUBLE,
my_varchar VARCHAR(50),
my_decimal DECIMAL(65,30)
);
SHOW CREATE TABLE t1;
let $max_power= 32;
while ($max_power)
{
eval INSERT INTO t1 SET my_float = 1.175494345e-$max_power,
my_double = 1.175494345e-$max_power,
my_varchar = '1.175494345e-$max_power';
dec $max_power;
}
SELECT my_float, my_double, my_varchar FROM t1;
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
UPDATE t1 SET my_decimal = my_float;
SELECT my_decimal, my_float FROM t1;
UPDATE t1 SET my_decimal = my_double;
SELECT my_decimal, my_double FROM t1;
UPDATE t1 SET my_decimal = my_varchar;
SELECT my_decimal, my_varchar FROM t1;
DROP TABLE t1;
# #
# Bug #13573 (Wrong data inserted for too big values) # Bug #13573 (Wrong data inserted for too big values)
# #
......
...@@ -973,7 +973,7 @@ int double2decimal(double from, decimal_t *to) ...@@ -973,7 +973,7 @@ int double2decimal(double from, decimal_t *to)
{ {
/* TODO: fix it, when we'll have dtoa */ /* TODO: fix it, when we'll have dtoa */
char s[400], *end; char s[400], *end;
sprintf(s, "%f", from); sprintf(s, "%.16G", from);
end= strend(s); end= strend(s);
return string2decimal(s, to, &end); return string2decimal(s, to, &end);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment