Bug #1845 Not correctly recognising value for decimal field
Submitted: 15 Nov 2003 15:35 Modified: 23 May 2006 2:33
Reporter: Matt Read Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:Linux (Linux)
Assigned to: Sergei Glukhov CPU Architecture:Any

[15 Nov 2003 15:35] Matt Read
Description:
Large values in the VALUES() clause of an insert statement into a DECIMAL field type doesn't seem to be interpreted correctly unless wrapped by quotes.

If this is a feature rather than a bug I'd appreciate it if someone could point me at the documentation which explains the rationale.

Matt.

How to repeat:
The following SQL produces rows with different values. The first row is a negative number.

DROP TABLE IF EXISTS TEST_TABLE;
CREATE TABLE TEST_TABLE (
  quantity decimal(60,0)
) TYPE=InnoDB;
insert into TEST_TABLE values (10000000000000000000);
insert into TEST_TABLE values ('10000000000000000000');
[16 Nov 2003 6:32] Alexander Keremidarski
This problem is not InnoDB related.

The problem is that floating point arithmetic is used. This will be fixed when we implement fixed point arithmetic for DECIMAL.
[16 Nov 2003 6:33] Alexander Keremidarski
This is not InnoDB related.

The problem is that floating point arithmetic is used. This will be fixed when we implement fixed point arithmetic for DECIMAL.
[16 Nov 2003 8:35] Sergei Golubchik
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

fixed in 4.0.17
[24 Nov 2003 7:18] Sergei Golubchik
oops, reverted because of undesirable side-effects.

The correct fix is too complex for the stable version (that is for 4.0)
:(

We'll fix it in 4.1
[12 Mar 2004 6:19] Michael Widenius
We will in 5.0 add a numeric package that will fix this problem properly.
[23 May 2006 2:33] MySQL Verification Team
This was already fixed on 5.0:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> DROP TABLE IF EXISTS TEST_TABLE;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE TEST_TABLE (
    ->   quantity decimal(60,0)
    -> ) TYPE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> insert into TEST_TABLE values (10000000000000000000);
Query OK, 1 row affected (0.01 sec)

mysql> insert into TEST_TABLE values ('10000000000000000000');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM TEST_TABLE;
+----------------------+
| quantity             |
+----------------------+
| 10000000000000000000 | 
| 10000000000000000000 | 
+----------------------+
2 rows in set (0.00 sec)

mysql>