diff --git a/executor/explainfor_test.go b/executor/explainfor_test.go index 7bc150a2b2bd9..3c5910339ff04 100644 --- a/executor/explainfor_test.go +++ b/executor/explainfor_test.go @@ -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", + "└─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) +} diff --git a/planner/core/common_plans.go b/planner/core/common_plans.go index 1189eda16fba5..434c52bbc2a0c 100644 --- a/planner/core/common_plans.go +++ b/planner/core/common_plans.go @@ -578,6 +578,9 @@ func (e *Explain) RenderResult() error { e.explainedPlans = map[int]bool{} e.explainPlanInRowFormat(e.TargetPlan, "root", "", true) case ast.ExplainFormatDOT: + if _, ok := e.TargetPlan.(PhysicalPlan); !ok { + return nil + } e.prepareDotInfo(e.TargetPlan.(PhysicalPlan)) default: return errors.Errorf("explain format '%s' is not supported now", e.Format)