diff --git a/cmd/explaintest/r/collation_misc_disabled.result b/cmd/explaintest/r/collation_misc_disabled.result index 20b3d9db10a9e..a9ee8ac04631f 100644 --- a/cmd/explaintest/r/collation_misc_disabled.result +++ b/cmd/explaintest/r/collation_misc_disabled.result @@ -14,11 +14,7 @@ select * from t; a t_value alter table t modify column a varchar(20) charset utf8; -admin check table t; - -select * from t; -a -t_value +Error 8200: Unsupported modify charset from latin1 to utf8 drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); @@ -31,7 +27,7 @@ t_value drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); -alter table t modify column a varchar(20) charset utf8 collate utf8_bin; +alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; admin check table t; select * from t; @@ -40,7 +36,8 @@ t_value drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); -alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; +alter table t modify column a varchar(20) charset utf8 collate utf8_bin; +Error 8200: Unsupported modify charset from latin1 to utf8 alter table t modify column a varchar(20) charset utf8mb4 collate utf8bin; [ddl:1273]Unknown collation: 'utf8bin' alter table t collate LATIN1_GENERAL_CI charset utf8 collate utf8_bin; @@ -53,15 +50,6 @@ insert into t values ("t_value"); alter table t modify column a varchar(19) charset utf8mb4; admin check table t; -select * from t; -a -t_value -drop table t; -create table t(a varchar(20) charset latin1); -insert into t values ("t_value"); -alter table t modify column a varchar(19) charset utf8 collate utf8_bin; -admin check table t; - select * from t; a t_value diff --git a/cmd/explaintest/r/collation_misc_enabled.result b/cmd/explaintest/r/collation_misc_enabled.result index 687ea0486e046..38161ba4ca6a6 100644 --- a/cmd/explaintest/r/collation_misc_enabled.result +++ b/cmd/explaintest/r/collation_misc_enabled.result @@ -14,11 +14,7 @@ select * from t; a t_value alter table t modify column a varchar(20) charset utf8; -admin check table t; - -select * from t; -a -t_value +Error 8200: Unsupported modify charset from latin1 to utf8 drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); @@ -31,7 +27,7 @@ t_value drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); -alter table t modify column a varchar(20) charset utf8 collate utf8_bin; +alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; admin check table t; select * from t; @@ -40,7 +36,8 @@ t_value drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); -alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; +alter table t modify column a varchar(20) charset utf8 collate utf8_bin; +Error 8200: Unsupported modify charset from latin1 to utf8 alter table t modify column a varchar(20) charset utf8mb4 collate utf8bin; [ddl:1273]Unknown collation: 'utf8bin' alter table t collate LATIN1_GENERAL_CI charset utf8 collate utf8_bin; @@ -53,15 +50,6 @@ insert into t values ("t_value"); alter table t modify column a varchar(19) charset utf8mb4; admin check table t; -select * from t; -a -t_value -drop table t; -create table t(a varchar(20) charset latin1); -insert into t values ("t_value"); -alter table t modify column a varchar(19) charset utf8 collate utf8_bin; -admin check table t; - select * from t; a t_value diff --git a/cmd/explaintest/t/collation_misc.test b/cmd/explaintest/t/collation_misc.test index e77fea4d783fd..d46d3a27aa8b1 100644 --- a/cmd/explaintest/t/collation_misc.test +++ b/cmd/explaintest/t/collation_misc.test @@ -13,9 +13,8 @@ insert into t values ("t_value"); alter table t modify column a varchar(20) charset latin1; select * from t; +--error 8200 alter table t modify column a varchar(20) charset utf8; -admin check table t; -select * from t; drop table t; create table t(a varchar(20) charset latin1); @@ -27,7 +26,7 @@ select * from t; drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); -alter table t modify column a varchar(20) charset utf8 collate utf8_bin; +alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; admin check table t; select * from t; @@ -35,7 +34,7 @@ drop table t; create table t(a varchar(20) charset latin1); insert into t values ("t_value"); --error 8200 -alter table t modify column a varchar(20) charset utf8mb4 collate utf8mb4_general_ci; +alter table t modify column a varchar(20) charset utf8 collate utf8_bin; --error 1273 alter table t modify column a varchar(20) charset utf8mb4 collate utf8bin; --error 1302, 1273 @@ -51,13 +50,6 @@ alter table t modify column a varchar(19) charset utf8mb4; admin check table t; select * from t; -drop table t; -create table t(a varchar(20) charset latin1); -insert into t values ("t_value"); -alter table t modify column a varchar(19) charset utf8 collate utf8_bin; -admin check table t; -select * from t; - # TestCharsetDatabase create database if not exists cd_test_utf8 CHARACTER SET utf8 COLLATE utf8_bin; --error 1273 diff --git a/ddl/db_integration_test.go b/ddl/db_integration_test.go index 74d3621d8ab07..e2d9cb33e01f2 100644 --- a/ddl/db_integration_test.go +++ b/ddl/db_integration_test.go @@ -770,9 +770,7 @@ func TestChangingTableCharset(t *testing.T) { tk.MustGetErrCode("alter table t charset utf8 collate latin1_bin", errno.ErrCollationCharsetMismatch) tk.MustGetErrCode("alter table t charset utf8 collate utf8mb4_bin;", errno.ErrCollationCharsetMismatch) tk.MustGetErrCode("alter table t charset utf8 collate utf8_bin collate utf8mb4_bin collate utf8_bin;", errno.ErrCollationCharsetMismatch) - - tk.MustExec("alter table t charset utf8") - tk.MustExec("admin check table t") + tk.MustGetErrCode("alter table t charset utf8", errno.ErrUnsupportedDDLOperation) tk.MustExec("drop table if exists t") tk.MustExec("create table t(a char(10), index i(a)) charset latin1 collate latin1_bin") @@ -806,8 +804,7 @@ func TestChangingTableCharset(t *testing.T) { tk.MustExec("create table t(a varchar(20), key i(a)) charset=latin1") tk.MustGetErrCode("alter table t convert to charset utf8 collate utf8_unicode_ci", errno.ErrUnsupportedDDLOperation) tk.MustGetErrCode("alter table t convert to charset utf8 collate utf8_general_ci", errno.ErrUnsupportedDDLOperation) - tk.MustExec("alter table t convert to charset utf8 collate utf8_bin") - tk.MustGetErrCode("alter table t convert to charset latin1", errno.ErrUnsupportedDDLOperation) + tk.MustGetErrCode("alter table t convert to charset utf8 collate utf8_bin", errno.ErrUnsupportedDDLOperation) // Test when column charset can not convert to the target charset. tk.MustExec("drop table t;") diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index e4ded50b7d794..237f4db50f88d 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -4178,7 +4178,6 @@ func checkModifyCharsetAndCollation(toCharset, toCollate, origCharset, origColla if (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8MB4) || (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8) || (origCharset == charset.CharsetUTF8MB4 && toCharset == charset.CharsetUTF8MB4) || - (origCharset == charset.CharsetLatin1 && toCharset == charset.CharsetUTF8) || (origCharset == charset.CharsetLatin1 && toCharset == charset.CharsetUTF8MB4) { // TiDB only allow utf8/latin1 to be changed to utf8mb4, or changing the collation when the charset is utf8/utf8mb4/latin1. return nil