Bug #120131 Bug in Query Behavior due to ZEROFILL in DOUBLE Column
Submitted: 23 Mar 11:27 Modified: 24 Mar 7:40
Reporter: b a Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.45 OS:Any
Assigned to: CPU Architecture:Any

[23 Mar 11:27] b a
Description:
This case highlights a bug caused by the use of ZEROFILL in a DOUBLE column, leading to inconsistent query behavior. In the first query, the c0 column is DOUBLE ZEROFILL, while the second query uses a standard DOUBLE. Both queries perform the same comparison (IFNULL(-1, '')) IN (t0.c0).

Expected Behavior: The ZEROFILL attribute should only affect the display of the value, padding it with zeros, without altering the underlying data. Therefore, the comparison between -1 and 0 should yield the same result in both queries. However, the queries return different results, which indicates a bug.

How to repeat:
```sql
-- query 1
drop database d0;
create database d0;
use d0;
CREATE TABLE IF NOT EXISTS t0(c0 DOUBLE ZEROFILL) ;
CREATE INDEX i0 ON t0(c0 DESC);
INSERT INTO t0(c0) VALUES(0);

SELECT c0 FROM t0 WHERE (IFNULL(-1, '')) IN (t0.c0); 

-- query 2
drop database d0;
create database d0;
use d0;
CREATE TABLE IF NOT EXISTS t0(c0 DOUBLE ) ;
CREATE INDEX i0 ON t0(c0 DESC);
INSERT INTO t0(c0) VALUES(0);

SELECT c0 FROM t0 WHERE (IFNULL(-1, '')) IN (t0.c0); 

-- result 1
+------------------------+
| c0                     |
+------------------------+
| 0000000000000000000000 |
+------------------------+
1 row in set (0.00 sec)

-- result 2

Empty set (0.00 sec)

```
[24 Mar 7:40] Roy Lyseng
Thank you for the bug report.
Verified as described.