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

planner, expression: fix a bug causes schema change after DML (#21027) #21050

Merged
merged 3 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
cherry pick #21027 to release-4.0
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
wjhuang2016 authored and ti-srebot committed Nov 13, 2020
commit e01099030519c8a4cc87f6f1dd282b27c5dc39c1
2 changes: 1 addition & 1 deletion expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6777,7 +6777,25 @@ func (s *testIntegrationSerialSuite) TestIssue17989(c *C) {
tk.MustExec("admin check table t")
}

<<<<<<< HEAD
func (s *testIntegrationSerialSuite) TestIssue18702(c *C) {
=======
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) TestIssue18638(c *C) {
>>>>>>> d084651fa... planner, expression: fix a bug causes schema change after DML (#21027)
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)
tk := testkit.NewTestKit(c, s.store)
Expand Down
2 changes: 1 addition & 1 deletion planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,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,
}
Expand Down
2 changes: 1 addition & 1 deletion planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down