The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
Example:
SELECT VERSION();
|
|
DROP TABLE IF EXISTS `t1`;
|
DROP SEQUENCE IF EXISTS `s1`;
|
|
CREATE SEQUENCE IF NOT EXISTS `s1`;
|
|
CREATE TABLE IF NOT EXISTS `t1` (
|
`a` BIGINT UNSIGNED NOT NULL PRIMARY KEY
|
DEFAULT (NEXT VALUE FOR `s1`),
|
`b` CHAR(1) NOT NULL
|
) ENGINE=InnoDB;
|
|
SHOW CREATE TABLE `s1`;
|
|
INSERT INTO `t1` (`b`) VALUES ('a');
|
INSERT INTO `t1` (`b`) VALUES ('b'), ('c');
|
INSERT INTO `t1` (`b`) VALUES ('d');
|
INSERT INTO `t1` (`b`)
|
SELECT `c`
|
FROM (
|
SELECT 'e' `c`
|
UNION
|
SELECT 'f' `c`
|
UNION
|
SELECT 'g' `c`
|
) `der`;
|
|
SELECT
|
`a`, `b`
|
FROM
|
`t1`;
|
Result:
VERSION() |
10.6.9-MariaDB-1:10.6.9+maria~deb11 |
Table |
Create Table |
s1 |
CREATE TABLE `s1` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
) ENGINE=InnoDB SEQUENCE=1 |
a |
b |
1 |
a |
 |
2 |
b |
 |
3 |
c |
 |
4 |
d |
 |
6 |
e |
 |
8 |
f |
 |
10 |
g |
 |
See dbfiddle.
Related bug: MDEV-17037.
- causes
-
MDEV-30342
Wrong "Truncated incorrect DECIMAL value" warning/error in recent releases
-
-
Closed
- links to
-
{"report":{"fcp":976.3000000715256,"ttfb":318.7000000476837,"pageVisibility":"visible","entityId":114690,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"74044bb1-5dd0-4245-9cab-e5fd29e0595a","navigationType":0,"readyForUser":1044.9000000953674,"redirectCount":0,"resourceLoadedEnd":1034.5,"resourceLoadedStart":323.10000002384186,"resourceTiming":[{"duration":227.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":323.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":323.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":551,"responseStart":0,"secureConnectionStart":0},{"duration":223.69999992847443,"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":327.3000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":327.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":551,"responseStart":0,"secureConnectionStart":0},{"duration":232.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":327.5,"connectEnd":327.5,"connectStart":327.5,"domainLookupEnd":327.5,"domainLookupStart":327.5,"fetchStart":327.5,"redirectEnd":0,"redirectStart":0,"requestStart":327.5,"responseEnd":560.1000000238419,"responseStart":560.1000000238419,"secureConnectionStart":327.5},{"duration":278.10000002384186,"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":327.8000000715256,"connectEnd":327.8000000715256,"connectStart":327.8000000715256,"domainLookupEnd":327.8000000715256,"domainLookupStart":327.8000000715256,"fetchStart":327.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":327.8000000715256,"responseEnd":605.9000000953674,"responseStart":605.9000000953674,"secureConnectionStart":327.8000000715256},{"duration":282,"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":327.90000009536743,"connectEnd":327.90000009536743,"connectStart":327.90000009536743,"domainLookupEnd":327.90000009536743,"domainLookupStart":327.90000009536743,"fetchStart":327.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":327.90000009536743,"responseEnd":609.9000000953674,"responseStart":609.8000000715256,"secureConnectionStart":327.90000009536743},{"duration":282.3000000715256,"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":328,"connectEnd":328,"connectStart":328,"domainLookupEnd":328,"domainLookupStart":328,"fetchStart":328,"redirectEnd":0,"redirectStart":0,"requestStart":328,"responseEnd":610.3000000715256,"responseStart":610.3000000715256,"secureConnectionStart":328},{"duration":282.60000002384186,"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":328.10000002384186,"connectEnd":328.10000002384186,"connectStart":328.10000002384186,"domainLookupEnd":328.10000002384186,"domainLookupStart":328.10000002384186,"fetchStart":328.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":328.10000002384186,"responseEnd":610.7000000476837,"responseStart":610.7000000476837,"secureConnectionStart":328.10000002384186},{"duration":282.89999997615814,"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":328.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":328.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":611.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":282.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":328.3000000715256,"connectEnd":328.3000000715256,"connectStart":328.3000000715256,"domainLookupEnd":328.3000000715256,"domainLookupStart":328.3000000715256,"fetchStart":328.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":328.3000000715256,"responseEnd":611.1000000238419,"responseStart":611.1000000238419,"secureConnectionStart":328.3000000715256},{"duration":283.09999990463257,"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":328.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":328.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":611.5,"responseStart":0,"secureConnectionStart":0},{"duration":283.10000002384186,"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":328.60000002384186,"connectEnd":328.60000002384186,"connectStart":328.60000002384186,"domainLookupEnd":328.60000002384186,"domainLookupStart":328.60000002384186,"fetchStart":328.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":328.60000002384186,"responseEnd":611.7000000476837,"responseStart":611.7000000476837,"secureConnectionStart":328.60000002384186},{"duration":693.0999999046326,"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":340.90000009536743,"connectEnd":340.90000009536743,"connectStart":340.90000009536743,"domainLookupEnd":340.90000009536743,"domainLookupStart":340.90000009536743,"fetchStart":340.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":340.90000009536743,"responseEnd":1034,"responseStart":1034,"secureConnectionStart":340.90000009536743},{"duration":692,"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":342.5,"connectEnd":342.5,"connectStart":342.5,"domainLookupEnd":342.5,"domainLookupStart":342.5,"fetchStart":342.5,"redirectEnd":0,"redirectStart":0,"requestStart":342.5,"responseEnd":1034.5,"responseStart":1034.5,"secureConnectionStart":342.5},{"duration":208,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":785,"connectEnd":785,"connectStart":785,"domainLookupEnd":785,"domainLookupStart":785,"fetchStart":785,"redirectEnd":0,"redirectStart":0,"requestStart":785,"responseEnd":993,"responseStart":993,"secureConnectionStart":785},{"duration":208.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":955.3000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":955.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1163.8000000715256,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":78,"responseStart":319,"responseEnd":343,"domLoading":322,"domInteractive":1147,"domContentLoadedEventStart":1147,"domContentLoadedEventEnd":1189,"domComplete":2062,"loadEventStart":2062,"loadEventEnd":2063,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1127.6000000238419},{"name":"bigPipe.sidebar-id.end","time":1128.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":1128.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":1131},{"name":"activityTabFullyLoaded","time":1195.9000000953674}],"measures":[],"correlationId":"ce90bae2318b4e","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":165,"dbReadsTimeInMs":8,"dbConnsTimeInMs":15,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}