Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
10.0.4, 5.5.31, 5.3.12
-
None
-
None
Description
The function MAKETIME() in MariaDB does not preserve fractional digits:
MariaDB [test]> SELECT MAKETIME(10,10,10.231); |
+------------------------+ |
| MAKETIME(10,10,10.231) |
|
+------------------------+ |
| 10:10:10 |
|
+------------------------+ |
1 row in set (0.00 sec) |
It works as expected in MySQL-5.6:
MySQL [test]> SELECT MAKETIME(10,10,10.231); |
+------------------------+ |
| MAKETIME(10,10,10.231) |
|
+------------------------+ |
| 10:10:10.231 |
|
+------------------------+ |
1 row in set (0.00 sec) |
A possibly related problem:
MariaDB [test]> SELECT MAKETIME(0, 0, 59.9);
|
+----------------------+
|
| MAKETIME(0, 0, 59.9) |
|
+----------------------+
|
| NULL |
|
+----------------------+
|
The above result is wrong.
It seems 59.9 is rounded to 60, which makes a wrong time '00:00:60', hence NULL.
The expected result is '00:00:59.9'.
More examples:
MariaDB [test]> drop table if exists t1; create table t1 as select time('10:00:00'); show create table t1; |
Query OK, 0 rows affected (0.00 sec) |
Query OK, 1 row affected (0.10 sec)
|
Records: 1 Duplicates: 0 Warnings: 0
|
+-------+------------------------------------------------------------------------------------------------------+ |
| Table | Create Table | |
+-------+------------------------------------------------------------------------------------------------------+ |
| t1 | CREATE TABLE `t1` ( |
`time('10:00:00')` time(6) DEFAULT NULL |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | |
+-------+------------------------------------------------------------------------------------------------------+ |
1 row in set (0.00 sec) |
The expected column type is time(0).
for maketime it was kind of intentional. it used to take three integers, and it still does. feel free to change it, if you'd like.
the second issue is a duplicate of
MDEV-3922