Skip to content

Commit 9a0cbd3

Browse files
committed
MDEV-26294 Duplicate entries in unique index not detected when changing collation
ha_innobase::check_if_supported_inplace_alter(): Refuse to change the collation of a column that would become or remain indexed as part of the ALTER TABLE operation. In MariaDB Server 10.6, we will allow this type of operation; that fix depends on MDEV-15250.
1 parent 392ee57 commit 9a0cbd3

File tree

6 files changed

+249
-21
lines changed

6 files changed

+249
-21
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# MDEV-26294 Duplicate entries in unique index not detected when
3+
# changing collation with INPLACE algorithm
4+
#
5+
SET NAMES utf8;
6+
CREATE TABLE t1 (
7+
id INT PRIMARY KEY,
8+
msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_swedish_ci UNIQUE
9+
) ENGINE=INNODB;
10+
INSERT INTO t1 VALUES (1, 'aaa');
11+
INSERT INTO t1 VALUES (2, 'ååå');
12+
ALTER TABLE t1
13+
MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
14+
ALGORITHM=NOCOPY;
15+
ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Collation change on an indexed column. Try ALGORITHM=COPY
16+
ALTER TABLE t1 DROP INDEX msg,
17+
MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
18+
ALGORITHM=NOCOPY;
19+
DROP TABLE t1;

mysql-test/suite/innodb/r/instant_alter_charset,redundant.rdiff

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
--- instant_alter_charset.result 2019-06-17 14:36:02.311515062 +0300
2-
+++ instant_alter_charset,redundant.result 2019-06-17 14:50:11.888705725 +0300
3-
@@ -279,7 +279,6 @@
1+
@@ -288,7 +288,6 @@
42
alter table boundary_255
53
modify a varchar(70) charset utf8mb4,
64
algorithm=instant;
75
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
86
drop table boundary_255;
97
create table t (
108
a char(10) collate utf8mb3_general_ci,
11-
@@ -297,32 +296,21 @@
9+
@@ -306,35 +305,21 @@
1210
repeat('a', 10), repeat('a', 10)
1311
);
1412
alter table t modify a char(10) collate utf8mb4_general_ci, algorithm=instant;
@@ -27,25 +25,30 @@
2725
-test.t check status OK
2826
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
2927
alter table t modify aa char(10) collate utf8mb4_general_ci, algorithm=instant;
28+
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Collation change on an indexed column. Try ALGORITHM=COPY
3029
-check table t;
3130
-Table Op Msg_type Msg_text
3231
-test.t check status OK
3332
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
3433
alter table t modify bb char(70) collate utf8mb4_general_ci, algorithm=instant;
34+
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Collation change on an indexed column. Try ALGORITHM=COPY
3535
-check table t;
3636
-Table Op Msg_type Msg_text
3737
-test.t check status OK
3838
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
3939
alter table t modify cc char(100) collate utf8mb4_general_ci, algorithm=instant;
40+
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Collation change on an indexed column. Try ALGORITHM=COPY
4041
-check table t;
4142
-Table Op Msg_type Msg_text
4243
-test.t check status OK
4344
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
4445
alter table t modify d char(10) collate utf8mb4_spanish_ci, algorithm=instant;
4546
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
4647
alter table t modify dd char(10) collate utf8mb4_spanish_ci, algorithm=instant;
47-
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
48+
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Collation change on an indexed column. Try ALGORITHM=COPY
4849
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
4950
select * from t;
5051
a b c aa bb cc d dd
5152
aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
53+
54+
mysqltest: Result length mismatch

0 commit comments

Comments
 (0)