Bug #31104 string to longlong conversion error
Submitted: 20 Sep 2007 6:31 Modified: 15 Oct 2007 6:00
Reporter: Venu Anuganti Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0-bk, 5.1-bk OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: string to longlong bug

[20 Sep 2007 6:31] Venu Anuganti
Description:
Hi !!

This one used to work fine with 4.0 and 4.1 and 5.0 except the recent 5.0 and 5.1 version.

mysql> create table t(c1 bigint);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values('15449237462.0000000000');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+---------------------------------------------+
| Level   | Code | Message                                     |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'c1' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)

This is caused by the following changeset:
http://mysql.bkbits.net:8080/mysql-5.0/?PAGE=cset&REV=460b3bbeDbs-rJuZhj_q2MJqN65UNg

Where in string to longlong used to be done though strntoull, but that the above change, the new function strntoull10rnd is used instead which does not seemed to has wrong checks on the CUTOFF value when the input had . as part of it.

How to repeat:
mysql> create table t(c1 bigint);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values('15449237462.0000000000');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+---------------------------------------------+
| Level   | Code | Message                                     |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'c1' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
1. Try to use the old strntoull instead of new strntoull10rnd

or

2. Fix strntoull10rnd

or 

may be termed as feature
[20 Sep 2007 7:19] Domas Mituzas
The problem here is not the reaction to bigger precision, but actually completely broken number conversion:

mysql> create table t1 (a bigint);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values ("1.0000000000");
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 values ("1.000000000000000000");
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 values ("1.0000000000000000000000");
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------------+
| Level   | Code | Message                                             |
+---------+------+-----------------------------------------------------+
| Warning | 1264 | Out of range value adjusted for column 'a' at row 1 | 
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+---------------------+
| a                   |
+---------------------+
|                   1 | 
|                   1 | 
| 9223372036854775807 | 
+---------------------+
3 rows in set (0.00 sec)

mysql>
[12 Oct 2007 14:48] Konstantin Osipov
Alexei, this seems to be a dup of the other bug I assigned to you.
[15 Oct 2007 6:00] Alexey Kopytov
Duplicate of bug #30453.