|
I run this script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a TIMESTAMP);
|
DROP TABLE IF EXISTS t2;
|
CREATE TABLE t2 AS SELECT
|
MAX(a),
|
COALESCE(a),
|
COALESCE(MAX(a)),
|
MAX(COALESCE(a))
|
FROM t1;
|
SHOW CREATE TABLE t2;
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t2 | CREATE TABLE `t2` (
|
`MAX(a)` timestamp NULL DEFAULT NULL,
|
`COALESCE(a)` timestamp NULL DEFAULT NULL,
|
`COALESCE(MAX(a))` timestamp NULL DEFAULT NULL,
|
`MAX(COALESCE(a))` datetime DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
Notice, it creates TIMESTAMP fields for all expression but MAX(COALESCE(a)). Looks confusing.
Moreover, if I run the client as:
mysql --column-type-info test
|
and execute this script:
SELECT
|
MAX(a),
|
COALESCE(a),
|
COALESCE(MAX(a)),
|
MAX(COALESCE(a))
|
FROM t1;
|
Field 1: `MAX(a)`
|
Type: TIMESTAMP
|
...
|
Field 2: `COALESCE(a)`
|
Type: TIMESTAMP
|
...
|
Field 3: `COALESCE(MAX(a))`
|
Type: TIMESTAMP
|
...
|
Field 4: `MAX(COALESCE(a))`
|
Type: TIMESTAMP
|
Collation: binary (63)
|
It correctly reports TIMESTAP for all columns.
|