Bug #114962 | insert into -0 become 0 (Fields of type double) | ||
---|---|---|---|
Submitted: | 11 May 2024 2:46 | Modified: | 13 May 2024 11:32 |
Reporter: | Guisen Yang | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.7 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | zero data |
[11 May 2024 2:46]
Guisen Yang
[13 May 2024 10:40]
MySQL Verification Team
HI Mr. lain, Thank you very much for your bug report. However, this is not a bug. DOUBLE is a floating data type that is defined in IEEE standard. According to that standard 0.0 and -0.0 are identical values. Hence, this is not a bug.
[13 May 2024 10:51]
MySQL Verification Team
Hi, We are also unable to repeat your test case: +----------+------+ | name | id | +----------+------+ | ABCDEFGH | -0 | | ABCDEFGH | -0 | | ABCDEFGH | 0.1 | | ABCDEFGH | -1.1 | +----------+------+ But, more important is the fact that you are using floating point type. If you want to preserve precision, use DECIMAL type.
[13 May 2024 11:32]
Guisen Yang
Thank you for your reply. For SELECT, -0 and 0 are the same. However, the data imported with -0 using Load DATA and -0 using Insert are different in the MYSQL database. anther example (Ver: 8.0.28): SHELL> cat /tmp/aa.txt -0.0 0.0 MYSQL> create table db1.t20240513(aa double); MYSQL> load data local infile '/tmp/aa.txt' ignore into table db1.t20240513; MYSQL> checksum table db1.t20240513; +---------------+------------+ | Table | Checksum | +---------------+------------+ | db1.t20240513 | 3988317094 | +---------------+------------+ MYSQL> select * from db1.t20240513; +------+ | aa | +------+ | -0 | | 0 | +------+ SHELL> mysqldump --databases db1 --table t20240513 --set-gtid-purged=off | mysql -D db1 MYSQL> checksum table db1.t20240513; +---------------+----------+ | Table | Checksum | +---------------+----------+ | db1.t20240513 | 56647878 | +---------------+----------+ MYSQL> select * from db1.t20240513; +------+ | aa | +------+ | 0 | | 0 | +------+
[13 May 2024 12:00]
MySQL Verification Team
Hi Mr. Yang, Yes, this is correct. This are typical characteristics of the IEEE floating point numbers. Expected behaviour.