diff --git a/bench_test.go b/bench_test.go index 1d481a542498a..f90f52aca9170 100644 --- a/bench_test.go +++ b/bench_test.go @@ -6,7 +6,6 @@ import ( "github.com/ngaut/log" "github.com/pingcap/tidb/ast" - "github.com/pingcap/tidb/plan" ) var smallCount = 100 @@ -218,22 +217,6 @@ func BenchmarkJoin(b *testing.B) { } } -func BenchmarkNewJoin(b *testing.B) { - b.StopTimer() - se := prepareBenchSession() - prepareJoinBenchData(se, "int", "%v", smallCount) - b.StartTimer() - plan.UseNewPlanner = true - for i := 0; i < b.N; i++ { - rs, err := se.Execute("select * from t a join t b on a.col = b.col") - if err != nil { - b.Fatal(err) - } - readResult(rs[0], 100) - } - plan.UseNewPlanner = false -} - func BenchmarkJoinLimit(b *testing.B) { b.StopTimer() se := prepareBenchSession() @@ -247,19 +230,3 @@ func BenchmarkJoinLimit(b *testing.B) { readResult(rs[0], 1) } } - -func BenchmarkNewJoinLimit(b *testing.B) { - b.StopTimer() - se := prepareBenchSession() - prepareJoinBenchData(se, "int", "%v", smallCount) - b.StartTimer() - plan.UseNewPlanner = true - for i := 0; i < b.N; i++ { - rs, err := se.Execute("select * from t a join t b on a.col = b.col limit 1") - if err != nil { - b.Fatal(err) - } - readResult(rs[0], 1) - } - plan.UseNewPlanner = false -} diff --git a/executor/adapter.go b/executor/adapter.go index f6eae3bae3bc0..9c7e65320775f 100644 --- a/executor/adapter.go +++ b/executor/adapter.go @@ -31,7 +31,7 @@ type recordSet struct { } func (a *recordSet) Fields() ([]*ast.ResultField, error) { - if plan.UseNewPlanner && len(a.fields) == 0 { + if len(a.fields) == 0 { for _, col := range a.schema { rf := &ast.ResultField{ ColumnAsName: col.ColName, diff --git a/executor/executor_write.go b/executor/executor_write.go index ec607979e68fb..82c26fa5f0758 100644 --- a/executor/executor_write.go +++ b/executor/executor_write.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/model" "github.com/pingcap/tidb/mysql" - "github.com/pingcap/tidb/plan" "github.com/pingcap/tidb/sessionctx/variable" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/terror" @@ -305,19 +304,12 @@ func (e *DeleteExec) Next() (*Row, error) { tblNames := make(map[string]string) if e.IsMultiTable { // Delete from multiple tables should consider table ident list. - if !plan.UseNewPlanner { - fs := e.SelectExec.Fields() - for _, f := range fs { - if len(f.TableAsName.L) > 0 { - tblNames[f.TableAsName.L] = f.TableName.Name.L - } else { - tblNames[f.TableName.Name.L] = f.TableName.Name.L - } - } - } else { - schema := e.SelectExec.Schema() - for _, s := range schema { - tblNames[s.TblName.L] = s.TblName.L + fs := e.SelectExec.Fields() + for _, f := range fs { + if len(f.TableAsName.L) > 0 { + tblNames[f.TableAsName.L] = f.TableName.Name.L + } else { + tblNames[f.TableName.Name.L] = f.TableName.Name.L } } if len(tblNames) != 0 { diff --git a/interpreter/main.go b/interpreter/main.go index 0ff8af403e056..7d84c5f8d4ea3 100644 --- a/interpreter/main.go +++ b/interpreter/main.go @@ -27,18 +27,16 @@ import ( "github.com/ngaut/log" "github.com/peterh/liner" "github.com/pingcap/tidb" - "github.com/pingcap/tidb/plan" "github.com/pingcap/tidb/terror" "github.com/pingcap/tidb/util/printer" ) var ( - logLevel = flag.String("L", "error", "log level") - store = flag.String("store", "goleveldb", "the name for the registered storage, e.g. memory, goleveldb, boltdb") - dbPath = flag.String("dbpath", "test", "db path") - dbName = flag.String("dbname", "test", "default db name") - lease = flag.Int("lease", 1, "schema lease seconds, very dangerous to change only if you know what you do") - useNewPlan = flag.Int("newplan", 1, "If use new planner.") + logLevel = flag.String("L", "error", "log level") + store = flag.String("store", "goleveldb", "the name for the registered storage, e.g. memory, goleveldb, boltdb") + dbPath = flag.String("dbpath", "test", "db path") + dbName = flag.String("dbname", "test", "default db name") + lease = flag.Int("lease", 1, "schema lease seconds, very dangerous to change only if you know what you do") line *liner.State historyPath = "/tmp/tidb_interpreter" @@ -180,10 +178,6 @@ func main() { tidb.SetSchemaLease(time.Duration(*lease) * time.Second) - if *useNewPlan == 0 { - plan.UseNewPlanner = false - } - // use test as default DB. mdb, err := sql.Open(tidb.DriverName, *store+"://"+*dbPath+"/"+*dbName) if err != nil { diff --git a/plan/logical_plan_builder.go b/plan/logical_plan_builder.go index 243fba3b3a265..784583dde27cf 100644 --- a/plan/logical_plan_builder.go +++ b/plan/logical_plan_builder.go @@ -25,9 +25,6 @@ import ( "github.com/pingcap/tidb/util/types" ) -// UseNewPlanner means if use the new planner. -var UseNewPlanner = true - type idAllocator struct { id int } diff --git a/plan/plan_test.go b/plan/plan_test.go index b94bf478259b2..77beabc6043d0 100644 --- a/plan/plan_test.go +++ b/plan/plan_test.go @@ -98,7 +98,6 @@ func newMockResolve(node ast.Node) error { } func (s *testPlanSuite) TestPredicatePushDown(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { sql string @@ -205,11 +204,9 @@ func (s *testPlanSuite) TestPredicatePushDown(c *C) { c.Assert(err, IsNil) c.Assert(ToString(p), Equals, ca.best, Commentf("for %s", ca.sql)) } - UseNewPlanner = false } func (s *testPlanSuite) TestJoinReOrder(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { sql string @@ -263,11 +260,9 @@ func (s *testPlanSuite) TestJoinReOrder(c *C) { p = res.p.PushLimit(nil) c.Assert(ToString(p), Equals, ca.best, Commentf("for %s", ca.sql)) } - UseNewPlanner = false } func (s *testPlanSuite) TestCBO(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { sql string @@ -353,11 +348,9 @@ func (s *testPlanSuite) TestCBO(c *C) { p = res.p.PushLimit(nil) c.Assert(ToString(p), Equals, ca.best, Commentf("for %s", ca.sql)) } - UseNewPlanner = false } func (s *testPlanSuite) TestRefine(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { sql string @@ -517,11 +510,9 @@ func (s *testPlanSuite) TestRefine(c *C) { np := res.p.PushLimit(nil) c.Assert(ToString(np), Equals, ca.best, Commentf("for %s", ca.sql)) } - UseNewPlanner = false } func (s *testPlanSuite) TestColumnPruning(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { sql string @@ -653,7 +644,6 @@ func (s *testPlanSuite) TestColumnPruning(c *C) { c.Assert(err, IsNil) check(p, c, ca.ans, comment) } - UseNewPlanner = false } func (s *testPlanSuite) TestAllocID(c *C) { @@ -667,7 +657,6 @@ func (s *testPlanSuite) TestAllocID(c *C) { } func (s *testPlanSuite) TestNewRangeBuilder(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() rb := &rangeBuilder{} @@ -850,7 +839,6 @@ func (s *testPlanSuite) TestNewRangeBuilder(c *C) { got := fmt.Sprintf("%v", result) c.Assert(got, Equals, ca.resultStr, Commentf("different for expr %s", ca.exprStr)) } - UseNewPlanner = false } func (s *testPlanSuite) TestTableScanWithOrder(c *C) { @@ -886,7 +874,6 @@ func (s *testPlanSuite) TestTableScanWithOrder(c *C) { } func (s *testPlanSuite) TestConstantFolding(c *C) { - UseNewPlanner = true defer testleak.AfterTest(c)() cases := []struct { @@ -956,7 +943,6 @@ func (s *testPlanSuite) TestConstantFolding(c *C) { c.Assert(expression.ComposeCNFCondition(selection.Conditions).ToString(), Equals, ca.resultStr, Commentf("different for expr %s", ca.exprStr)) } - UseNewPlanner = false } func (s *testPlanSuite) TestCoveringIndex(c *C) { diff --git a/tidb-server/main.go b/tidb-server/main.go index 29e3aa63fcd0d..86f32423ad1d6 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -28,7 +28,6 @@ import ( "github.com/pingcap/tidb" "github.com/pingcap/tidb/metric" "github.com/pingcap/tidb/perfschema" - "github.com/pingcap/tidb/plan" "github.com/pingcap/tidb/server" "github.com/pingcap/tidb/store/localstore/boltdb" "github.com/pingcap/tidb/store/tikv" @@ -46,7 +45,6 @@ var ( socket = flag.String("socket", "", "The socket file to use for connection.") enablePS = flag.Bool("perfschema", false, "If enable performance schema.") reportStatus = flag.Bool("report-status", true, "If enable status report HTTP service.") - useNewPlan = flag.Bool("newplan", true, "If use new planner.") logFile = flag.String("log-file", "", "log file path") ) @@ -94,10 +92,6 @@ func main() { perfschema.EnablePerfSchema() } - if !*useNewPlan { - plan.UseNewPlanner = false - } - // Create a session to load information schema. se, err := tidb.CreateSession(store) if err != nil {