From f1d382af959aadd1b41896c496b7fa09bc2609e6 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Thu, 2 Aug 2018 17:49:00 +0800 Subject: [PATCH 1/2] plan: fix a bug when eliminating projection --- plan/rule_eliminate_projection.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plan/rule_eliminate_projection.go b/plan/rule_eliminate_projection.go index 009d83374833d..26b7f7fa703ab 100644 --- a/plan/rule_eliminate_projection.go +++ b/plan/rule_eliminate_projection.go @@ -90,10 +90,8 @@ func eliminatePhysicalProjection(p PhysicalPlan) PhysicalPlan { newRoot := doPhysicalProjectionElimination(p) newCols := newRoot.Schema().Columns for i, oldCol := range oldSchema.Columns { - newCols[i].DBName = oldCol.DBName - newCols[i].TblName = oldCol.TblName - newCols[i].ColName = oldCol.ColName - newCols[i].OrigTblName = oldCol.OrigTblName + oldCol.Index = newCols[i].Index + newRoot.Schema().Columns[i] = oldCol } return newRoot } From 9119ee2014024427238a25b2168d6802a81e016b Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Thu, 2 Aug 2018 19:47:55 +0800 Subject: [PATCH 2/2] add test. --- executor/write_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/executor/write_test.go b/executor/write_test.go index d39e9cfce8309..565c018e3c7f2 100644 --- a/executor/write_test.go +++ b/executor/write_test.go @@ -914,6 +914,8 @@ func (s *testSuite) TestUpdate(c *C) { tk.MustExec("CREATE TABLE `t` ( `c1` year DEFAULT NULL, `c2` year DEFAULT NULL, `c3` date DEFAULT NULL, `c4` datetime DEFAULT NULL, KEY `idx` (`c1`,`c2`))") _, err = tk.Exec("UPDATE t SET c2=16777215 WHERE c1>= -8388608 AND c1 < -9 ORDER BY c1 LIMIT 2") c.Assert(err.Error(), Equals, "cannot convert datum from bigint to type year.") + + tk.MustExec("update (select * from t) t set c1 = 1111111") } // TestUpdateCastOnlyModifiedValues for issue #4514.