Wrong character set of ADDTIME() and DATE_ADD()

Description

ADDTIME(expr1,expr2) is a hybrid function.

  • In case when expr1 is DATETIME, the result type is DATETIME.

  • In case when expr1 is TIME, the result type is TIME.

  • Otherwise, the result type is VARCHAR, and the choice between
    DATETIME or TIME format is done per-row.

In case of VARCHAR result, the function must follow the standard
MySQL/MariaDB convention:
character set and collation of a string function returning a result
from numeric or temporal input should be set according to
@@character_set_connection and @@collation_connection
respectively.

http://dev.mysql.com/doc/refman/5.6/en/type-conversion.html

In MySQL 5.6, implicit conversion of a numeric or temporal value to string produces a value that has a character set and collation determined by the character_set_connection and collation_connection system variables.

Consider this SQL script:

MySQL-5.6 does follow this rule, and the output is:

Notice: ucs2 is consistently reported in both tables in the output.

MariaDB does not follow this rule, and the output is:

Moreover, the result of CHARSET() and of "SHOW CREATE" do not
match to each over (binary vs latin1).

The same problem is observed with another temporal hybrid function DATE_ADD.
The script:

Results from MySQL-5.6 are consistently correct:

Result from MariaDB-10.0 are wrong and non-consistent:

Environment

None

Status

Assignee

Alexander Barkov

Reporter

Alexander Barkov

Labels

None

External issue ID

None

External issue ID

None

Fix versions

Affects versions

Priority

Minor
Configure