From 1c5b9fd16967ce3aebae11f4d5c70b90978a60d2 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sat, 6 Aug 2022 17:59:23 +0800 Subject: [PATCH 1/9] *: enable deprecated linter Signed-off-by: Weizhen Wang --- build/BUILD.bazel | 1 + build/nogo_config.json | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/build/BUILD.bazel b/build/BUILD.bazel index 0532961efab6b..eb97275d1fd58 100644 --- a/build/BUILD.bazel +++ b/build/BUILD.bazel @@ -54,6 +54,7 @@ STATICHECK_ANALYZERS = [ "S1038", "S1039", "S1040", + "SA1019", "SA2000", "SA2001", "SA2003", diff --git a/build/nogo_config.json b/build/nogo_config.json index 8a2674d69691f..c32ab998db7e9 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -606,6 +606,12 @@ "parser/parser.go": "ignore generated code" } }, + "SA1019": { + "exclude_files": { + "/external/": "no need to vet third party code", + ".*_generated\\.go$": "ignore generated code" + } + }, "SA2000": { "exclude_files": { "/external/": "no need to vet third party code", From 44434a16081872117c491fce9c1035ba18e6c9a6 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sat, 6 Aug 2022 18:07:13 +0800 Subject: [PATCH 2/9] *: enable deprecated linter Signed-off-by: Weizhen Wang --- build/nogo_config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/build/nogo_config.json b/build/nogo_config.json index c32ab998db7e9..b693ecf5d1677 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -608,6 +608,7 @@ }, "SA1019": { "exclude_files": { + "/build/": "no need to linter code", "/external/": "no need to vet third party code", ".*_generated\\.go$": "ignore generated code" } From 771ff0e52c09e86e5c775511ca3a51c34e6000e9 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 00:40:07 +0800 Subject: [PATCH 3/9] enable --- build/nogo_config.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index b693ecf5d1677..077611331f298 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -611,7 +611,10 @@ "/build/": "no need to linter code", "/external/": "no need to vet third party code", ".*_generated\\.go$": "ignore generated code" - } + }, + "only_files": { + "ddl/": "enable to ddl" + } }, "SA2000": { "exclude_files": { From e16cf6270b02d20a59540c6b0b35c61a1097240a Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 00:45:44 +0800 Subject: [PATCH 4/9] enable --- ddl/ddl_api.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index fecd6946a8ecf..1ce0bee545791 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -46,6 +46,7 @@ import ( field_types "github.com/pingcap/tidb/parser/types" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" + "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/tablecodec" @@ -493,7 +494,7 @@ func checkAndNormalizePlacementPolicy(ctx sessionctx.Context, placementPolicyRef return nil, nil } - policy, ok := ctx.GetInfoSchema().(infoschema.InfoSchema).PolicyByName(placementPolicyRef.Name) + policy, ok := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema().PolicyByName(placementPolicyRef.Name) if !ok { return nil, errors.Trace(infoschema.ErrPlacementPolicyNotExists.GenWithStackByArgs(placementPolicyRef.Name)) } @@ -761,7 +762,9 @@ func ResolveCharsetCollation(charsetOpts ...ast.CharsetOpt) (string, string, err } // OverwriteCollationWithBinaryFlag is used to handle the case like -// CREATE TABLE t (a VARCHAR(255) BINARY) CHARSET utf8 COLLATE utf8_general_ci; +// +// CREATE TABLE t (a VARCHAR(255) BINARY) CHARSET utf8 COLLATE utf8_general_ci; +// // The 'BINARY' sets the column collation to *_bin according to the table charset. func OverwriteCollationWithBinaryFlag(colDef *ast.ColumnDef, chs, coll string) (newChs string, newColl string) { ignoreBinFlag := colDef.Tp.GetCharset() != "" && (colDef.Tp.GetCollate() != "" || containsColumnOption(colDef, ast.ColumnOptionCollate)) From 9dfc15d45de56d3eb14913859c14f0fe7776c84c Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 00:50:05 +0800 Subject: [PATCH 5/9] enable --- build/nogo_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 077611331f298..8ba4182c05fb3 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -613,7 +613,8 @@ ".*_generated\\.go$": "ignore generated code" }, "only_files": { - "ddl/": "enable to ddl" + "ddl/": "enable to ddl", + "planner/": "enable to planner" } }, "SA2000": { From 6070f9631e971b3e45f2d16ce6b9cf1458b6eb13 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 00:59:34 +0800 Subject: [PATCH 6/9] enable --- planner/core/access_object.go | 4 ++-- planner/core/expression_rewriter.go | 10 ++++++---- planner/core/point_get_plan.go | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/planner/core/access_object.go b/planner/core/access_object.go index 81296c39c9223..f286d7a6c9aeb 100644 --- a/planner/core/access_object.go +++ b/planner/core/access_object.go @@ -19,9 +19,9 @@ import ( "strconv" "strings" - "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/parser/model" "github.com/pingcap/tidb/sessionctx" + "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tipb/go-tipb" ) @@ -362,7 +362,7 @@ func getDynamicAccessPartition(sctx sessionctx.Context, tblInfo *model.TableInfo tblName = asName } res.Table = tblName - is := sctx.GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(sctx).GetTxnInfoSchema() db, ok := is.SchemaByTable(tblInfo) if ok { res.Database = db.Name.O diff --git a/planner/core/expression_rewriter.go b/planner/core/expression_rewriter.go index 231f5795deac2..4bd1b5370b455 100644 --- a/planner/core/expression_rewriter.go +++ b/planner/core/expression_rewriter.go @@ -34,6 +34,7 @@ import ( "github.com/pingcap/tidb/parser/opcode" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" + "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/tablecodec" @@ -66,7 +67,7 @@ func evalAstExpr(sctx sessionctx.Context, expr ast.ExprNode) (types.Datum, error func rewriteAstExpr(sctx sessionctx.Context, expr ast.ExprNode, schema *expression.Schema, names types.NameSlice) (expression.Expression, error) { var is infoschema.InfoSchema // in tests, it may be null - if s, ok := sctx.GetInfoSchema().(infoschema.InfoSchema); ok { + if s := sessiontxn.GetTxnManager(sctx).GetTxnInfoSchema(); s != nil { is = s } b, savedBlockNames := NewPlanBuilder().Init(sctx, is, &hint.BlockHintProcessor{}) @@ -264,9 +265,10 @@ func (er *expressionRewriter) ctxStackAppend(col expression.Expression, name *ty // 1. If op are EQ or NE or NullEQ, constructBinaryOpFunctions converts (a0,a1,a2) op (b0,b1,b2) to (a0 op b0) and (a1 op b1) and (a2 op b2) // 2. Else constructBinaryOpFunctions converts (a0,a1,a2) op (b0,b1,b2) to // `IF( a0 NE b0, a0 op b0, -// IF ( isNull(a0 NE b0), Null, -// IF ( a1 NE b1, a1 op b1, -// IF ( isNull(a1 NE b1), Null, a2 op b2))))` +// +// IF ( isNull(a0 NE b0), Null, +// IF ( a1 NE b1, a1 op b1, +// IF ( isNull(a1 NE b1), Null, a2 op b2))))` func (er *expressionRewriter) constructBinaryOpFunction(l expression.Expression, r expression.Expression, op string) (expression.Expression, error) { lLen, rLen := expression.GetRowLen(l), expression.GetRowLen(r) if lLen == 1 && rLen == 1 { diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index b400144f873bf..a4a27363b0ebc 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tidb/expression" - "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/parser/ast" "github.com/pingcap/tidb/parser/charset" @@ -35,6 +34,7 @@ import ( "github.com/pingcap/tidb/privilege" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/stmtctx" + "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/types" @@ -1089,7 +1089,7 @@ func checkFastPlanPrivilege(ctx sessionctx.Context, dbName, tableName string, ch }) } - infoSchema := ctx.GetInfoSchema().(infoschema.InfoSchema) + infoSchema := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() return CheckTableLock(ctx, infoSchema, visitInfos) } @@ -1429,7 +1429,7 @@ func buildPointUpdatePlan(ctx sessionctx.Context, pointPlan PhysicalPlan, dbName VirtualAssignmentsOffset: len(orderedList), }.Init(ctx) updatePlan.names = pointPlan.OutputNames() - is := ctx.GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() t, _ := is.TableByID(tbl.ID) updatePlan.tblID2Table = map[int64]table.Table{ tbl.ID: t, @@ -1732,7 +1732,7 @@ func getHashPartitionColumnPos(idx *model.IndexInfo, partitionColName *ast.Colum } func getPartitionExpr(ctx sessionctx.Context, tbl *model.TableInfo) *tables.PartitionExpr { - is := ctx.GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() table, ok := is.TableByID(tbl.ID) if !ok { return nil @@ -1760,7 +1760,7 @@ func getHashPartitionColumnName(ctx sessionctx.Context, tbl *model.TableInfo) *a if pi.Type != model.PartitionTypeHash { return nil } - is := ctx.GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() table, ok := is.TableByID(tbl.ID) if !ok { return nil From 6514237dd8a58a89e7802941ed0a331a0706787d Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 01:06:23 +0800 Subject: [PATCH 7/9] enable --- planner/core/expression_rewriter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/planner/core/expression_rewriter.go b/planner/core/expression_rewriter.go index 4bd1b5370b455..7621ebb9e7a20 100644 --- a/planner/core/expression_rewriter.go +++ b/planner/core/expression_rewriter.go @@ -67,8 +67,8 @@ func evalAstExpr(sctx sessionctx.Context, expr ast.ExprNode) (types.Datum, error func rewriteAstExpr(sctx sessionctx.Context, expr ast.ExprNode, schema *expression.Schema, names types.NameSlice) (expression.Expression, error) { var is infoschema.InfoSchema // in tests, it may be null - if s := sessiontxn.GetTxnManager(sctx).GetTxnInfoSchema(); s != nil { - is = s + if txnManager := sessiontxn.GetTxnManager(sctx); txnManager != nil { + is = txnManager.GetTxnInfoSchema() } b, savedBlockNames := NewPlanBuilder().Init(sctx, is, &hint.BlockHintProcessor{}) fakePlan := LogicalTableDual{}.Init(sctx, 0) From 094a001b4cd159e910af4b91515042f4ffa7f333 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 01:11:58 +0800 Subject: [PATCH 8/9] enable --- build/nogo_config.json | 3 +-- planner/core/access_object.go | 4 ++-- planner/core/expression_rewriter.go | 12 +++++------- planner/core/point_get_plan.go | 10 +++++----- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 8ba4182c05fb3..077611331f298 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -613,8 +613,7 @@ ".*_generated\\.go$": "ignore generated code" }, "only_files": { - "ddl/": "enable to ddl", - "planner/": "enable to planner" + "ddl/": "enable to ddl" } }, "SA2000": { diff --git a/planner/core/access_object.go b/planner/core/access_object.go index f286d7a6c9aeb..81296c39c9223 100644 --- a/planner/core/access_object.go +++ b/planner/core/access_object.go @@ -19,9 +19,9 @@ import ( "strconv" "strings" + "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/parser/model" "github.com/pingcap/tidb/sessionctx" - "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tipb/go-tipb" ) @@ -362,7 +362,7 @@ func getDynamicAccessPartition(sctx sessionctx.Context, tblInfo *model.TableInfo tblName = asName } res.Table = tblName - is := sessiontxn.GetTxnManager(sctx).GetTxnInfoSchema() + is := sctx.GetInfoSchema().(infoschema.InfoSchema) db, ok := is.SchemaByTable(tblInfo) if ok { res.Database = db.Name.O diff --git a/planner/core/expression_rewriter.go b/planner/core/expression_rewriter.go index 7621ebb9e7a20..231f5795deac2 100644 --- a/planner/core/expression_rewriter.go +++ b/planner/core/expression_rewriter.go @@ -34,7 +34,6 @@ import ( "github.com/pingcap/tidb/parser/opcode" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" - "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/tablecodec" @@ -67,8 +66,8 @@ func evalAstExpr(sctx sessionctx.Context, expr ast.ExprNode) (types.Datum, error func rewriteAstExpr(sctx sessionctx.Context, expr ast.ExprNode, schema *expression.Schema, names types.NameSlice) (expression.Expression, error) { var is infoschema.InfoSchema // in tests, it may be null - if txnManager := sessiontxn.GetTxnManager(sctx); txnManager != nil { - is = txnManager.GetTxnInfoSchema() + if s, ok := sctx.GetInfoSchema().(infoschema.InfoSchema); ok { + is = s } b, savedBlockNames := NewPlanBuilder().Init(sctx, is, &hint.BlockHintProcessor{}) fakePlan := LogicalTableDual{}.Init(sctx, 0) @@ -265,10 +264,9 @@ func (er *expressionRewriter) ctxStackAppend(col expression.Expression, name *ty // 1. If op are EQ or NE or NullEQ, constructBinaryOpFunctions converts (a0,a1,a2) op (b0,b1,b2) to (a0 op b0) and (a1 op b1) and (a2 op b2) // 2. Else constructBinaryOpFunctions converts (a0,a1,a2) op (b0,b1,b2) to // `IF( a0 NE b0, a0 op b0, -// -// IF ( isNull(a0 NE b0), Null, -// IF ( a1 NE b1, a1 op b1, -// IF ( isNull(a1 NE b1), Null, a2 op b2))))` +// IF ( isNull(a0 NE b0), Null, +// IF ( a1 NE b1, a1 op b1, +// IF ( isNull(a1 NE b1), Null, a2 op b2))))` func (er *expressionRewriter) constructBinaryOpFunction(l expression.Expression, r expression.Expression, op string) (expression.Expression, error) { lLen, rLen := expression.GetRowLen(l), expression.GetRowLen(r) if lLen == 1 && rLen == 1 { diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index a4a27363b0ebc..b400144f873bf 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -22,6 +22,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tidb/expression" + "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/parser/ast" "github.com/pingcap/tidb/parser/charset" @@ -34,7 +35,6 @@ import ( "github.com/pingcap/tidb/privilege" "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/stmtctx" - "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/types" @@ -1089,7 +1089,7 @@ func checkFastPlanPrivilege(ctx sessionctx.Context, dbName, tableName string, ch }) } - infoSchema := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() + infoSchema := ctx.GetInfoSchema().(infoschema.InfoSchema) return CheckTableLock(ctx, infoSchema, visitInfos) } @@ -1429,7 +1429,7 @@ func buildPointUpdatePlan(ctx sessionctx.Context, pointPlan PhysicalPlan, dbName VirtualAssignmentsOffset: len(orderedList), }.Init(ctx) updatePlan.names = pointPlan.OutputNames() - is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() + is := ctx.GetInfoSchema().(infoschema.InfoSchema) t, _ := is.TableByID(tbl.ID) updatePlan.tblID2Table = map[int64]table.Table{ tbl.ID: t, @@ -1732,7 +1732,7 @@ func getHashPartitionColumnPos(idx *model.IndexInfo, partitionColName *ast.Colum } func getPartitionExpr(ctx sessionctx.Context, tbl *model.TableInfo) *tables.PartitionExpr { - is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() + is := ctx.GetInfoSchema().(infoschema.InfoSchema) table, ok := is.TableByID(tbl.ID) if !ok { return nil @@ -1760,7 +1760,7 @@ func getHashPartitionColumnName(ctx sessionctx.Context, tbl *model.TableInfo) *a if pi.Type != model.PartitionTypeHash { return nil } - is := sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema() + is := ctx.GetInfoSchema().(infoschema.InfoSchema) table, ok := is.TableByID(tbl.ID) if !ok { return nil From a688e28c309a7f21733ed0933e977fe4ea85252f Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 8 Aug 2022 01:26:36 +0800 Subject: [PATCH 9/9] enable --- ddl/column_modify_test.go | 6 ++---- ddl/column_type_change_test.go | 8 ++++---- ddl/serial_test.go | 7 ++++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ddl/column_modify_test.go b/ddl/column_modify_test.go index 2ccdf96a24916..926ed6b13cdb3 100644 --- a/ddl/column_modify_test.go +++ b/ddl/column_modify_test.go @@ -28,12 +28,10 @@ import ( testddlutil "github.com/pingcap/tidb/ddl/testutil" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/errno" - "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/parser/ast" "github.com/pingcap/tidb/parser/model" "github.com/pingcap/tidb/parser/mysql" - "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/table" @@ -447,7 +445,7 @@ func TestVirtualColumnDDL(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") tk.MustExec(`create global temporary table test_gv_ddl(a int, b int as (a+8) virtual, c int as (b + 2) stored) on commit delete rows;`) - is := tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(tk.Session()).GetTxnInfoSchema() tbl, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_gv_ddl")) require.NoError(t, err) testCases := []struct { @@ -471,7 +469,7 @@ func TestVirtualColumnDDL(t *testing.T) { // for local temporary table tk.MustExec(`create temporary table test_local_gv_ddl(a int, b int as (a+8) virtual, c int as (b + 2) stored);`) - is = tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema) + is = sessiontxn.GetTxnManager(tk.Session()).GetTxnInfoSchema() tbl, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_local_gv_ddl")) require.NoError(t, err) for i, column := range tbl.Meta().Columns { diff --git a/ddl/column_type_change_test.go b/ddl/column_type_change_test.go index 72d3ffd6a06af..2fed091c5be3f 100644 --- a/ddl/column_type_change_test.go +++ b/ddl/column_type_change_test.go @@ -245,10 +245,10 @@ var mockTerrorMap = make(map[string]*terror.Error) func init() { // Since terror new action will cause data race with other test suite (getTerrorCode) in parallel, we init it all here. - mockTerrorMap[model.StateNone.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateNone.String()) - mockTerrorMap[model.StateDeleteOnly.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateDeleteOnly.String()) - mockTerrorMap[model.StateWriteOnly.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateWriteOnly.String()) - mockTerrorMap[model.StateWriteReorganization.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateWriteReorganization.String()) + mockTerrorMap[model.StateNone.String()] = dbterror.ClassDDL.NewStdErr(1, mysql.Message("MockRollingBackInCallBack-"+model.StateNone.String(), nil)) + mockTerrorMap[model.StateDeleteOnly.String()] = dbterror.ClassDDL.NewStdErr(1, mysql.Message("MockRollingBackInCallBack-"+model.StateDeleteOnly.String(), nil)) + mockTerrorMap[model.StateWriteOnly.String()] = dbterror.ClassDDL.NewStdErr(1, mysql.Message("MockRollingBackInCallBack-"+model.StateWriteOnly.String(), nil)) + mockTerrorMap[model.StateWriteReorganization.String()] = dbterror.ClassDDL.NewStdErr(1, mysql.Message("MockRollingBackInCallBack-"+model.StateWriteReorganization.String(), nil)) } func TestColumnTypeChangeFromIntegerToOthers(t *testing.T) { diff --git a/ddl/serial_test.go b/ddl/serial_test.go index 322a30fdbb9a1..98b18417d90e8 100644 --- a/ddl/serial_test.go +++ b/ddl/serial_test.go @@ -39,6 +39,7 @@ import ( "github.com/pingcap/tidb/planner/core" "github.com/pingcap/tidb/session" "github.com/pingcap/tidb/sessionctx/variable" + "github.com/pingcap/tidb/sessiontxn" "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/tablecodec" "github.com/pingcap/tidb/testkit" @@ -271,7 +272,7 @@ func TestCreateTableWithLikeAtTemporaryMode(t *testing.T) { tk.MustExec(`create table test_gv_ddl(a int, b int as (a+8) virtual, c int as (b + 2) stored)`) tk.MustExec(`create global temporary table test_gv_ddl_temp like test_gv_ddl on commit delete rows;`) defer tk.MustExec("drop table if exists test_gv_ddl_temp, test_gv_ddl") - is := tk.Session().GetInfoSchema().(infoschema.InfoSchema) + is := sessiontxn.GetTxnManager(tk.Session()).GetTxnInfoSchema() table, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_gv_ddl")) require.NoError(t, err) testCases := []struct { @@ -300,7 +301,7 @@ func TestCreateTableWithLikeAtTemporaryMode(t *testing.T) { tk.MustExec("create table test_foreign_key (c int,d int,foreign key (d) references t1 (b))") defer tk.MustExec("drop table if exists test_foreign_key, t1") tk.MustExec("create global temporary table test_foreign_key_temp like test_foreign_key on commit delete rows") - is = tk.Session().GetInfoSchema().(infoschema.InfoSchema) + is = sessiontxn.GetTxnManager(tk.Session()).GetTxnInfoSchema() table, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_foreign_key_temp")) require.NoError(t, err) tableInfo := table.Meta() @@ -384,7 +385,7 @@ func TestCreateTableWithLikeAtTemporaryMode(t *testing.T) { tk.MustExec("create table foreign_key_table1 (a int, b int)") tk.MustExec("create table foreign_key_table2 (c int,d int,foreign key (d) references foreign_key_table1 (b))") tk.MustExec("create temporary table foreign_key_tmp like foreign_key_table2") - is = tk.Session().GetInfoSchema().(infoschema.InfoSchema) + is = sessiontxn.GetTxnManager(tk.Session()).GetTxnInfoSchema() table, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("foreign_key_tmp")) require.NoError(t, err) tableInfo = table.Meta()