monty, this task is a pre-requisite for MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temporal arithmetics.
The problem is that all date/time arithmetic functions currently implement only DATETIME input and DATETIME output.
When called with a TIMESTAMP input, these functions involve TIMESTAMP->DATETIME conversion on input and optionally DATETIME->TIMESTAMP conversion on output.
These both conversions are lossy because of DST changes and leap seconds.
But implementing native TIMESTAMP arithmetic is rather meaningless because of a very narrow value range.
Alexander Barkov
added a comment - monty , this task is a pre-requisite for MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temporal arithmetics.
The problem is that all date/time arithmetic functions currently implement only DATETIME input and DATETIME output.
When called with a TIMESTAMP input, these functions involve TIMESTAMP->DATETIME conversion on input and optionally DATETIME->TIMESTAMP conversion on output.
These both conversions are lossy because of DST changes and leap seconds.
But implementing native TIMESTAMP arithmetic is rather meaningless because of a very narrow value range.
Currently, if arithmetic works by doing TIMESTAMP->DATETIME->TIMESTAMP conversion. It makes total sense to remove conversions and make arithmetic works on TIMESTAMP values. This alone doesn't need any wider value range, what was out of range in TIMESTAMP->DATETIME->TIMESTAMP will stay out of range, but DST bugs will disappear.
Widening the TIMESTAMP range is a separate task, mostly unrelated to how arithmetic is done.
Sergei Golubchik
added a comment - I don't think it is meaningless.
Currently, if arithmetic works by doing TIMESTAMP->DATETIME->TIMESTAMP conversion. It makes total sense to remove conversions and make arithmetic works on TIMESTAMP values. This alone doesn't need any wider value range, what was out of range in TIMESTAMP->DATETIME->TIMESTAMP will stay out of range, but DST bugs will disappear.
Widening the TIMESTAMP range is a separate task, mostly unrelated to how arithmetic is done.
Now it returns a DATETIME out of the TIMESTAMP supported range. It works, but imprecisely.
If we change the returned type to TIMESTAMP, it will return an out-of-range error.
Alexander Barkov
added a comment - It's not clear what to do with queries like this:
SELECT DATE_ADD(timestamp_field, INTERVAL 200 YEAR );
Now it returns a DATETIME out of the TIMESTAMP supported range. It works, but imprecisely.
If we change the returned type to TIMESTAMP, it will return an out-of-range error.
People
Unassigned
Alexander Barkov
Votes:
0Vote for this issue
Watchers:
5Start watching this issue
Dates
Created:
Updated:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1013,"ttfb":292.40000000596046,"pageVisibility":"visible","entityId":125825,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"60f2938c-76b2-4029-b266-fe4e57455656","navigationType":0,"readyForUser":1079.0999999940395,"redirectCount":0,"resourceLoadedEnd":661.5,"resourceLoadedStart":305,"resourceTiming":[{"duration":48.400000005960464,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":305,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":305,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":353.40000000596046,"responseStart":0,"secureConnectionStart":0},{"duration":48.29999998211861,"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":305.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":305.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":353.59999999403954,"responseStart":0,"secureConnectionStart":0},{"duration":218.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":305.59999999403954,"connectEnd":305.59999999403954,"connectStart":305.59999999403954,"domainLookupEnd":305.59999999403954,"domainLookupStart":305.59999999403954,"fetchStart":305.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":357,"responseEnd":524.0999999940395,"responseStart":372.30000001192093,"secureConnectionStart":305.59999999403954},{"duration":355.40000000596046,"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":306.09999999403954,"connectEnd":306.09999999403954,"connectStart":306.09999999403954,"domainLookupEnd":306.09999999403954,"domainLookupStart":306.09999999403954,"fetchStart":306.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":357.30000001192093,"responseEnd":661.5,"responseStart":376,"secureConnectionStart":306.09999999403954},{"duration":67.59999999403954,"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":306.40000000596046,"connectEnd":306.40000000596046,"connectStart":306.40000000596046,"domainLookupEnd":306.40000000596046,"domainLookupStart":306.40000000596046,"fetchStart":306.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":358.30000001192093,"responseEnd":374,"responseStart":370.80000001192093,"secureConnectionStart":306.40000000596046},{"duration":74.40000000596046,"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":306.59999999403954,"connectEnd":306.59999999403954,"connectStart":306.59999999403954,"domainLookupEnd":306.59999999403954,"domainLookupStart":306.59999999403954,"fetchStart":306.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":359.40000000596046,"responseEnd":381,"responseStart":378,"secureConnectionStart":306.59999999403954},{"duration":78,"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":306.69999998807907,"connectEnd":306.69999998807907,"connectStart":306.69999998807907,"domainLookupEnd":306.69999998807907,"domainLookupStart":306.69999998807907,"fetchStart":306.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":360.30000001192093,"responseEnd":384.69999998807907,"responseStart":381.40000000596046,"secureConnectionStart":306.69999998807907},{"duration":52.599999994039536,"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":306.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":306.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":359.40000000596046,"responseStart":0,"secureConnectionStart":0},{"duration":78.09999999403954,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":307,"connectEnd":307,"connectStart":307,"domainLookupEnd":307,"domainLookupStart":307,"fetchStart":307,"redirectEnd":0,"redirectStart":0,"requestStart":362.40000000596046,"responseEnd":385.09999999403954,"responseStart":382.30000001192093,"secureConnectionStart":307},{"duration":53.5,"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":307.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":307.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":360.69999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":80,"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":307.40000000596046,"connectEnd":307.40000000596046,"connectStart":307.40000000596046,"domainLookupEnd":307.40000000596046,"domainLookupStart":307.40000000596046,"fetchStart":307.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":363.80000001192093,"responseEnd":387.40000000596046,"responseStart":385.69999998807907,"secureConnectionStart":307.40000000596046},{"duration":283.69999998807907,"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":321.5,"connectEnd":321.5,"connectStart":321.5,"domainLookupEnd":321.5,"domainLookupStart":321.5,"fetchStart":321.5,"redirectEnd":0,"redirectStart":0,"requestStart":482.5,"responseEnd":605.1999999880791,"responseStart":599,"secureConnectionStart":321.5},{"duration":283.80000001192093,"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":321.59999999403954,"connectEnd":321.59999999403954,"connectStart":321.59999999403954,"domainLookupEnd":321.59999999403954,"domainLookupStart":321.59999999403954,"fetchStart":321.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":483.80000001192093,"responseEnd":605.4000000059605,"responseStart":599.8000000119209,"secureConnectionStart":321.59999999403954},{"duration":119.09999999403954,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":650.0999999940395,"connectEnd":650.0999999940395,"connectStart":650.0999999940395,"domainLookupEnd":650.0999999940395,"domainLookupStart":650.0999999940395,"fetchStart":650.0999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":738.3000000119209,"responseEnd":769.1999999880791,"responseStart":768,"secureConnectionStart":650.0999999940395}],"fetchStart":0,"domainLookupStart":80,"domainLookupEnd":89,"connectStart":89,"connectEnd":107,"secureConnectionStart":97,"requestStart":108,"responseStart":292,"responseEnd":320,"domLoading":296,"domInteractive":1179,"domContentLoadedEventStart":1179,"domContentLoadedEventEnd":1231,"domComplete":1760,"loadEventStart":1760,"loadEventEnd":1760,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1155.300000011921},{"name":"bigPipe.sidebar-id.end","time":1156.199999988079},{"name":"bigPipe.activity-panel-pipe-id.start","time":1156.300000011921},{"name":"bigPipe.activity-panel-pipe-id.end","time":1158.0999999940395},{"name":"activityTabFullyLoaded","time":1253.199999988079}],"measures":[],"correlationId":"f7e378797998a6","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":108,"dbReadsTimeInMs":17,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
bar, if possible, do not use ulong. It is a very badly portable type. for usec, int32_t is more than enough.