Type:
Bug
Priority:
Blocker
Resolution:
Fixed
Affects Version/s:
None
Component/s:
None
CAST(time_expr AS DATETIME) and CAST(time_expr AS DATE)
work differently in MariaDB-10.0 and MySQL-5.6.
MySQL-5.6:
mysql> SELECT CURRENT_DATE, CAST(TIME'48:10:10' AS DATETIME), CAST(TIME'48:10:10' AS DATE);
+--------------+----------------------------------+------------------------------+
| CURRENT_DATE | CAST(TIME'48:10:10' AS DATETIME) | CAST(TIME'48:10:10' AS DATE) |
+--------------+----------------------------------+------------------------------+
| 2013-12-02 | 2013-12-04 00:10:10 | 2013-12-04 |
+--------------+----------------------------------+------------------------------+
1 row in set (0.00 sec)
MariaDB-10.0:
mysql> SELECT CURRENT_DATE, CAST(TIME'48:10:10' AS DATETIME), CAST(TIME'48:10:10' AS DATE);
+--------------+----------------------------------+------------------------------+
| CURRENT_DATE | CAST(TIME'48:10:10' AS DATETIME) | CAST(TIME'48:10:10' AS DATE) |
+--------------+----------------------------------+------------------------------+
| 2013-12-02 | 0000-00-02 00:10:10 | 0000-00-00 |
+--------------+----------------------------------+------------------------------+
1 row in set (0.01 sec)
Starting from the version 5.6, MySQL switched to the SQL Standard
behaviour when casting TIME to DATETIME, i.e. by adding CURRENT_DATE
to the time value.
MySQL-5.6 also uses CURRENT_DATE when casting from TIME to DATE for consistency
(this is a non-standard extension, the standard disallows CAST from TIME to DATE).
Pre-5.6 versions of MySQL did not use CURRENT_DATE when doing such casts.
MariaDB-10.0 still demonstrates the pre-5.6 behaviour.
Note, Oracle 11g also uses the standard behaviour:
SQL> SELECT CURRENT_DATE, CAST(TIME'10:10:10' AS TIMESTAMP) FROM DUAL;
CURRENT_DATE
------------------
CAST(TIME'10:10:10'ASTIMESTAMP)
---------------------------------------------------------------------------
02-DEC-13
02-DEC-13 10.10.10.000000 AM
An excerpt from the SQL standard, Section 6.12 <cast specification>:
<cast specification> ::= CAST <left paren> <cast operand> AS <cast target> <right paren>
<cast operand> ::= <value expression> | <null specification> | <empty specification>
.. let TD be the data type identified by <data type>
.. let SD be the declared type of the <value expression>
.. SV is the source value
.. TV is the target value
17) If TD is the datetime data type TIMESTAMP WITHOUT TIME ZONE...
c) If SD is TIME WITHOUT TIME ZONE, then the <primary datetime field>s
year, month, and day of TV are set to their respective values in an execution
of CURRENT_DATE and the <primary datetime field>s hour, minute, and second
of TV are set to their respective values in SV, with implementation-
defined rounding or truncation if necessary.
{"report":{"fcp":742.3999998569489,"ttfb":147.39999985694885,"pageVisibility":"visible","entityId":27301,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"88074907-28af-49a1-8292-8e11c911fea1","navigationType":0,"readyForUser":802.5,"redirectCount":0,"resourceLoadedEnd":735.7000000476837,"resourceLoadedStart":151.59999990463257,"resourceTiming":[{"duration":129.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":151.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":151.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":280.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":129.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":151.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":151.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":280.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":137.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":151.89999985694885,"connectEnd":151.89999985694885,"connectStart":151.89999985694885,"domainLookupEnd":151.89999985694885,"domainLookupStart":151.89999985694885,"fetchStart":151.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":151.89999985694885,"responseEnd":289.7999999523163,"responseStart":289.7000000476837,"secureConnectionStart":151.89999985694885},{"duration":209.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":152.09999990463257,"connectEnd":152.09999990463257,"connectStart":152.09999990463257,"domainLookupEnd":152.09999990463257,"domainLookupStart":152.09999990463257,"fetchStart":152.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":152.09999990463257,"responseEnd":361.2000000476837,"responseStart":361.2000000476837,"secureConnectionStart":152.09999990463257},{"duration":212.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":152.20000004768372,"connectEnd":152.20000004768372,"connectStart":152.20000004768372,"domainLookupEnd":152.20000004768372,"domainLookupStart":152.20000004768372,"fetchStart":152.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":152.20000004768372,"responseEnd":364.7000000476837,"responseStart":364.7000000476837,"secureConnectionStart":152.20000004768372},{"duration":212.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":152.29999995231628,"connectEnd":152.29999995231628,"connectStart":152.29999995231628,"domainLookupEnd":152.29999995231628,"domainLookupStart":152.29999995231628,"fetchStart":152.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":152.29999995231628,"responseEnd":365.2000000476837,"responseStart":365.2000000476837,"secureConnectionStart":152.29999995231628},{"duration":213.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":152.39999985694885,"connectEnd":152.39999985694885,"connectStart":152.39999985694885,"domainLookupEnd":152.39999985694885,"domainLookupStart":152.39999985694885,"fetchStart":152.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":152.39999985694885,"responseEnd":365.59999990463257,"responseStart":365.59999990463257,"secureConnectionStart":152.39999985694885},{"duration":213.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":152.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":152.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":366.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":213.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":152.59999990463257,"connectEnd":152.59999990463257,"connectStart":152.59999990463257,"domainLookupEnd":152.59999990463257,"domainLookupStart":152.59999990463257,"fetchStart":152.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":152.59999990463257,"responseEnd":366.09999990463257,"responseStart":366.09999990463257,"secureConnectionStart":152.59999990463257},{"duration":213.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":152.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":152.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":366.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":213.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":152.79999995231628,"connectEnd":152.79999995231628,"connectStart":152.79999995231628,"domainLookupEnd":152.79999995231628,"domainLookupStart":152.79999995231628,"fetchStart":152.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":152.79999995231628,"responseEnd":366.59999990463257,"responseStart":366.59999990463257,"secureConnectionStart":152.79999995231628},{"duration":381.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":158.29999995231628,"connectEnd":158.29999995231628,"connectStart":158.29999995231628,"domainLookupEnd":158.29999995231628,"domainLookupStart":158.29999995231628,"fetchStart":158.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":158.29999995231628,"responseEnd":539.5,"responseStart":539.5,"secureConnectionStart":158.29999995231628},{"duration":577.1000001430511,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":158.59999990463257,"connectEnd":158.59999990463257,"connectStart":158.59999990463257,"domainLookupEnd":158.59999990463257,"domainLookupStart":158.59999990463257,"fetchStart":158.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":158.59999990463257,"responseEnd":735.7000000476837,"responseStart":735.7000000476837,"secureConnectionStart":158.59999990463257},{"duration":191.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":502.59999990463257,"connectEnd":502.59999990463257,"connectStart":502.59999990463257,"domainLookupEnd":502.59999990463257,"domainLookupStart":502.59999990463257,"fetchStart":502.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":502.59999990463257,"responseEnd":693.7999999523163,"responseStart":693.7999999523163,"secureConnectionStart":502.59999990463257}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":27,"responseStart":147,"responseEnd":159,"domLoading":150,"domInteractive":854,"domContentLoadedEventStart":854,"domContentLoadedEventEnd":895,"domComplete":1670,"loadEventStart":1670,"loadEventEnd":1671,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":836.2999999523163},{"name":"bigPipe.sidebar-id.end","time":837.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":837.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":840.2000000476837},{"name":"activityTabFullyLoaded","time":900.5999999046326}],"measures":[],"correlationId":"e84f95eee31b2f","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":64,"dbReadsTimeInMs":8,"dbConnsTimeInMs":14,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}