Description:
metadata of an operation on a zerofill column sometimes contain the zerofill flag, while the value is not zero-filled
How to repeat:
mysql> create table t1 (a int zerofill);
Query OK, 0 rows affected (0.02 sec)
mysql> insert t1 values (1);
Query OK, 1 row affected (0.01 sec)
mysql> select * from t1;
Field 1: `a`
Catalog: `def`
Database: `test`
Table: `t1`
Org_table: `t1`
Type: LONG
Collation: binary (63)
Length: 10
Max_length: 10
Decimals: 0
Flags: UNSIGNED ZEROFILL NUM
+------------+
| a |
+------------+
| 0000000001 |
+------------+
1 row in set (0.00 sec)
---- fine. ZEROFILL flag in the metadata, the value is zero-filled
mysql> select a+1 from t1;
Field 1: `a+1`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: LONGLONG
Collation: binary (63)
Length: 12
Max_length: 1
Decimals: 0
Flags: UNSIGNED BINARY NUM
+------+
| a+1 |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
---- ZEROFILL flag was dropped. ok.
mysql> select max(a) from t1;
Field 1: `max(a)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: LONG
Collation: binary (63)
Length: 10
Max_length: 1
Decimals: 0
Flags: UNSIGNED ZEROFILL NUM
+--------+
| max(a) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
---- ZEROFILL flag is present, but the value is not zero-filled !
Suggested fix:
either drop the zerofill flag or zero-fill the value