Bug #45875 bogus (?) zerofill flag in max(column)

Submitted: 1 Jul 2009 11:52 Modified: 1 Jul 2009 12:10
Reporter: Sergei Golubchik Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:any OS:Any
Assigned to: CPU Architecture:Any

[1 Jul 2009 11:52] Sergei Golubchik
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
[1 Jul 2009 12:10] Valeriy Kravchuk
Verified just as described with recent 5.1.37 from bzr.
[1 Jul 2009 12:11] Valeriy Kravchuk
ZEROFILL flag is present for max(a), min(a), but not for count(a) or avg(a)...

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.