[debian-mysql] Bug#588814: mysql-server-5.0: MySql ROUND function
Verdnatura Levante S.L.
juan at verdnatura.es
Mon Jul 12 15:16:44 UTC 2010
Subject: mysql-server-5.0: MySql ROUND function
Package: mysql-server-5.0
Version: 5.0.51a-24
Severity: important
This error was found in an other computer: Debian stable with kernel
version 2.6.26-2-amd64. The package version is the same.
There is a problem when you round some number directly from a SELECT
query.
There is an example:
mysql> CREATE TABLE rounding (id int(10) unsigned NOT NULL
auto_increment,
amount double NOT NULL DEFAULT 0, price double DEFAULT 0, discount
double NOT
NULL DEFAULT 0, PRIMARY KEY (id) );
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO rounding (amount,price,discount) VALUES
(1,4.95,50),(1,2.07,50);
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> SELECT ROUND(amount * price * (100 - discount) / 100, 2) AS
with_round,
-> amount * price * (100 - discount) / 100 as without_round FROM
rounding;
+------------+---------------+
| with_round | without_round |
+------------+---------------+
| 2.48 | 2.475 |
| 1.03 | 1.035 |
+------------+---------------+
2 rows in set (0.00 sec)
In the second row the column`with_round` would be 1.04, but in the first
row,
it works correctly.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
More information about the pkg-mysql-maint
mailing list