Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
-
None
Description
SELECT
|
COALESCE(TIME'800:00:00', NOW()) AS c, |
HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; |
+---------------------+------+
|
| c | hc |
|
+---------------------+------+
|
| 2018-03-22 08:00:00 | 800 |
|
+---------------------+------+
|
The result for hc is wrong. It returns HOURS() of the first argument of COALESCE() before its conversion to DATETIME. The expected result is to return hours after conversion, i,e. 8, like the hour part in the first column c.
The same problem is repeatable with CASE and its abbreviations:
SELECT
|
CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, |
HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; |
SELECT
|
IFNULL(TIME'800:00:00', NOW()) AS c, |
HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; |
SELECT
|
IF(TRUE,TIME'800:00:00', NOW()) AS c, |
HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; |
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
-
- Closed
-
-
MDEV-8894 Inserting fractional seconds into MySQL 5.6 master breaks consistency on MariaDB 10 slave
-
- Closed
-
- is duplicated by
-
MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Environment |
{code:sql}
SELECT COALESCE(TIME'800:00:00', NOW()) AS c, HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; {code} {noformat} +---------------------+------+ | c | hc | +---------------------+------+ | 2018-03-22 08:00:00 | 800 | +---------------------+------+ {noformat} The result for {{hc}} is wrong. It returns {{HOURS()}} of the first argument of {{COALESCE()}} before its conversion to {{DATETIME}}. The expected result is to return hours after conversion, i,e. {{8}}, like the hour part in the first column {{c}}. {code:sql} SELECT CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; {code} {code:sql} SELECT IFNULL(TIME'800:00:00', NOW()) AS c, HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; {code} {code:sql} SELECT IF(TRUE,TIME'800:00:00', NOW()) AS c, HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; {code} |
Description |
{code:sql}
SELECT COALESCE(TIME'800:00:00', NOW()) AS c, HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; {code} {noformat} +---------------------+------+ | c | hc | +---------------------+------+ | 2018-03-22 08:00:00 | 800 | +---------------------+------+ {noformat} The result for {{hc}} is wrong. It returns {{HOURS()}} of the first argument of {{COALESCE()}} before its conversion to {{DATETIME}}. The expected result is to return hours after conversion, i,e. {{8}}, like the hour part in the first column {{c}}. {code:sql} SELECT CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; {code} {code:sql} SELECT IFNULL(TIME'800:00:00', NOW()) AS c, HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; {code} {code:sql} SELECT IF(TRUE,TIME'800:00:00', NOW()) AS c, HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; {code} |
Description |
{code:sql}
SELECT COALESCE(TIME'800:00:00', NOW()) AS c, HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; {code} {noformat} +---------------------+------+ | c | hc | +---------------------+------+ | 2018-03-22 08:00:00 | 800 | +---------------------+------+ {noformat} The result for {{hc}} is wrong. It returns {{HOURS()}} of the first argument of {{COALESCE()}} before its conversion to {{DATETIME}}. The expected result is to return hours after conversion, i,e. {{8}}, like the hour part in the first column {{c}}. {code:sql} SELECT CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; {code} {code:sql} SELECT IFNULL(TIME'800:00:00', NOW()) AS c, HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; {code} {code:sql} SELECT IF(TRUE,TIME'800:00:00', NOW()) AS c, HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; {code} |
{code:sql}
SELECT COALESCE(TIME'800:00:00', NOW()) AS c, HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; {code} {noformat} +---------------------+------+ | c | hc | +---------------------+------+ | 2018-03-22 08:00:00 | 800 | +---------------------+------+ {noformat} The result for {{hc}} is wrong. It returns {{HOURS()}} of the first argument of {{COALESCE()}} before its conversion to {{DATETIME}}. The expected result is to return hours after conversion, i,e. {{8}}, like the hour part in the first column {{c}}. The same problem is repeatable with {{CASE}} and its abbreviations: {code:sql} SELECT CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; {code} {code:sql} SELECT IFNULL(TIME'800:00:00', NOW()) AS c, HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; {code} {code:sql} SELECT IF(TRUE,TIME'800:00:00', NOW()) AS c, HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; {code} |
issue.field.resolutiondate | 2018-02-19 19:45:24.0 | 2018-02-19 19:45:24.099 |
Fix Version/s | 10.3.5 [ 22905 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Link |
This issue is duplicated by |
Workflow | MariaDB v3 [ 85623 ] | MariaDB v4 [ 153816 ] |
A related problem:
SELECT
+------+------+----------+----------+
| c1 | c2 | c3 | c4 |
+------+------+----------+----------+
| NULL | NULL | 34:20:30 | 34:20:30 |
+------+------+----------+----------+
The result for c3 and c4 is wrong. The expected result is NULL for all four columns.