Skip to content

Commit

Permalink
planner: check plan type when executing explain format="dot". (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFall authored and sre-bot committed May 13, 2020
1 parent ae511d4 commit 6c46368
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions executor/explainfor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,21 @@ func (s *testPrepareSerialSuite) TestExplainForConnPlanCache(c *C) {
" └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo",
))
}

func (s *testPrepareSerialSuite) TestExplainDotForExplainPlan(c *C) {
tk := testkit.NewTestKit(c, s.store)

rows := tk.MustQuery("select connection_id()").Rows()
c.Assert(len(rows), Equals, 1)
connID := rows[0][0].(string)
tk.MustQuery("explain select 1").Check(testkit.Rows(
"Projection_3 1.00 root 1->Column#1",
"└─TableDual_4 1.00 root rows:1",
))

tkProcess := tk.Se.ShowProcess()
ps := []*util.ProcessInfo{tkProcess}
tk.Se.SetSessionManager(&mockSessionManager1{PS: ps})

tk.MustQuery(fmt.Sprintf("explain format=\"dot\" for connection %s", connID)).Check(nil)
}
4 changes: 3 additions & 1 deletion planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,9 @@ func (e *Explain) RenderResult() error {
return err
}
case ast.ExplainFormatDOT:
e.prepareDotInfo(e.TargetPlan.(PhysicalPlan))
if physicalPlan, ok := e.TargetPlan.(PhysicalPlan); ok {
e.prepareDotInfo(physicalPlan)
}
case ast.ExplainFormatHint:
hints := GenHintsFromPhysicalPlan(e.TargetPlan)
hints = append(hints, hint.ExtractTableHintsFromStmtNode(e.ExecStmt)...)
Expand Down

0 comments on commit 6c46368

Please sign in to comment.