Skip to content

Commit

Permalink
MDEV-29345 update case insensitive (large) unique key with insensitiv…
Browse files Browse the repository at this point in the history
…e change of value - duplicate key

use collation-sensitive comparison when comparing fields
  • Loading branch information
vuvova committed May 5, 2024
1 parent 91fb8b7 commit 947eeaa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
24 changes: 23 additions & 1 deletion mysql-test/main/long_unique_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -694,5 +694,27 @@ Hrecvx_0004ln-00 1
Hrecvx_0004mm-00 2
drop table t;
#
# End of 10.5 tests
# MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
#
create table t1 (a int, b text, unique (b));
insert ignore t1 values (1, 'a'), (2, 'A');
Warnings:
Warning 1062 Duplicate entry 'A' for key 'b'
select * from t1;
a b
1 a
update t1 set b='A' where a=1;
select * from t1;
a b
1 A
drop table t1;
create table t1 (a int, b blob, unique (b));
insert t1 values (1, 'a'), (2, 'A');
select * from t1;
a b
1 a
2 A
update t1 set b='A' where a=1;
ERROR 23000: Duplicate entry 'A' for key 'b'
drop table t1;
# End of 10.5 tests
17 changes: 16 additions & 1 deletion mysql-test/main/long_unique_bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -671,5 +671,20 @@ insert into t values ('Hrecvx_0004mm-00',2)
select * from t;
drop table t;
--echo #
--echo # End of 10.5 tests
--echo # MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
--echo #
create table t1 (a int, b text, unique (b));
insert ignore t1 values (1, 'a'), (2, 'A');
select * from t1;
update t1 set b='A' where a=1;
select * from t1;
drop table t1;

create table t1 (a int, b blob, unique (b));
insert t1 values (1, 'a'), (2, 'A');
select * from t1;
--error ER_DUP_ENTRY
update t1 set b='A' where a=1;
drop table t1;

--echo # End of 10.5 tests
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7082,7 +7082,7 @@ int handler::check_duplicate_long_entries_update(const uchar *new_rec)
So also check for that too
*/
if((field->is_null(0) != field->is_null(reclength)) ||
field->cmp_binary_offset(reclength))
field->cmp_offset(reclength))
{
if((error= check_duplicate_long_entry_key(new_rec, i)))
return error;
Expand Down

0 comments on commit 947eeaa

Please sign in to comment.