Skip to content

Commit 947eeaa

Browse files
committed
MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
use collation-sensitive comparison when comparing fields
1 parent 91fb8b7 commit 947eeaa

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

mysql-test/main/long_unique_bugs.result

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,5 +694,27 @@ Hrecvx_0004ln-00 1
694694
Hrecvx_0004mm-00 2
695695
drop table t;
696696
#
697-
# End of 10.5 tests
697+
# MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
698698
#
699+
create table t1 (a int, b text, unique (b));
700+
insert ignore t1 values (1, 'a'), (2, 'A');
701+
Warnings:
702+
Warning 1062 Duplicate entry 'A' for key 'b'
703+
select * from t1;
704+
a b
705+
1 a
706+
update t1 set b='A' where a=1;
707+
select * from t1;
708+
a b
709+
1 A
710+
drop table t1;
711+
create table t1 (a int, b blob, unique (b));
712+
insert t1 values (1, 'a'), (2, 'A');
713+
select * from t1;
714+
a b
715+
1 a
716+
2 A
717+
update t1 set b='A' where a=1;
718+
ERROR 23000: Duplicate entry 'A' for key 'b'
719+
drop table t1;
720+
# End of 10.5 tests

mysql-test/main/long_unique_bugs.test

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,5 +671,20 @@ insert into t values ('Hrecvx_0004mm-00',2)
671671
select * from t;
672672
drop table t;
673673
--echo #
674-
--echo # End of 10.5 tests
674+
--echo # MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
675675
--echo #
676+
create table t1 (a int, b text, unique (b));
677+
insert ignore t1 values (1, 'a'), (2, 'A');
678+
select * from t1;
679+
update t1 set b='A' where a=1;
680+
select * from t1;
681+
drop table t1;
682+
683+
create table t1 (a int, b blob, unique (b));
684+
insert t1 values (1, 'a'), (2, 'A');
685+
select * from t1;
686+
--error ER_DUP_ENTRY
687+
update t1 set b='A' where a=1;
688+
drop table t1;
689+
690+
--echo # End of 10.5 tests

sql/handler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7082,7 +7082,7 @@ int handler::check_duplicate_long_entries_update(const uchar *new_rec)
70827082
So also check for that too
70837083
*/
70847084
if((field->is_null(0) != field->is_null(reclength)) ||
7085-
field->cmp_binary_offset(reclength))
7085+
field->cmp_offset(reclength))
70867086
{
70877087
if((error= check_duplicate_long_entry_key(new_rec, i)))
70887088
return error;

0 commit comments

Comments
 (0)