From 7a23c27760e896cf95d61e477f718313e3cc39df Mon Sep 17 00:00:00 2001 From: xiongjiwei Date: Thu, 9 Dec 2021 14:39:04 +0800 Subject: [PATCH 1/2] make charset config not affected by collation config --- session/session.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/session/session.go b/session/session.go index 8a2b61e50e6db..80cbce68e0f3e 100644 --- a/session/session.go +++ b/session/session.go @@ -2437,9 +2437,9 @@ func BootstrapSession(store kv.Storage) (*domain.Domain, error) { if newCollationEnabled { collate.EnableNewCollations() - if cfg.Experimental.EnableNewCharset { - collate.EnableNewCharset() - } + } + if cfg.Experimental.EnableNewCharset { + collate.EnableNewCharset() } newMemoryQuotaQuery, err := loadDefMemQuotaQuery(se) From 2ed1ed2d4cfab2c893a369ab5c8f3412f61d264d Mon Sep 17 00:00:00 2001 From: xiongjiwei Date: Tue, 14 Dec 2021 10:49:10 +0800 Subject: [PATCH 2/2] add a test --- executor/executor_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/executor/executor_test.go b/executor/executor_test.go index c821901d5a18d..1bb3357a768d5 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -5794,6 +5794,23 @@ func (s *testSuiteWithCliBaseCharset) TestCharsetFeature(c *C) { " `a` char(10) DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci", )) + + collate.SetNewCollationEnabledForTest(false) + tk.MustQuery("show charset").Check(testkit.Rows( + "ascii US ASCII ascii_bin 1", + "binary binary binary 1", + "gbk Chinese Internal Code Specification gbk_chinese_ci 2", + "latin1 Latin1 latin1_bin 1", + "utf8 UTF-8 Unicode utf8_bin 3", + "utf8mb4 UTF-8 Unicode utf8mb4_bin 4", + )) + tk.MustQuery("show collation").Check(testkit.Rows( + "utf8mb4_bin utf8mb4 46 Yes Yes 1", + "latin1_bin latin1 47 Yes Yes 1", + "binary binary 63 Yes Yes 1", + "ascii_bin ascii 65 Yes Yes 1", + "utf8_bin utf8 83 Yes Yes 1", + )) } func (s *testSuiteWithCliBaseCharset) TestCharsetFeatureCollation(c *C) {