Bug #79518 Get inconsistent string when converting year column to char
Submitted: 4 Dec 2015 7:42 Modified: 7 Dec 2015 6:59
Reporter: Su Dylan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.8, 5.5.48, 5.6.29, 5.7.11 OS:Any
Assigned to: CPU Architecture:Any

[4 Dec 2015 7:42] Su Dylan
Description:
Output:
=======
mysql> drop table t1; create table t1(a year, b char(10));
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.02 sec)

mysql> insert into t1(a) values (0);
selQuery OK, 1 row affected (0.00 sec)

mysql> update t1 set b = a;
ect *, cast(a as char) from t1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select *, cast(a as char) from t1;
+------+------+-----------------+
| a    | b    | cast(a as char) |
+------+------+-----------------+
| 0000 | 0    | 0000            |
+------+------+-----------------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.8-rc  |
+-----------+
1 row in set (0.00 sec)

Problem:
========
After "update t1 set b = a", column b and cast(a as char) are expected to return the same string.

How to repeat:

drop table t1; create table t1(a year, b char(10));
insert into t1(a) values (0);
update t1 set b = a;
select *, cast(a as char) from t1;

Suggested fix:
After "update t1 set b = a", column b and cast(a as char) are expected to return the same string.
[7 Dec 2015 6:59] MySQL Verification Team
Hello Su Dylan,

Thank you for the report.

Thanks,
Umesh