Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 12.2.2
Description
The valid fractional boundary `0.999999` is accepted by the string-to-time
conversion path but rejected by the numeric conversion path. Adjacent value
`0.999998` is included to show the boundary behavior. The two conversion paths
should agree for valid fractional time values, but MariaDB returns `NULL` and a
warning for the numeric cast at this boundary.
DROP DATABASE IF EXISTS db; |
CREATE DATABASE db; |
USE db; |
|
|
CREATE TABLE t ( |
id INT PRIMARY KEY, |
p INT NOT NULL, |
o INT NOT NULL, |
v INT NOT NULL, |
od DECIMAL(20,10) NOT NULL |
);
|
|
|
INSERT INTO t VALUES |
(1, 1, 1, 10, 0.999999),
|
(2, 1, 2, 20, 0.999998);
|
|
|
SELECT 'scalar_compare' AS phase; |
SELECT id, |
CAST(od AS TIME(6)) AS num_cast, |
CAST(CAST(od AS CHAR) AS TIME(6)) AS char_cast |
FROM t |
ORDER BY id; |
SHOW WARNINGS;
|
|
|
SELECT 'numeric_cast_query' AS phase; |
SELECT id, |
ROW_NUMBER() OVER (PARTITION BY p ORDER BY o) AS rn, |
CAST(od AS TIME(6)) AS tm |
FROM t |
ORDER BY id; |
SHOW WARNINGS;
|
|
|
SELECT 'string_cast_query' AS phase; |
SELECT t1.id, |
(SELECT COUNT(*) FROM t AS t2 WHERE t2.p = t1.p AND t2.o <= t1.o) AS rn, |
CAST(CAST(t1.od AS CHAR) AS TIME(6)) AS tm |
FROM t AS t1 |
ORDER BY t1.id; |
SHOW WARNINGS;
|
|
|
DROP DATABASE db; |
Expected Result
Numeric and stringified casts should agree for valid fractional time values.
Actual Result
The numeric cast returns `NULL` with a warning for `0.999999`; the stringified
reference returns `00:00:00.999999`.