REPLACE is supposed to remove all conflicting rows.
For UNIQUE HASH, REPLACE only removes the first conflicting row, not all conflicting rows, and generates an error:
Test case:
create or replace table t1 (a int primary key, b int, c int, unique key `test` (b,c) using hash) engine=myisam;
|
insert into t1 values (1,1,1),(2,2,2);
|
replace into t1 values (3,1,1);
|
select * from t1;
|
--error 1062
|
replace into t1 values (3,2,2);
|
select * from t1;
|
+---+------+------+
|
| a | b | c |
|
+---+------+------+
|
| 3 | 1 | 1 |
|
| 2 | 2 | 2 |
|
+---+------+------+
|
Test without USING HASH
create or replace table t1 (a int primary key, b int, c int, unique key `test` (b,c)) engine=myisam;
|
insert into t1 values (1,1,1),(2,2,2);
|
replace into t1 values (3,1,1);
|
select * from t1;
|
replace into t1 values (3,2,2);
|
select * from t1;
|
+---+------+------+
|
| a | b | c |
|
+---+------+------+
|
| 3 | 2 | 2 |
|
+---+------+------+
|
- relates to
-
MDEV-32839
LONG UNIQUE gives error when used with REPLACE
-
-
Closed
{"report":{"fcp":1243.3000001907349,"ttfb":351.30000019073486,"pageVisibility":"visible","entityId":126449,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"3556509c-f17f-47e7-8b5c-16559e299cfd","navigationType":0,"readyForUser":1329.9000005722046,"redirectCount":0,"resourceLoadedEnd":974.3000001907349,"resourceLoadedStart":356.9000005722046,"resourceTiming":[{"duration":106.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":356.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":356.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":463.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":106.5,"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":357.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":357.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":463.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":419,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":357.4000005722046,"connectEnd":464.5,"connectStart":464.5,"domainLookupEnd":464.5,"domainLookupStart":464.5,"fetchStart":357.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":465.1000003814697,"responseEnd":776.4000005722046,"responseStart":479,"secureConnectionStart":464.5},{"duration":573.6999998092651,"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":357.6000003814697,"connectEnd":357.6000003814697,"connectStart":357.6000003814697,"domainLookupEnd":357.6000003814697,"domainLookupStart":357.6000003814697,"fetchStart":357.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":467.1000003814697,"responseEnd":931.3000001907349,"responseStart":482.5,"secureConnectionStart":357.6000003814697},{"duration":128.70000076293945,"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":358.19999980926514,"connectEnd":358.19999980926514,"connectStart":358.19999980926514,"domainLookupEnd":358.19999980926514,"domainLookupStart":358.19999980926514,"fetchStart":358.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":467.4000005722046,"responseEnd":486.9000005722046,"responseStart":485.30000019073486,"secureConnectionStart":358.19999980926514},{"duration":139.0999994277954,"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":358.4000005722046,"connectEnd":358.4000005722046,"connectStart":358.4000005722046,"domainLookupEnd":358.4000005722046,"domainLookupStart":358.4000005722046,"fetchStart":358.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":473,"responseEnd":497.5,"responseStart":494.1000003814697,"secureConnectionStart":358.4000005722046},{"duration":140.30000019073486,"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":358.69999980926514,"connectEnd":358.69999980926514,"connectStart":358.69999980926514,"domainLookupEnd":358.69999980926514,"domainLookupStart":358.69999980926514,"fetchStart":358.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":473.80000019073486,"responseEnd":499,"responseStart":495.80000019073486,"secureConnectionStart":358.69999980926514},{"duration":112.09999942779541,"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":358.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":358.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":471,"responseStart":0,"secureConnectionStart":0},{"duration":140.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":359,"connectEnd":359,"connectStart":359,"domainLookupEnd":359,"domainLookupStart":359,"fetchStart":359,"redirectEnd":0,"redirectStart":0,"requestStart":474.30000019073486,"responseEnd":499.19999980926514,"responseStart":496.30000019073486,"secureConnectionStart":359},{"duration":112.20000076293945,"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":359.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":359.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":471.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":143.39999961853027,"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":359.4000005722046,"connectEnd":359.4000005722046,"connectStart":359.4000005722046,"domainLookupEnd":359.4000005722046,"domainLookupStart":359.4000005722046,"fetchStart":359.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":474.9000005722046,"responseEnd":502.80000019073486,"responseStart":497.69999980926514,"secureConnectionStart":359.4000005722046},{"duration":606,"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":367.69999980926514,"connectEnd":367.69999980926514,"connectStart":367.69999980926514,"domainLookupEnd":367.69999980926514,"domainLookupStart":367.69999980926514,"fetchStart":367.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":632.8000001907349,"responseEnd":973.6999998092651,"responseStart":966.4000005722046,"secureConnectionStart":367.69999980926514},{"duration":606.6000003814697,"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":367.69999980926514,"connectEnd":367.69999980926514,"connectStart":367.69999980926514,"domainLookupEnd":367.69999980926514,"domainLookupStart":367.69999980926514,"fetchStart":367.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":803.8000001907349,"responseEnd":974.3000001907349,"responseStart":968.9000005722046,"secureConnectionStart":367.69999980926514},{"duration":244.20000076293945,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":913.1999998092651,"connectEnd":913.1999998092651,"connectStart":913.1999998092651,"domainLookupEnd":913.1999998092651,"domainLookupStart":913.1999998092651,"fetchStart":913.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1118,"responseEnd":1157.4000005722046,"responseStart":1156.8000001907349,"secureConnectionStart":913.1999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":169,"responseStart":351,"responseEnd":364,"domLoading":355,"domInteractive":1436,"domContentLoadedEventStart":1436,"domContentLoadedEventEnd":1492,"domComplete":2125,"loadEventStart":2125,"loadEventEnd":2126,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1413.4000005722046},{"name":"bigPipe.sidebar-id.end","time":1414.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1414.4000005722046},{"name":"bigPipe.activity-panel-pipe-id.end","time":1415.4000005722046},{"name":"activityTabFullyLoaded","time":1508.1999998092651}],"measures":[],"correlationId":"9ec3a141b436fc","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":104,"dbReadsTimeInMs":12,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Hello serg,
Please review a patch:
https://github.com/MariaDB/server/commit/424ee6eac783dd91d08305a9efff9347da6a6b4a