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: check plan type when executing explain format="dot". (#17144) #17157

Merged
merged 9 commits into from
Jul 27, 2020
18 changes: 18 additions & 0 deletions executor/explainfor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,21 @@ func (s *testSuite) TestIssue11124(c *C) {
c.Assert(rs[i], DeepEquals, rs2[i])
}
}

func (s *testSuite) 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",
winoros marked this conversation as resolved.
Show resolved Hide resolved
"└─TableDual_4 1.00 root rows:1",
winoros marked this conversation as resolved.
Show resolved Hide resolved
))

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)
}
3 changes: 3 additions & 0 deletions planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ func (e *Explain) RenderResult() error {
if e.StmtPlan == nil {
return nil
}
if _, ok := e.StmtPlan.(PhysicalPlan); !ok {
return nil
}
switch strings.ToLower(e.Format) {
case ast.ExplainFormatROW:
e.explainedPlans = map[int]bool{}
Expand Down