Add a session server variable @@system_versioning_insert_history which allows to use ROW_START and ROW_END columns in the INSERT (unless they are normal visible (in SELECT *) fields, they have to be explicitly specified in INSERT as any invisible fields are). And if @@secure_timestamp allows the current user to modify @@timestamp then he should be able to insert directly into ROW_START/ROW_END columns.
The use case of this is to be able to dump the history with mysqldump and to load it back later (MDEV-16029). It provides a convenient way to have a row in the system versioned table with row_start=A and row_end=B. Without @@system_versioning_insert_history it can be achieved with
set @@timestamp=A;
insert t1 values (...);
set @@timestamp=B;
deletefrom t1 where ... -- a condition to match the row that was just inserted
So this new feature does not provide any new functionality, but allows to load the history dump much faster than with timestamp manipulations as above. In particular it does not allow to do anything that wasn't possible to do before, it requires exactly the same set of privileges as the snippet above, and is subject to the same set of restrictions.
Attachments
Issue Links
blocks
MDEV-16029mysqldump: dump and restore historical data
Closed
causes
MDEV-29674History modification inserts records into a wrong partition without warning
Stalled
MDEV-29721Inconsistency upon inserting history with visible system versioning columns
Closed
MDEV-29722History modification requires specifying values for both period columns
Closed
MDEV-29732mysqlbinlog produces syntactically incorrect output with system_versioning_insert_history
Closed
MDEV-29738REPLACE under system_versioning_insert_history allows to change existing historical records
Closed
MDEV-29741SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on
Fixed. It should not go into Item_field::fix_fields() because there is no explicit field list (so no Item_field). It uses different fill_record() for implicit field list, that's normal.
Aleksey Midenkov
added a comment - Fixed. It should not go into Item_field::fix_fields() because there is no explicit field list (so no Item_field). It uses different fill_record() for implicit field list, that's normal.
I wanted to split THD::vers_insert_history(Field *) into Field::vers_insert_history(THD *) and THD::vers_insert_history(). But they both cannot be inline (or it sort of hard to rule out without inline files) because Field::vers_insert_history(THD *) must call THD::vers_insert_history() but sql_class.h is not included into field.h. serg, I remember about your inline request.
Aleksey Midenkov
added a comment - I wanted to split THD::vers_insert_history(Field *) into Field::vers_insert_history(THD *) and THD::vers_insert_history() . But they both cannot be inline (or it sort of hard to rule out without inline files) because Field::vers_insert_history(THD *) must call THD::vers_insert_history() but sql_class.h is not included into field.h . serg , I remember about your inline request.
+insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
you'll see that values are ignored
Sergei Golubchik
added a comment - midenok , you haven't fixed the issue yet. You don't have the test case for it. If you do
-insert into t3(z, row_start, row_end) values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
+insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
you'll see that values are ignored
the final implementation allows INSERT, CREATE .. INSERT, and LOAD; does not allow REPLACE, LOAD .. REPLACE, UPDATE, INSERT .. ON DUPLICATE KEY UPDATE
in addition to sufficient permissions to change the timestamp, the user performing the operation naturally also needs standard grants for inserting into the table;
the variable is already in the KB, but the description needs to indicate that it only applies to timestamp-based versioning;
while inserting history into a versioned table with limit-based partitioning, the user must be aware of MDEV-29674, all injected historical rows are inserted into the first partition. It may be fixed in future;
in general, functionality is mainly aimed for re-loading the real history by the means of mysqldump / restoration. While arbitrary history inserting also works, the effect may be not quite what the user expects to achieve.
Elena Stepanova
added a comment - I have no objections against pushing bb-10.11- MDEV-16546 as of 87fca0525 into 10.11 branch and releasing it with 10.11.1.
Some notes in no particular order ( greenman FYI):
the final implementation allows INSERT , CREATE .. INSERT , and LOAD ; does not allow REPLACE , LOAD .. REPLACE , UPDATE , INSERT .. ON DUPLICATE KEY UPDATE
in addition to sufficient permissions to change the timestamp, the user performing the operation naturally also needs standard grants for inserting into the table;
the variable is already in the KB , but the description needs to indicate that it only applies to timestamp-based versioning;
while inserting history into a versioned table with limit-based partitioning, the user must be aware of MDEV-29674 , all injected historical rows are inserted into the first partition. It may be fixed in future;
in general, functionality is mainly aimed for re-loading the real history by the means of mysqldump / restoration. While arbitrary history inserting also works, the effect may be not quite what the user expects to achieve.
see also notes in MDEV-16029 .
People
Sergei Golubchik
Aleksey Midenkov
Votes:
8Vote for this issue
Watchers:
17Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1743.8999998569489,"ttfb":351.59999990463257,"pageVisibility":"visible","entityId":68267,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"1ec805c2-6a97-48a6-9216-72a782ed9c39","navigationType":0,"readyForUser":1878.5,"redirectCount":0,"resourceLoadedEnd":1445.5,"resourceLoadedStart":406.69999980926514,"resourceTiming":[{"duration":319.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":406.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":406.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":726.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":320,"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":407,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":407,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":727,"responseStart":0,"secureConnectionStart":0},{"duration":817.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":407.19999980926514,"connectEnd":407.19999980926514,"connectStart":407.19999980926514,"domainLookupEnd":407.19999980926514,"domainLookupStart":407.19999980926514,"fetchStart":407.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":749.2999999523163,"responseEnd":1224.3999998569489,"responseStart":874,"secureConnectionStart":407.19999980926514},{"duration":1022.5,"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":407.2999999523163,"connectEnd":407.2999999523163,"connectStart":407.2999999523163,"domainLookupEnd":407.2999999523163,"domainLookupStart":407.2999999523163,"fetchStart":407.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":749,"responseEnd":1429.7999999523163,"responseStart":867.5999999046326,"secureConnectionStart":407.2999999523163},{"duration":482.7999999523163,"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":407.5,"connectEnd":407.5,"connectStart":407.5,"domainLookupEnd":407.5,"domainLookupStart":407.5,"fetchStart":407.5,"redirectEnd":0,"redirectStart":0,"requestStart":749.7999999523163,"responseEnd":890.2999999523163,"responseStart":874.7999999523163,"secureConnectionStart":407.5},{"duration":482.7000000476837,"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":407.7999999523163,"connectEnd":407.7999999523163,"connectStart":407.7999999523163,"domainLookupEnd":407.7999999523163,"domainLookupStart":407.7999999523163,"fetchStart":407.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":750,"responseEnd":890.5,"responseStart":877.5,"secureConnectionStart":407.7999999523163},{"duration":482.7999999523163,"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":408,"connectEnd":408,"connectStart":408,"domainLookupEnd":408,"domainLookupStart":408,"fetchStart":408,"redirectEnd":0,"redirectStart":0,"requestStart":750.2999999523163,"responseEnd":890.7999999523163,"responseStart":881.7999999523163,"secureConnectionStart":408},{"duration":319.89999985694885,"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":408.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":408.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":728.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":482.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":408.39999985694885,"connectEnd":408.39999985694885,"connectStart":408.39999985694885,"domainLookupEnd":408.39999985694885,"domainLookupStart":408.39999985694885,"fetchStart":408.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":750.3999998569489,"responseEnd":891,"responseStart":883.8999998569489,"secureConnectionStart":408.39999985694885},{"duration":320.09999990463257,"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":408.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":408.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":728.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":496.39999985694885,"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":408.7999999523163,"connectEnd":408.7999999523163,"connectStart":408.7999999523163,"domainLookupEnd":408.7999999523163,"domainLookupStart":408.7999999523163,"fetchStart":408.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":750.5,"responseEnd":905.1999998092651,"responseStart":888.5999999046326,"secureConnectionStart":408.7999999523163},{"duration":1030.9000000953674,"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":411.39999985694885,"connectEnd":411.39999985694885,"connectStart":411.39999985694885,"domainLookupEnd":411.39999985694885,"domainLookupStart":411.39999985694885,"fetchStart":411.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":1161.0999999046326,"responseEnd":1442.2999999523163,"responseStart":1406.1999998092651,"secureConnectionStart":411.39999985694885},{"duration":1034.1000001430511,"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":411.39999985694885,"connectEnd":411.39999985694885,"connectStart":411.39999985694885,"domainLookupEnd":411.39999985694885,"domainLookupStart":411.39999985694885,"fetchStart":411.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":929.8999998569489,"responseEnd":1445.5,"responseStart":1428.2999999523163,"secureConnectionStart":411.39999985694885},{"duration":266.10000014305115,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1417.6999998092651,"connectEnd":1417.6999998092651,"connectStart":1417.6999998092651,"domainLookupEnd":1417.6999998092651,"domainLookupStart":1417.6999998092651,"fetchStart":1417.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1641.3999998569489,"responseEnd":1683.7999999523163,"responseStart":1671.8999998569489,"secureConnectionStart":1417.6999998092651},{"duration":256.7999999523163,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1735.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1735.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1992.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":272.10000014305115,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1752.3999998569489,"connectEnd":1752.3999998569489,"connectStart":1752.3999998569489,"domainLookupEnd":1752.3999998569489,"domainLookupStart":1752.3999998569489,"fetchStart":1752.3999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":1930.7999999523163,"responseEnd":2024.5,"responseStart":1961.2999999523163,"secureConnectionStart":1752.3999998569489}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":95,"responseStart":352,"responseEnd":369,"domLoading":375,"domInteractive":2014,"domContentLoadedEventStart":2014,"domContentLoadedEventEnd":2069,"domComplete":2624,"loadEventStart":2624,"loadEventEnd":2624,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1994.3999998569489},{"name":"bigPipe.sidebar-id.end","time":1995.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1995.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":1997.0999999046326},{"name":"activityTabFullyLoaded","time":2098.0999999046326}],"measures":[],"correlationId":"91d293af3bdb7d","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":145,"dbReadsTimeInMs":37,"dbConnsTimeInMs":49,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Fixed. It should not go into Item_field::fix_fields() because there is no explicit field list (so no Item_field). It uses different fill_record() for implicit field list, that's normal.