Commit 64c2a598 authored by hf@deer.(none)'s avatar hf@deer.(none)

Merge bk@192.168.21.1:/usr/home/bk/mysql-5.0

into deer.(none):/home/hf/work/mysql-5.0.clean
parents 60bb14c3 ba559d65
...@@ -955,3 +955,26 @@ t1 CREATE TABLE `t1` ( ...@@ -955,3 +955,26 @@ t1 CREATE TABLE `t1` (
`sl` decimal(5,5) default NULL `sl` decimal(5,5) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (
f1 decimal unsigned not null default 17.49,
f2 decimal unsigned not null default 17.68,
f3 decimal unsigned not null default 99.2,
f4 decimal unsigned not null default 99.7,
f5 decimal unsigned not null default 104.49,
f6 decimal unsigned not null default 199.91,
f7 decimal unsigned not null default 999.9,
f8 decimal unsigned not null default 9999.99);
Warnings:
Note 1265 Data truncated for column 'f1' at row 1
Note 1265 Data truncated for column 'f2' at row 1
Note 1265 Data truncated for column 'f3' at row 1
Note 1265 Data truncated for column 'f4' at row 1
Note 1265 Data truncated for column 'f5' at row 1
Note 1265 Data truncated for column 'f6' at row 1
Note 1265 Data truncated for column 'f7' at row 1
Note 1265 Data truncated for column 'f8' at row 1
insert into t1 (f1) values (1);
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8
1 18 99 100 104 200 1000 10000
drop table t1;
...@@ -998,3 +998,20 @@ create table t1 (sl decimal(0,30)); ...@@ -998,3 +998,20 @@ create table t1 (sl decimal(0,30));
create table t1 (sl decimal(5, 5)); create table t1 (sl decimal(5, 5));
show create table t1; show create table t1;
drop table t1; drop table t1;
#
# Bug 11557 (DEFAULT values rounded improperly
#
create table t1 (
f1 decimal unsigned not null default 17.49,
f2 decimal unsigned not null default 17.68,
f3 decimal unsigned not null default 99.2,
f4 decimal unsigned not null default 99.7,
f5 decimal unsigned not null default 104.49,
f6 decimal unsigned not null default 199.91,
f7 decimal unsigned not null default 999.9,
f8 decimal unsigned not null default 9999.99);
insert into t1 (f1) values (1);
select * from t1;
drop table t1;
...@@ -1443,6 +1443,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1443,6 +1443,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
intg1=ROUND_UP(from->intg + intg1=ROUND_UP(from->intg +
(((intg0 + frac0)>0) && (from->buf[0] == DIG_MAX))); (((intg0 + frac0)>0) && (from->buf[0] == DIG_MAX)));
dec1 *buf0=from->buf, *buf1=to->buf, x, y, carry=0; dec1 *buf0=from->buf, *buf1=to->buf, x, y, carry=0;
int first_dig;
sanity(to); sanity(to);
...@@ -1578,14 +1579,6 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1578,14 +1579,6 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
*buf1=1; *buf1=1;
to->intg++; to->intg++;
} }
else
{
/* Here we check 999.9 -> 1000 case when we need to increase intg */
int first_dig= to->intg % DIG_PER_DEC1;
/* first_dig==0 should be handled above in the 'if' */
if (first_dig && (*buf1 >= powers10[first_dig]))
to->intg++;
}
} }
else else
{ {
...@@ -1606,6 +1599,12 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1606,6 +1599,12 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
} }
} }
} }
/* Here we check 999.9 -> 1000 case when we need to increase intg */
first_dig= to->intg % DIG_PER_DEC1;
if (first_dig && (*buf1 >= powers10[first_dig]))
to->intg++;
if (scale<0) if (scale<0)
scale=0; scale=0;
......
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