[MDEV-19502] TIME_ROUND_FRACTIONAL is not respected on TIME->BIGINT conversion Created: 2019-05-17  Updated: 2019-05-17

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: Compatibility, compat57

Issue Links:
Relates
relates to MDEV-16991 Rounding vs truncation for TIME, DATE... Closed
relates to MDEV-8919 Wrong result for CAST(999999999999999... Closed

 Description   

MySQL rounds fractional seconds on implicit TIME->BIGINT conversion and on explicit CAST:

SET sql_mode=''; -- MySQL rounds by default
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIGINT);
INSERT INTO t1 VALUES (TIME'-00:00:01.6');
SELECT a, CAST(TIME'-00:00:01.6' AS SIGNED) FROM t1;

+------+-----------------------------------+
| a    | CAST(TIME'-00:00:01.6' AS SIGNED) |
+------+-----------------------------------+
|   -2 |                                -2 |
+------+-----------------------------------+

MariaDB truncates:

SET sql_mode='TIME_ROUND_FRACTIONAL';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIGINT);
INSERT INTO t1 VALUES (TIME'-00:00:01.6');
SELECT a, CAST(TIME'-00:00:01.6' AS SIGNED) FROM t1;

+------+-----------------------------------+
| a    | CAST(TIME'-00:00:01.6' AS SIGNED) |
+------+-----------------------------------+
|   -1 |                                -1 |
+------+-----------------------------------+


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