If I try to create a system-versioned table with ROW START and ROW END columns of type DATETIME(6), the table is created. This is different from what happens if I try, for example, VARCHAR, in which case I get a clear error message. But then, the table is unusable.
MariaDB [test]> CREATEORREPLACETABLE t (
-> id INT UNSIGNED NOTNULL AUTO_INCREMENT,
-> label VARCHAR(50) NOTNULL,
->
-> PERIOD FOR SYSTEM_TIME (valid_from, valid_to),
-> valid_from DATETIME(6)
-> GENERATED ALWAYS AS ROW START,
-> valid_to DATETIME(6)
-> GENERATED ALWAYS AS ROW END,
->
-> PRIMARYKEY (id)
-> )
-> WITH SYSTEM VERSIONING,
-> ENGINE InnoDB
-> ;
Query OK, 0 rows affected (0.010 sec)
MariaDB [test]> INSERTINTO t (label) VALUES ('blah blah');
Query OK, 1 row affected (0.001 sec)
MariaDB [test]> SELECT * FROM t;
Empty set (0.000 sec)
And the reason is easy to find out:
MariaDB [test]> SELECT * FROM t FOR SYSTEM_TIME ALL;
An SQL-transaction has a transaction timestamp, a value of an implementation-defined timestamp type that is
used to set the values of system-time period start and system-time period end columns of rows, if any, modified
by the execution of an SQL-data change statement in this SQL-transaction.
We use MariaDB's TIMESTAMP data type (which is timestamp with local time zone) as this implementation defined type.
Translation from TIMESTAMP to DATETIME is lossy:
DATETIME preserves the YYYYMMDDhhmmss.ff part of the TIMESTAMP
but it looses the timezone information (i.e. the value of the @@time_zone system variable which was set at the conversion time)
It's not possible to restore the original TIMESTAMP value once it was converted to DATETIME, because the reverse conversion can already use a different @@time_zone value.
For me it does not seem to be useful storing ROW START / ROW END data in DATETIME or DATE columns.
We'll be adding TIMESTAMP WITH TIME ZONE soon. This new data type will support the full datetime range from '0001-01-01 00:00:00' to '9999-12-31 23:59:59' and will preserve both TIMESTAMP parts:
the YYYYMMDDhhmmss.ff part
the time zone part
so round trip conversion TIMESTAMP -> TIMESTAMP WITH TIME ZONE -> TIMESTAMP will be non-lossy.
It's a better candidate for ROW START and ROW END columns that DATETIME / DATE.
Alexander Barkov
added a comment - - edited 4.41.3 Properties of SQL-transactions says:
An SQL-transaction has a transaction timestamp, a value of an implementation-defined timestamp type that is
used to set the values of system-time period start and system-time period end columns of rows, if any, modified
by the execution of an SQL-data change statement in this SQL-transaction.
We use MariaDB's TIMESTAMP data type (which is timestamp with local time zone) as this implementation defined type.
Translation from TIMESTAMP to DATETIME is lossy:
DATETIME preserves the YYYYMMDDhhmmss.ff part of the TIMESTAMP
but it looses the timezone information (i.e. the value of the @@time_zone system variable which was set at the conversion time)
It's not possible to restore the original TIMESTAMP value once it was converted to DATETIME, because the reverse conversion can already use a different @@time_zone value.
For me it does not seem to be useful storing ROW START / ROW END data in DATETIME or DATE columns.
We'll be adding TIMESTAMP WITH TIME ZONE soon. This new data type will support the full datetime range from '0001-01-01 00:00:00' to '9999-12-31 23:59:59' and will preserve both TIMESTAMP parts:
the YYYYMMDDhhmmss.ff part
the time zone part
so round trip conversion TIMESTAMP -> TIMESTAMP WITH TIME ZONE -> TIMESTAMP will be non-lossy.
It's a better candidate for ROW START and ROW END columns that DATETIME / DATE.
Possible solution for DATETIME row_start, row_end might be to store in UTC. System fields independent from time_zone can be an advantage for certain deployments.
Aleksey Midenkov
added a comment - Possible solution for DATETIME row_start, row_end might be to store in UTC. System fields independent from time_zone can be an advantage for certain deployments.
@Alexander – "TIMESTAMP data type (which is timestamp with local time zone)" – I thought that `TIMESTAMP` was stored in UTC, without any timezone. (When viewing (SELECTing) it, the current timezone is used to modify what you see.)
That is, `TIMESTAMP` should be adequate, as is, for use in ROW_START, etc.
Rick James
added a comment - @Alexander – "TIMESTAMP data type (which is timestamp with local time zone)" – I thought that `TIMESTAMP` was stored in UTC, without any timezone. (When viewing (SELECTing) it, the current timezone is used to modify what you see.)
That is, `TIMESTAMP` should be adequate, as is, for use in ROW_START, etc.
People
Aleksey Midenkov
Federico Razzoli
Votes:
4Vote for this issue
Watchers:
10Start 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":1311.0999999046326,"ttfb":504.5,"pageVisibility":"visible","entityId":70281,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"87a6769c-ffdd-4e99-8f97-87ff2a76a7c7","navigationType":0,"readyForUser":1408.5999999046326,"redirectCount":0,"resourceLoadedEnd":1441.3000001907349,"resourceLoadedStart":516.1999998092651,"resourceTiming":[{"duration":213.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":516.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":516.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":730.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":214,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":516.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":516.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":730.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":284.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":516.5999999046326,"connectEnd":516.5999999046326,"connectStart":516.5999999046326,"domainLookupEnd":516.5999999046326,"domainLookupStart":516.5999999046326,"fetchStart":516.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":516.5999999046326,"responseEnd":801.0999999046326,"responseStart":801.0999999046326,"secureConnectionStart":516.5999999046326},{"duration":338.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":516.9000000953674,"connectEnd":516.9000000953674,"connectStart":516.9000000953674,"domainLookupEnd":516.9000000953674,"domainLookupStart":516.9000000953674,"fetchStart":516.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":516.9000000953674,"responseEnd":855.8000001907349,"responseStart":855.8000001907349,"secureConnectionStart":516.9000000953674},{"duration":342.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":517.0999999046326,"connectEnd":517.0999999046326,"connectStart":517.0999999046326,"domainLookupEnd":517.0999999046326,"domainLookupStart":517.0999999046326,"fetchStart":517.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":517.0999999046326,"responseEnd":859.9000000953674,"responseStart":859.9000000953674,"secureConnectionStart":517.0999999046326},{"duration":343.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":517.3000001907349,"connectEnd":517.3000001907349,"connectStart":517.3000001907349,"domainLookupEnd":517.3000001907349,"domainLookupStart":517.3000001907349,"fetchStart":517.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":517.3000001907349,"responseEnd":860.4000000953674,"responseStart":860.4000000953674,"secureConnectionStart":517.3000001907349},{"duration":343.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":517.5,"connectEnd":517.5,"connectStart":517.5,"domainLookupEnd":517.5,"domainLookupStart":517.5,"fetchStart":517.5,"redirectEnd":0,"redirectStart":0,"requestStart":517.5,"responseEnd":860.9000000953674,"responseStart":860.9000000953674,"secureConnectionStart":517.5},{"duration":445.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":517.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":517.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":963.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":343.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":517.8000001907349,"connectEnd":517.8000001907349,"connectStart":517.8000001907349,"domainLookupEnd":517.8000001907349,"domainLookupStart":517.8000001907349,"fetchStart":517.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":517.8000001907349,"responseEnd":861.5999999046326,"responseStart":861.5999999046326,"secureConnectionStart":517.8000001907349},{"duration":445.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":518,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":518,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":963.5,"responseStart":0,"secureConnectionStart":0},{"duration":344.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":518.0999999046326,"connectEnd":518.0999999046326,"connectStart":518.0999999046326,"domainLookupEnd":518.0999999046326,"domainLookupStart":518.0999999046326,"fetchStart":518.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":518.0999999046326,"responseEnd":862.1999998092651,"responseStart":862.1999998092651,"secureConnectionStart":518.0999999046326},{"duration":699.7000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":519.1999998092651,"connectEnd":519.1999998092651,"connectStart":519.1999998092651,"domainLookupEnd":519.1999998092651,"domainLookupStart":519.1999998092651,"fetchStart":519.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":519.1999998092651,"responseEnd":1218.9000000953674,"responseStart":1218.9000000953674,"secureConnectionStart":519.1999998092651},{"duration":898.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":530.9000000953674,"connectEnd":530.9000000953674,"connectStart":530.9000000953674,"domainLookupEnd":530.9000000953674,"domainLookupStart":530.9000000953674,"fetchStart":530.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":530.9000000953674,"responseEnd":1429.3000001907349,"responseStart":1429.3000001907349,"secureConnectionStart":530.9000000953674},{"duration":252.40000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":975.4000000953674,"connectEnd":975.4000000953674,"connectStart":975.4000000953674,"domainLookupEnd":975.4000000953674,"domainLookupStart":975.4000000953674,"fetchStart":975.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":975.4000000953674,"responseEnd":1227.8000001907349,"responseStart":1227.8000001907349,"secureConnectionStart":975.4000000953674},{"duration":187,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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&whisper-enabled=true","startTime":1254.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1254.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1441.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":175.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1255.3000001907349,"connectEnd":1255.3000001907349,"connectStart":1255.3000001907349,"domainLookupEnd":1255.3000001907349,"domainLookupStart":1255.3000001907349,"fetchStart":1255.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1255.3000001907349,"responseEnd":1430.5,"responseStart":1430.5,"secureConnectionStart":1255.3000001907349},{"duration":177,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/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.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1255.8000001907349,"connectEnd":1255.8000001907349,"connectStart":1255.8000001907349,"domainLookupEnd":1255.8000001907349,"domainLookupStart":1255.8000001907349,"fetchStart":1255.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1255.8000001907349,"responseEnd":1432.8000001907349,"responseStart":1432.8000001907349,"secureConnectionStart":1255.8000001907349},{"duration":280.3999996185303,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1298.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1298.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1579.1999998092651,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":288,"responseStart":504,"responseEnd":520,"domLoading":514,"domInteractive":1508,"domContentLoadedEventStart":1508,"domContentLoadedEventEnd":1568,"domComplete":1731,"loadEventStart":1731,"loadEventEnd":1731,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1477.3000001907349},{"name":"bigPipe.sidebar-id.end","time":1478.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1478.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1482.1999998092651},{"name":"activityTabFullyLoaded","time":1639.3000001907349}],"measures":[],"correlationId":"c404365d682208","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":150,"dbReadsTimeInMs":30,"dbConnsTimeInMs":41,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
It is already disallowed in 10.3. But `DATETIME` is not prohibited by standard, so it should be supported in 10.4.