Copying from YEAR to DATE result in '0000-00-00'

Description

These scripts:

1 2 3 4 5 6 DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 (a DATETIME); CREATE TABLE t2 (a YEAR); INSERT INTO t2 VALUES (2000); INSERT INTO t1 SELECT * FROM t2; SELECT * FROM t1;
1 2 3 4 5 6 DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a YEAR); INSERT INTO t1 VALUES (2000); ALTER TABLE t1 MODIFY a DATETIME; SHOW WARNINGS; SELECT * FROM t1;

return

1 2 3 4 5 +---------------------+ | a | +---------------------+ | 0000-00-00 00:00:00 | +---------------------+

The year value could be preserved when NO_ZERO_IN_DATE is not set.

Environment

None

Status

Assignee

Alexander Barkov

Reporter

Alexander Barkov

Labels

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

10.0
10.1
10.2
5.5

Priority

Major