Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: fix alter table charset bug that change blob column type to text #10477

Merged
merged 10 commits into from Jun 4, 2019
@@ -44,6 +44,7 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testutil"
)

var _ = Suite(&testIntegrationSuite1{&testIntegrationSuite{}})
@@ -738,6 +739,16 @@ func (s *testIntegrationSuite10) TestChangingTableCharset(c *C) {
c.Assert(tbl.Meta().Columns[0].Collate, Equals, "")
tk.MustExec("alter table t convert to charset utf8mb4;")
checkCharset()

tk.MustExec("drop table t")
tk.MustExec("create table t (a blob) character set utf8;")
tk.MustExec("alter table t charset=utf8mb4 collate=utf8mb4_bin;")
tk.MustQuery("show create table t").Check(testutil.RowsWithSep("|",
"t CREATE TABLE `t` (\n"+
" `a` blob DEFAULT NULL\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))

}

func (s *testIntegrationSuite7) TestCaseInsensitiveCharsetAndCollate(c *C) {
@@ -735,6 +735,9 @@ func onModifyTableCharsetAndCollate(t *meta.Meta, job *model.Job) (ver int64, _
tblInfo.Collate = toCollate
// update column charset.
for _, col := range tblInfo.Columns {
if col.Charset == charset.CharsetBin {

This comment has been minimized.

Copy link
@winkyao

winkyao May 15, 2019

Member

We can use HasCharset here.

continue
}
if typesNeedCharset(col.Tp) {
col.Charset = toCharset
col.Collate = toCollate
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.