Details
Description
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 |
|
+---+------+------+
|
Attachments
Issue Links
- relates to
-
MDEV-32839 LONG UNIQUE gives error when used with REPLACE
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Summary | long unique does not work like unique quey with replace | long unique does not work like unique key when using replace |
Link | This issue relates to MENT-1986 [ MENT-1986 ] |
Issue Type | Task [ 3 ] | Bug [ 1 ] |
Affects Version/s | 10.6 [ 24028 ] |
Description |
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); # This works replace into t1 values (3,1,1); select * from t1; --error 1062 replace into t1 values (3,2,2); select * from t1; {noformat} +---+------+------+ | a | b | c | +---+------+------+ | 3 | 1 | 1 | | 2 | 2 | 2 | +---+------+------+ {noformat} # 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; {noformat} +---+------+------+ | a | b | c | +---+------+------+ | 3 | 2 | 2 | +---+------+------+ {noformat} drop table t1; |
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: {code:sql} 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; {code} {noformat} +---+------+------+ | a | b | c | +---+------+------+ | 3 | 1 | 1 | | 2 | 2 | 2 | +---+------+------+ {noformat} Test without USING HASH {code:sql} 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; {code} {noformat} +---+------+------+ | a | b | c | +---+------+------+ | 3 | 2 | 2 | +---+------+------+ {noformat} |
Priority | Major [ 3 ] | Critical [ 2 ] |
Assignee | Sergei Golubchik [ serg ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Affects Version/s | 10.5 [ 23123 ] |
Fix Version/s | 10.5 [ 23123 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Status | Stalled [ 10000 ] | In Review [ 10002 ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Fix Version/s | 10.5.24 [ 29517 ] | |
Fix Version/s | 10.6.17 [ 29518 ] | |
Fix Version/s | 10.11.7 [ 29519 ] | |
Fix Version/s | 11.0.5 [ 29520 ] | |
Fix Version/s | 11.1.4 [ 29024 ] | |
Fix Version/s | 11.2.3 [ 29521 ] | |
Fix Version/s | 11.3.2 [ 29522 ] | |
Fix Version/s | 11.4.1 [ 29523 ] | |
Fix Version/s | 10.9.8 [ 29015 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | 10.6 [ 24028 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Zendesk Related Tickets | 144370 |
Hello serg,
Please review a patch:
https://github.com/MariaDB/server/commit/424ee6eac783dd91d08305a9efff9347da6a6b4a