| Bug #11557 | Default values are set to zero when need to be rounded up to the next magnitude | ||
|---|---|---|---|
| Submitted: | 24 Jun 2005 22:38 | Modified: | 12 Jul 2005 11:43 |
| Reporter: | Omer Barnir (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.8/5.0.9 BK source | OS: | Linux (Linux SuSE 9.3) |
| Assigned to: | Alexey Botchkov | CPU Architecture: | Any |
[25 Jun 2005 0:43]
MySQL Verification Team
mysql> select * from t1; +----+----+----+----+-----+-----+----+----+ | f1 | f2 | f3 | f4 | f5 | f6 | f7 | f8 | +----+----+----+----+-----+-----+----+----+ | 1 | 18 | 99 | 0 | 104 | 200 | 0 | 0 | | 17 | 18 | 99 | 0 | 104 | 200 | 0 | 0 | +----+----+----+----+-----+-----+----+----+ 2 rows in set (0.00 sec) mysql> select version(); +------------------+ | version() | +------------------+ | 5.0.9-beta-debug | +------------------+ 1 row in set (0.00 sec) thank you for the bug report.
[12 Jul 2005 9:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/26932
[12 Jul 2005 11:43]
Alexey Botchkov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.
If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information
about accessing the source trees is available at
http://www.mysql.com/doc/en/Installing_source_tree.html

Description: When default columns are defined as not null with a default value that includes a decimal portion, the value is rounded up/down when inderted/updated into the column. However when the default value is set to a number that tounding up requires moving to the next magnitude (i.e. 9.6 --> 10, 99.9 --> 100 etc.) the value is set to zero as shown below: omer@linux:~/source/src50_0620/client> ./mysql --sock=../mysql-test/var/tmp/master.sock --user=root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.0.8-beta-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use test; Database changed mysql> 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); Query OK, 0 rows affected, 8 warnings (0.00 sec) mysql> insert into t1 (f1) values (1); Query OK, 1 row affected (0.00 sec) mysql> select * from t1; +----+----+----+----+-----+-----+----+----+ | f1 | f2 | f3 | f4 | f5 | f6 | f7 | f8 | +----+----+----+----+-----+-----+----+----+ | 1 | 18 | 99 | 0 | 104 | 200 | 0 | 0 | +----+----+----+----+-----+-----+----+----+ 1 row in set (0.00 sec) *** OBN> Note f4 sould have been 100, f6 1000 and f7 10000 mysql> insert into t1 values (2,2,2,2,2,2,2,2); Query OK, 1 row affected (0.00 sec) mysql> update t1 set f1=DEFAULT, f2=DEFAULT, f3=DEFAULT, f4=DEFAULT, f5=DEFAULT, f6=DEFAULT, f7=DEFAULT, f8=DEFAULT where f1=2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from t1; +----+----+----+----+-----+-----+----+----+ | f1 | f2 | f3 | f4 | f5 | f6 | f7 | f8 | +----+----+----+----+-----+-----+----+----+ | 1 | 18 | 99 | 0 | 104 | 200 | 0 | 0 | | 17 | 18 | 99 | 0 | 104 | 200 | 0 | 0 | +----+----+----+----+-----+-----+----+----+ 2 rows in set (0.00 sec) *** OBN> Note f4 sould have been 100, f6 1000 and f7 10000 mysql> exit Bye omer@linux:~/source/src50_0620/client> How to repeat: Run the following in the mysql client: use test; drop table if exists 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); insert into t1 (f1) values (1); select * from t1; insert into t1 values (2,2,2,2,2,2,2,2); update t1 set f1=DEFAULT, f2=DEFAULT, f3=DEFAULT, f4=DEFAULT, f5=DEFAULT, f6=DEFAULT, f7=DEFAULT, f8=DEFAULT where f1=2; select * from t1; drop table t1; Suggested fix: default values should be rounded up correctly