Make "CAST(time_expr AS DATETIME)" compatible with MySQL-5.6 (and the SQL Standard)

Description

CAST(time_expr AS DATETIME) and CAST(time_expr AS DATE)
work differently in MariaDB-10.0 and MySQL-5.6.

MySQL-5.6:

MariaDB-10.0:

Starting from the version 5.6, MySQL switched to the SQL Standard
behaviour when casting TIME to DATETIME, i.e. by adding CURRENT_DATE
to the time value.

MySQL-5.6 also uses CURRENT_DATE when casting from TIME to DATE for consistency
(this is a non-standard extension, the standard disallows CAST from TIME to DATE).

Pre-5.6 versions of MySQL did not use CURRENT_DATE when doing such casts.
MariaDB-10.0 still demonstrates the pre-5.6 behaviour.

Note, Oracle 11g also uses the standard behaviour:

An excerpt from the SQL standard, Section 6.12 <cast specification>:

Environment

None

Assignee

Alexander Barkov

Reporter

Alexander Barkov

Labels

None

Fix versions

Priority

Blocker
Configure