The documentation days:
The NO_ZERO_DATE mode affects whether the server permits '0000-00-00' as a valid date. Its effect also depends on whether strict SQL mode is enabled.
But it does not say if DATETIME values with zero YYYYMMDD and non-zero hhmmss.uuuuuu parts (e.g. '0000-00 10:20:30') is permitted.
Different parts of the code tread it differently for DATETIME.
Example1: '0000-00-00 10:20:30' is not permitted
SET sql_mode='NO_ZERO_DATE';
|
SELECT TIMESTAMP'0000-00-00 10:20:30', TIMESTAMP'0000-00-01 10:20:30';
|
returns
+--------------------------------+--------------------------------+
|
| TIMESTAMP'0000-00-00 10:20:30' | TIMESTAMP'0000-00-01 10:20:30' |
|
+--------------------------------+--------------------------------+
|
| NULL | 0000-00-01 10:20:30 |
|
+--------------------------------+--------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
That is only the YYYYMMDD part is used to decide if the value is "ZERO DATE".
Example2: '0000-00-00 10:20:30' behaves differently in the same script:
SET sql_mode='NO_ZERO_DATE';
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a DATETIME);
|
INSERT INTO t1 VALUES ('0000-00-00 10:20:30');
|
SELECT a, LEAST(a,'2001-01-01 10:20:30') FROM t1;
|
returns:
+---------------------+--------------------------------+
|
| a | LEAST(a,'2001-01-01 10:20:30') |
|
+---------------------+--------------------------------+
|
| 0000-00-00 10:20:30 | NULL |
|
+---------------------+--------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
That is INSERT and "SELECT a FROM t1" treated '0000-00-00 10:20:30' as a permitted value, while LEAST() treated it as a non-permitted value.
It should be fixed to treat in the same way in all context.
Example3:
SET sql_mode='NO_ZERO_DATE';
|
SELECT STR_TO_DATE('0000-00-00 10:20:30','%Y-%m-%d %h:%i:%s');
|
Example4:
SET sql_mode='NO_ZERO_DATE';
|
SELECT TIMESTAMP'0000-00-00 10:20:30';
|
Exapmple 5:
SET old_mode=zero_date_time_cast;
|
SET SQL_MODE='NO_ZERO_DATE';
|
SELECT CAST(TIME'10:20:30' AS DATETIME);
|
Example 6:
SET old_mode=zero_date_time_cast;
|
SET SQL_MODE='NO_ZERO_DATE';
|
SELECT CAST((CAST('10:20:30' AS TIME)) AS DATETIME);
|
Example 7:
SET old_mode=zero_date_time_cast;
|
SET SQL_MODE='NO_ZERO_DATE';
|
SELECT CAST((CAST(TIMESTAMP'0000-00-00 10:20:30' AS TIME)) AS DATETIME);
|
There are no comments yet on this issue.
{"report":{"fcp":868.8999999761581,"ttfb":163.60000002384186,"pageVisibility":"visible","entityId":51840,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"b86cc156-dc2d-4914-8314-a3cf84e8f8a6","navigationType":0,"readyForUser":947.6000000238419,"redirectCount":0,"resourceLoadedEnd":1097.199999988079,"resourceLoadedStart":169.30000001192093,"resourceTiming":[{"duration":182.30000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":169.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":169.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":351.60000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":182.39999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":169.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":169.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":351.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":190.9000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":169.69999998807907,"connectEnd":169.69999998807907,"connectStart":169.69999998807907,"domainLookupEnd":169.69999998807907,"domainLookupStart":169.69999998807907,"fetchStart":169.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":169.69999998807907,"responseEnd":360.60000002384186,"responseStart":360.60000002384186,"secureConnectionStart":169.69999998807907},{"duration":227,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":169.89999997615814,"connectEnd":169.89999997615814,"connectStart":169.89999997615814,"domainLookupEnd":169.89999997615814,"domainLookupStart":169.89999997615814,"fetchStart":169.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":169.89999997615814,"responseEnd":396.89999997615814,"responseStart":396.89999997615814,"secureConnectionStart":169.89999997615814},{"duration":230.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":170.19999998807907,"connectEnd":170.19999998807907,"connectStart":170.19999998807907,"domainLookupEnd":170.19999998807907,"domainLookupStart":170.19999998807907,"fetchStart":170.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":170.19999998807907,"responseEnd":400.39999997615814,"responseStart":400.39999997615814,"secureConnectionStart":170.19999998807907},{"duration":230.5999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":170.30000001192093,"connectEnd":170.30000001192093,"connectStart":170.30000001192093,"domainLookupEnd":170.30000001192093,"domainLookupStart":170.30000001192093,"fetchStart":170.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":170.30000001192093,"responseEnd":400.89999997615814,"responseStart":400.89999997615814,"secureConnectionStart":170.30000001192093},{"duration":230.80000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":170.5,"connectEnd":170.5,"connectStart":170.5,"domainLookupEnd":170.5,"domainLookupStart":170.5,"fetchStart":170.5,"redirectEnd":0,"redirectStart":0,"requestStart":170.5,"responseEnd":401.30000001192093,"responseStart":401.30000001192093,"secureConnectionStart":170.5},{"duration":330.4000000357628,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":170.69999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":170.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":501.10000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":230.80000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":170.89999997615814,"connectEnd":170.89999997615814,"connectStart":170.89999997615814,"domainLookupEnd":170.89999997615814,"domainLookupStart":170.89999997615814,"fetchStart":170.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":170.89999997615814,"responseEnd":401.69999998807907,"responseStart":401.69999998807907,"secureConnectionStart":170.89999997615814},{"duration":330.19999998807907,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":171.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":171.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":501.30000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":231.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":171.19999998807907,"connectEnd":171.19999998807907,"connectStart":171.19999998807907,"domainLookupEnd":171.19999998807907,"domainLookupStart":171.19999998807907,"fetchStart":171.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":171.19999998807907,"responseEnd":402.30000001192093,"responseStart":402.30000001192093,"secureConnectionStart":171.19999998807907},{"duration":494.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":172.10000002384186,"connectEnd":172.10000002384186,"connectStart":172.10000002384186,"domainLookupEnd":172.10000002384186,"domainLookupStart":172.10000002384186,"fetchStart":172.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":172.10000002384186,"responseEnd":666.6000000238419,"responseStart":666.6000000238419,"secureConnectionStart":172.10000002384186},{"duration":914.1000000238419,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":172.19999998807907,"connectEnd":172.19999998807907,"connectStart":172.19999998807907,"domainLookupEnd":172.19999998807907,"domainLookupStart":172.19999998807907,"fetchStart":172.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":172.19999998807907,"responseEnd":1086.300000011921,"responseStart":1086.300000011921,"secureConnectionStart":172.19999998807907},{"duration":154.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":512.5,"connectEnd":512.5,"connectStart":512.5,"domainLookupEnd":512.5,"domainLookupStart":512.5,"fetchStart":512.5,"redirectEnd":0,"redirectStart":0,"requestStart":512.5,"responseEnd":667,"responseStart":667,"secureConnectionStart":512.5},{"duration":326.0999999642372,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":771.1000000238419,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":771.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1097.199999988079,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":11,"responseStart":164,"responseEnd":167,"domLoading":167,"domInteractive":1106,"domContentLoadedEventStart":1106,"domContentLoadedEventEnd":1145,"domComplete":1568,"loadEventStart":1568,"loadEventEnd":1569,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1088},{"name":"bigPipe.sidebar-id.end","time":1088.8999999761581},{"name":"bigPipe.activity-panel-pipe-id.start","time":1089.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.end","time":1089.6000000238419},{"name":"activityTabFullyLoaded","time":1151}],"measures":[],"correlationId":"eb083c8e4dbf47","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":88,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}