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 column collate should use table's if it has when create table or alter table. (#13119 & #12327) #13190

Merged
merged 3 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddl/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ func (s *testColumnSuite) colDefStrToFieldType(c *C, str string) *types.FieldTyp
stmt, err := parser.New().ParseOneStmt(sqlA, "", "")
c.Assert(err, IsNil)
colDef := stmt.(*ast.AlterTableStmt).Specs[0].NewColumns[0]
col, _, err := buildColumnAndConstraint(nil, 0, colDef, nil, "", "")
col, _, err := buildColumnAndConstraint(nil, 0, colDef, nil, "", "", "", "")
c.Assert(err, IsNil)
return &col.FieldType
}
Expand Down
13 changes: 12 additions & 1 deletion ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (s *testStateChangeSuite) TestShowCreateTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table t (id int)")
tk.MustExec("create table t2 (a int, b varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci")

var checkErr error
testCases := []struct {
Expand All @@ -95,6 +96,10 @@ func (s *testStateChangeSuite) TestShowCreateTable(c *C) {
"CREATE TABLE `t` (\n `id` int(11) DEFAULT NULL,\n KEY `idx` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"},
{"alter table t add column c int",
"CREATE TABLE `t` (\n `id` int(11) DEFAULT NULL,\n KEY `idx` (`id`),\n KEY `idx1` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"},
{"alter table t2 add column c varchar(1)",
"CREATE TABLE `t2` (\n `a` int(11) DEFAULT NULL,\n `b` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"},
{"alter table t2 add column d varchar(1)",
"CREATE TABLE `t2` (\n `a` int(11) DEFAULT NULL,\n `b` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL,\n `c` varchar(1) COLLATE utf8mb4_general_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"},
}
prevState := model.StateNone
callback := &ddl.TestDDLCallback{}
Expand All @@ -107,7 +112,13 @@ func (s *testStateChangeSuite) TestShowCreateTable(c *C) {
currTestCaseOffset++
}
if job.SchemaState != model.StatePublic {
result := tk.MustQuery("show create table t")
var result *testkit.Result
tbl2 := testGetTableByName(c, tk.Se, "test", "t2")
if job.TableID == tbl2.Meta().ID {
result = tk.MustQuery("show create table t2")
} else {
result = tk.MustQuery("show create table t")
}
got := result.Rows()[0][1]
expected := testCases[currTestCaseOffset].expectedRet
if got != expected {
Expand Down
22 changes: 11 additions & 11 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
c.Assert(err, NotNil)
c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err))
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing this keyword?

Copy link
Contributor Author

@AilinKid AilinKid Nov 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause backport change the output in show.go. CHARACTER is same to master/mysql.

" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `a` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

// Mock old version table info with column charset is utf8.
Expand Down Expand Up @@ -683,8 +683,8 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
tk.MustExec("insert into t set a= x'f09f8c80'")
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) DEFAULT NULL,\n" +
" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL,\n" +
" `c` varchar(10) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,\n" +
" `c` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false
Expand All @@ -693,8 +693,8 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
c.Assert(err, NotNil)
c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err))
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `a` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

// Mock old version table info with table and column charset is utf8.
Expand All @@ -711,7 +711,7 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
tk.MustExec("insert into t set a= x'f09f8c80'")
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) DEFAULT NULL,\n" +
" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL,\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,\n" +
" `c` varchar(10) DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

Expand All @@ -722,7 +722,7 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err))
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) DEFAULT NULL,\n" +
" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin"))

// Test modify column charset.
Expand All @@ -735,7 +735,7 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
tk.MustExec("insert into t set a= x'f09f8c80'")
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(10) DEFAULT NULL,\n" +
" `b` varchar(10) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
// Test for change column should not modify the column version.
tk.MustExec("alter table t change column a a varchar(20)") // change column.
Expand All @@ -759,7 +759,7 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
tk.MustExec("insert into t set a= x'f09f8c80'")
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(20) DEFAULT NULL,\n" +
" `b` varchar(20) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `b` varchar(20) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false
Expand All @@ -769,7 +769,7 @@ func (s *testIntegrationSuite) TestIgnoreColumnUTF8Charset(c *C) {
c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err))
tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" +
" `a` varchar(20) DEFAULT NULL,\n" +
" `b` varchar(30) CHARSET ascii COLLATE ascii_bin DEFAULT NULL\n" +
" `b` varchar(30) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin"))

// Test for alter table convert charset
Expand Down
19 changes: 16 additions & 3 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,19 @@ func (s *testDBSuite) TestCreateTable(c *C) {

_, err = s.tk.Exec("CREATE TABLE `t` (`a` int) DEFAULT CHARSET=abcdefg")
c.Assert(err, NotNil)

_, err = s.tk.Exec("CREATE TABLE `collateTest` (`a` int, `b` varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci")
c.Assert(err, IsNil)
result := s.tk.MustQuery("show create table collateTest")
got := result.Rows()[0][1]
c.Assert(got, Equals, "CREATE TABLE `collateTest` (\n `a` int(11) DEFAULT NULL,\n `b` varchar(10) COLLATE utf8_slovak_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci")

s.tk.MustExec("create database test2 default charset utf8 collate utf8_general_ci")
s.tk.MustExec("use test2")
s.tk.MustExec("create table dbCollateTest (a varchar(10))")
result = s.tk.MustQuery("show create table dbCollateTest")
got = result.Rows()[0][1]
c.Assert(got, Equals, "CREATE TABLE `dbCollateTest` (\n `a` varchar(10) COLLATE utf8_general_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci")
}

func (s *testDBSuite) TestTableForeignKey(c *C) {
Expand Down Expand Up @@ -4653,8 +4666,8 @@ func (s *testDBSuite) TestModifyColumnCharset(c *C) {
result := s.tk.MustQuery(`show create table t_mcc`)
result.Check(testkit.Rows(
"t_mcc CREATE TABLE `t_mcc` (\n" +
" `a` varchar(8) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
" `b` varchar(8) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
" `a` varchar(8) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,\n" +
" `b` varchar(8) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

s.tk.MustExec("alter table t_mcc modify column a varchar(8);")
Expand All @@ -4667,7 +4680,7 @@ func (s *testDBSuite) TestModifyColumnCharset(c *C) {
result.Check(testkit.Rows(
"t_mcc CREATE TABLE `t_mcc` (\n" +
" `a` varchar(8) DEFAULT NULL,\n" +
" `b` varchar(8) CHARSET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
" `b` varchar(8) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

}
Expand Down
85 changes: 60 additions & 25 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func setColumnFlagWithConstraint(colMap map[string]*table.Column, v *ast.Constra
}

func buildColumnsAndConstraints(ctx sessionctx.Context, colDefs []*ast.ColumnDef,
constraints []*ast.Constraint, tblCharset, dbCharset string) ([]*table.Column, []*ast.Constraint, error) {
constraints []*ast.Constraint, tblCharset, tblCollate, dbCharset, dbCollate string) ([]*table.Column, []*ast.Constraint, error) {
var cols []*table.Column
colMap := map[string]*table.Column{}
// outPriKeyConstraint is the primary key constraint out of column definition. such as: create table t1 (id int , age int, primary key(id));
Expand All @@ -239,7 +239,7 @@ func buildColumnsAndConstraints(ctx sessionctx.Context, colDefs []*ast.ColumnDef
}
}
for i, colDef := range colDefs {
col, cts, err := buildColumnAndConstraint(ctx, i, colDef, outPriKeyConstraint, tblCharset, dbCharset)
col, cts, err := buildColumnAndConstraint(ctx, i, colDef, outPriKeyConstraint, tblCharset, tblCollate, dbCharset, dbCollate)
if err != nil {
return nil, nil, errors.Trace(err)
}
Expand All @@ -255,23 +255,32 @@ func buildColumnsAndConstraints(ctx sessionctx.Context, colDefs []*ast.ColumnDef
return cols, constraints, nil
}

// ResolveCharsetCollation will resolve the charset by the order: table charset > database charset > server default charset.
func ResolveCharsetCollation(tblCharset, dbCharset string) (string, string, error) {
// ResolveCharsetCollation will resolve the charset by the order: table charset > database charset > server default charset,
// and it will also resolve the collate by the order: table collate > database collate > server default collate.
func ResolveCharsetCollation(tblCharset, tblCollate, dbCharset, dbCollate string) (string, string, error) {
if len(tblCharset) != 0 {
defCollate, err := charset.GetDefaultCollation(tblCharset)
if err != nil {
// return terror is better.
return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(tblCharset)
// tblCollate is not specified by user.
if len(tblCollate) == 0 {
defCollate, err := charset.GetDefaultCollation(tblCharset)
if err != nil {
// return terror is better.
return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(tblCharset)
}
return tblCharset, defCollate, nil
}
return tblCharset, defCollate, nil
return tblCharset, tblCollate, nil
}

if len(dbCharset) != 0 {
defCollate, err := charset.GetDefaultCollation(dbCharset)
if err != nil {
return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(dbCharset)
// dbCollate is not specified by user.
if len(dbCollate) == 0 {
defCollate, err := charset.GetDefaultCollation(dbCharset)
if err != nil {
return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(dbCharset)
}
return dbCharset, defCollate, nil
}
return dbCharset, defCollate, errors.Trace(err)
return dbCharset, dbCollate, nil
}

charset, collate := charset.GetDefaultCharsetAndCollate()
Expand All @@ -288,15 +297,15 @@ func typesNeedCharset(tp byte) bool {
return false
}

func setCharsetCollationFlenDecimal(tp *types.FieldType, specifiedCollates []string, tblCharset string, dbCharset string) error {
func setCharsetCollationFlenDecimal(tp *types.FieldType, specifiedCollates []string, tblCharset, tblCollate, dbCharset, dbCollate string) error {
tp.Charset = strings.ToLower(tp.Charset)
tp.Collate = strings.ToLower(tp.Collate)
if len(tp.Charset) == 0 {
if typesNeedCharset(tp.Tp) {
if len(specifiedCollates) == 0 {
// Both the charset and collate are not specified.
var err error
tp.Charset, tp.Collate, err = ResolveCharsetCollation(tblCharset, dbCharset)
tp.Charset, tp.Collate, err = ResolveCharsetCollation(tblCharset, tblCollate, dbCharset, dbCollate)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -366,11 +375,11 @@ func setCharsetCollationFlenDecimal(tp *types.FieldType, specifiedCollates []str

// outPriKeyConstraint is the primary key constraint out of column definition. such as: create table t1 (id int , age int, primary key(id));
func buildColumnAndConstraint(ctx sessionctx.Context, offset int,
colDef *ast.ColumnDef, outPriKeyConstraint *ast.Constraint, tblCharset, dbCharset string) (*table.Column, []*ast.Constraint, error) {
colDef *ast.ColumnDef, outPriKeyConstraint *ast.Constraint, tblCharset, tblCollate, dbCharset, dbCollate string) (*table.Column, []*ast.Constraint, error) {
// specifiedCollates refers to collates in colDef.Options, should handle them together.
specifiedCollates := extractCollateFromOption(colDef)

if err := setCharsetCollationFlenDecimal(colDef.Tp, specifiedCollates, tblCharset, dbCharset); err != nil {
if err := setCharsetCollationFlenDecimal(colDef.Tp, specifiedCollates, tblCharset, tblCollate, dbCharset, dbCollate); err != nil {
return nil, nil, errors.Trace(err)
}
col, cts, err := columnDefToCol(ctx, offset, colDef, outPriKeyConstraint)
Expand Down Expand Up @@ -1126,9 +1135,9 @@ func (d *ddl) CreateTable(ctx sessionctx.Context, s *ast.CreateTableStmt) (err e
return errors.Trace(err)
}

tableCharset := findTableOptionCharset(s.Options)
tableCharset, tableCollate := findTableOptionCharsetAndCollate(s.Options)
// The column charset haven't been resolved here.
cols, newConstraints, err := buildColumnsAndConstraints(ctx, colDefs, s.Constraints, tableCharset, schema.Charset)
cols, newConstraints, err := buildColumnsAndConstraints(ctx, colDefs, s.Constraints, tableCharset, tableCollate, schema.Charset, schema.Collate)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -1203,7 +1212,7 @@ func (d *ddl) CreateTable(ctx sessionctx.Context, s *ast.CreateTableStmt) (err e
return errors.Trace(err)
}

if err = resolveDefaultTableCharsetAndCollation(tbInfo, schema.Charset); err != nil {
if err = resolveDefaultTableCharsetAndCollation(tbInfo, schema.Charset, schema.Collate); err != nil {
return errors.Trace(err)
}

Expand Down Expand Up @@ -1279,8 +1288,8 @@ func (d *ddl) handleAutoIncID(tbInfo *model.TableInfo, schemaID int64) error {
return nil
}

func resolveDefaultTableCharsetAndCollation(tbInfo *model.TableInfo, dbCharset string) (err error) {
chr, collate, err := ResolveCharsetCollation(tbInfo.Charset, dbCharset)
func resolveDefaultTableCharsetAndCollation(tbInfo *model.TableInfo, dbCharset, dbCollate string) (err error) {
chr, collate, err := ResolveCharsetCollation(tbInfo.Charset, tbInfo.Collate, dbCharset, dbCollate)
if err != nil {
return errors.Trace(err)
}
Expand All @@ -1294,6 +1303,32 @@ func resolveDefaultTableCharsetAndCollation(tbInfo *model.TableInfo, dbCharset s
return
}

func findTableOptionCharsetAndCollate(options []*ast.TableOption) (tableCharset, tableCollate string) {
var findCnt int
for i := len(options) - 1; i >= 0; i-- {
op := options[i]
if len(tableCharset) == 0 && op.Tp == ast.TableOptionCharset {
// find the last one.
tableCharset = op.StrValue
findCnt++
if findCnt == 2 {
break
}
continue
}
if len(tableCollate) == 0 && op.Tp == ast.TableOptionCollate {
// find the last one.
tableCollate = op.StrValue
findCnt++
if findCnt == 2 {
break
}
continue
}
}
return tableCharset, tableCollate
}

// handleTableOptions updates tableInfo according to table options.
func handleTableOptions(options []*ast.TableOption, tbInfo *model.TableInfo) error {
for _, op := range options {
Expand Down Expand Up @@ -1632,7 +1667,7 @@ func (d *ddl) AddColumn(ctx sessionctx.Context, ti ast.Ident, spec *ast.AlterTab
// Ingore table constraints now, maybe return error later.
// We use length(t.Cols()) as the default offset firstly, we will change the
// column's offset later.
col, _, err = buildColumnAndConstraint(ctx, len(t.Cols()), specNewColumn, nil, t.Meta().Charset, schema.Charset)
col, _, err = buildColumnAndConstraint(ctx, len(t.Cols()), specNewColumn, nil, t.Meta().Charset, t.Meta().Collate, schema.Charset, schema.Collate)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -2074,7 +2109,7 @@ func (d *ddl) getModifiableColumnJob(ctx sessionctx.Context, ident ast.Ident, or
// should take the collate in colDef.Option into consideration rather than handling it separately
specifiedCollates := extractCollateFromOption(specNewColumn)

err = setCharsetCollationFlenDecimal(&newCol.FieldType, specifiedCollates, t.Meta().Charset, schema.Charset)
err = setCharsetCollationFlenDecimal(&newCol.FieldType, specifiedCollates, t.Meta().Charset, t.Meta().Collate, schema.Charset, schema.Collate)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -2332,7 +2367,7 @@ func checkAlterTableCharset(tblInfo *model.TableInfo, dbInfo *model.DBInfo, toCh
if len(origCharset) == 0 {
// The table charset may be "", if the table is create in old TiDB version, such as v2.0.8.
// This DDL will update the table charset to default charset.
origCharset, origCollate, err = ResolveCharsetCollation("", dbInfo.Charset)
origCharset, origCollate, err = ResolveCharsetCollation("", "", dbInfo.Charset, dbInfo.Collate)
if err != nil {
return doNothing, err
}
Expand Down
2 changes: 1 addition & 1 deletion ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func (s *testDDLSuite) TestCancelJob(c *C) {
Tp: &types.FieldType{Tp: mysql.TypeLonglong},
Options: []*ast.ColumnOption{},
}
col, _, err := buildColumnAndConstraint(ctx, 2, newColumnDef, nil, "", "")
col, _, err := buildColumnAndConstraint(ctx, 2, newColumnDef, nil, "", "", "", "")
c.Assert(err, IsNil)
addColumnArgs := []interface{}{col, &ast.ColumnPosition{Tp: ast.ColumnPositionNone}, 0}
doDDLJobErrWithSchemaState(ctx, d, c, dbInfo.ID, tblInfo.ID, model.ActionAddColumn, addColumnArgs, &cancelState)
Expand Down
4 changes: 2 additions & 2 deletions ddl/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (dr *mockDelRange) clear() {

// MockTableInfo mocks a table info by create table stmt ast and a specified table id.
func MockTableInfo(ctx sessionctx.Context, stmt *ast.CreateTableStmt, tableID int64) (*model.TableInfo, error) {
cols, newConstraints, err := buildColumnsAndConstraints(ctx, stmt.Cols, stmt.Constraints, "", "")
cols, newConstraints, err := buildColumnsAndConstraints(ctx, stmt.Cols, stmt.Constraints, "", "", "", "")
if err != nil {
return nil, errors.Trace(err)
}
Expand All @@ -163,7 +163,7 @@ func MockTableInfo(ctx sessionctx.Context, stmt *ast.CreateTableStmt, tableID in
return nil, errors.Trace(err)
}

if err = resolveDefaultTableCharsetAndCollation(tbl, ""); err != nil {
if err = resolveDefaultTableCharsetAndCollation(tbl, "", ""); err != nil {
return nil, errors.Trace(err)
}
return tbl, nil
Expand Down
Loading