Bug #19223 Union on zerofilled fields eats 'zerofilling'
Submitted: 20 Apr 2006 14:51 Modified: 15 May 2006 14:18
Reporter: Juri Shimon Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.0.20/5.0BK/5.1BK/4.1BK OS:Windows (Windows/Suse Linux)
Assigned to: Georgi Kodinov CPU Architecture:Any

[20 Apr 2006 14:51] Juri Shimon
Description:
Union on tables with zerofilled values returns values without leading zeros.

How to repeat:
> create table a (id integer zerofill);
> insert into a values(1),(2),(3);

> select * from a;
+------------+
| id         |
+------------+
| 0000000001 |
| 0000000002 |
| 0000000003 |
+------------+

> select * from a union select * from a;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
[20 Apr 2006 15:28] MySQL Verification Team
Thank you for the bug report. Verified as reported.
[20 Apr 2006 15:36] Valeriy Kravchuk
Same (wrong) results on 5.0.21-BK. CREATE TABLE aa SELECT * FROM a preserves "zerofill" property, while UNION and UNION ALL - not. It is a bug.
[15 May 2006 14:18] Georgi Kodinov
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

This is a duplicate of bug#9707 "UNIONs trim leading zeros in ZEROFILL fields".