[MDEV-19930] Since MariaDB 10.1 aggregate functions return different field type for columns with date values Created: 2019-07-02  Updated: 2019-07-05  Resolved: 2019-07-05

Status: Closed
Project: MariaDB Server
Component/s: Data types, Temporal Types
Affects Version/s: 10.1.40
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Stefan Langenmaier Assignee: Alexander Barkov
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

If I execute the following query on MariaDB 10.1 or later, the result contains a column with a datetime field type (MYSQL_TYPE_DATETIME):

`SELECT MIN(NOW()) AS t`

On older versions or any version of MySQL this column is a text type (MYSQL_TYPE_VAR_STRING).

https://dev.mysql.com/doc/dev/mysql-server/latest/field__types_8h.html

I'm not aware of a sql_mode compatibility flag so I consider this a bug.
I see why it's preferable/reasonable to return a datetime, but this behavior breaks existing applications.



 Comments   
Comment by Alexander Barkov [ 2019-07-05 ]

Old versions returned a wrong data type in the result set metadata, see this bug report:
MDEV-8875 Wrong metadata for MAX(CAST(time_column AS DATETIME))

This bug was fixed in 10.1.8. I'm afraid we cannot do anything here. Adding an sql_mode flag like EMULATE_BUG8875 does not sound like a reasonable idea.

Generated at Thu Feb 08 08:55:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.