Bug #79568 varchar convert to int
Submitted: 9 Dec 2015 7:48 Modified: 9 Dec 2015 11:06
Reporter: H jake Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.6.27 and above OS:Linux
Assigned to: CPU Architecture:Any

[9 Dec 2015 7:48] H jake
Description:
it will occurs convert when query like this select 123'=123;
but if the varchar length is over 16 bits will wrong!

i konw this is ok
mysql> SELECT '201512081252120026' = '201512081252120025' ;
+---------------------------------------------+
| '201512081252120026' = '201512081252120025' |
+---------------------------------------------+
|                                           0 |
+---------------------------------------------+
1 row in set (0.00 sec)

bug if as blow :

mysql> SELECT 201512081252120026 = '201512081252120025' ;
+-------------------------------------------+
| 201512081252120026 = '201512081252120025' |
+-------------------------------------------+
|                                         1 |
+-------------------------------------------+
1 row in set (0.00 sec)

if this is ok,max length is 16 or small

mysql> SELECT 2015120812521201 = '2015120812521200' ;
+---------------------------------------+
| 2015120812521201 = '2015120812521200' |
+---------------------------------------+
|                                     0 |
+---------------------------------------+
1 row in set (0.00 sec)

if over 16 ,the result is wrong
mysql> SELECT 20151208125212001 = '20151208125212002' ;
+-----------------------------------------+
| 20151208125212001 = '20151208125212002' |
+-----------------------------------------+
|                                       1 |
+-----------------------------------------+
1 row in set (0.00 sec)

How to repeat:
mysql> SELECT '201512081252120026' = '201512081252120025' ;

mysql> SELECT 201512081252120026 = '201512081252120025' ;

Suggested fix:
i want to know the max varhcar convert to int is what,and i knew how to void the problem
[9 Dec 2015 11:06] MySQL Verification Team
Thank you for the bug report. Please read:

http://dev.mysql.com/doc/refman/5.6/en/type-conversion.html

"If both arguments in a comparison operation are strings, they are compared as strings. "

.....

" Comparisons that use floating-point numbers (or values that are converted to floating-point numbers) are approximate because such numbers are inexact. This might lead to results that appear inconsistent:

mysql> SELECT '18015376320243458' = 18015376320243458;
        -> 1
mysql> SELECT '18015376320243459' = 18015376320243459;
        -> 0
"