Today, I received a call from a friend who said that the database was changed by others, and the problem of incorrect data appeared. After a long time, the data type has overflowed (the version of the problem is MySQL 5.1). Later, through the friend side of the MySQL 5.1 to upgrade to MySQL 5.5 to solve this problem. It also gives me an interest in understanding MySQL's handling mechanism for different versions of data type overflow.
First look at the number of integers supported by MySQL and size, storage space:
In addition, please remember that MySQL data processing will be turned into bigint processing, so here is a few bigint test:
Selectcast (0ASUNSIGNED)-1;
select9223372036854775807+1;
MySQL 5.1 under:
Mysql>selectcast (0ASUNSIGNED)-1;
+-------------------------+| CAST (0ASUNSIGNED) -1|+-------------------------+|18446744073709551615|+-------------------------+1rowinset (0.01 SEC)
mysql>select9223372036854775807+1;
+-------------------------+|9223372036854775807+1|+-------------------------+|-9223372036854775808|+---------- ---------------+1rowinset (0.01 sec)
MySQL 5.5, 5.6, 5.7 under:
Mysql>selectcast (0ASUNSIGNED)-1;
ERROR 1690 (22003): Bigintunsignedvalueisoutof range in ' (CAST (0 as unsigned)-1) '
mysql>
mysql>
mysql>
mysql>select9223372036854775807+1;
ERROR 1690 (22003): Bigintvalueisoutof range in ' (9223372036854775807 + 1) '
Where the processing of such data is to be careful to overflow (such as early have to do the harm of the Q currency is to use this method to deal with)
This problem is likely to appear in the integration message, integral addition, or some money related to the business, the main library 5.1, from the library MySQL 5.5 situation will also be a problem of synchronization.
Recommendation: This kind of business system as far as possible upgrade to MySQL 5.5 version