diff --git a/expression/expression.go b/expression/expression.go index dd2b55b9b32c..144ddab2834e 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -779,7 +779,7 @@ func ColumnInfos2ColumnsAndNames(ctx sessionctx.Context, dbName, tblName model.C ColName: col.Name, }) newCol := &Column{ - RetType: &col.FieldType, + RetType: col.FieldType.Clone(), ID: col.ID, UniqueID: ctx.GetSessionVars().AllocPlanColumnID(), Index: col.Offset, diff --git a/expression/integration_test.go b/expression/integration_test.go index 81777a965d8c..66172d4f2019 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6777,6 +6777,20 @@ func (s *testIntegrationSerialSuite) TestIssue17989(c *C) { tk.MustExec("admin check table t") } +func (s *testIntegrationSuite2) TestSchemaDMLNotChange(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk2 := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk2.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t (id int primary key, c_json json);") + tk.MustExec("insert into t values (1, '{\"k\": 1}');") + tk.MustExec("begin") + tk.MustExec("update t set c_json = '{\"k\": 2}' where id = 1;") + tk2.MustExec("alter table t rename column c_json to cc_json;") + tk.MustExec("commit") +} + func (s *testIntegrationSerialSuite) TestIssue18702(c *C) { collate.SetNewCollationEnabledForTest(true) defer collate.SetNewCollationEnabledForTest(false) diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index be87c8d1be80..9091cfca2e49 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -2948,7 +2948,7 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as newCol := &expression.Column{ UniqueID: sessionVars.AllocPlanColumnID(), ID: col.ID, - RetType: &col.FieldType, + RetType: col.FieldType.Clone(), OrigName: names[i].String(), IsHidden: col.Hidden, } diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index 3211a887230d..4ce476fa3672 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -1172,7 +1172,7 @@ func findCol(tbl *model.TableInfo, colName *ast.ColumnName) *model.ColumnInfo { func colInfoToColumn(col *model.ColumnInfo, idx int) *expression.Column { return &expression.Column{ - RetType: &col.FieldType, + RetType: col.FieldType.Clone(), ID: col.ID, UniqueID: int64(col.Offset), Index: idx,