diff --git a/planner/core/common_plans.go b/planner/core/common_plans.go index 3429cd9e1f..ba450d80ed 100644 --- a/planner/core/common_plans.go +++ b/planner/core/common_plans.go @@ -631,7 +631,7 @@ func (e *Explain) prepareSchema() error { e.Format = types.ExplainFormatROW } switch { - case (format == types.ExplainFormatROW && (!e.Analyze && e.RuntimeStatsColl == nil)) || (format == types.ExplainFormatBrief): + case (format == types.ExplainFormatROW || format == types.ExplainFormatBrief) && (!e.Analyze && e.RuntimeStatsColl == nil): fieldNames = []string{"id", "estRows", "task", "access object", "operator info"} case format == types.ExplainFormatVerbose || format == types.ExplainFormatTrueCardCost: if e.Analyze || e.RuntimeStatsColl != nil { @@ -639,7 +639,7 @@ func (e *Explain) prepareSchema() error { } else { fieldNames = []string{"id", "estRows", "estCost", "task", "access object", "operator info"} } - case format == types.ExplainFormatROW && (e.Analyze || e.RuntimeStatsColl != nil): + case (format == types.ExplainFormatROW || format == types.ExplainFormatBrief) && (e.Analyze || e.RuntimeStatsColl != nil): fieldNames = []string{"id", "estRows", "actRows", "task", "access object", "execution info", "operator info", "memory", "disk"} case format == types.ExplainFormatDOT: fieldNames = []string{"dot contents"} diff --git a/planner/core/plan_test.go b/planner/core/plan_test.go index cbc8e2d79a..4a4d8e0edf 100644 --- a/planner/core/plan_test.go +++ b/planner/core/plan_test.go @@ -710,6 +710,29 @@ func BenchmarkEncodeFlatPlan(b *testing.B) { } } +func TestIssue35090(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test;") + tk.MustExec("drop table if exists p, t;") + tk.MustExec("create table p (id int, c int, key i_id(id), key i_c(c));") + tk.MustExec("create table t (id int);") + tk.MustExec("insert into p values (3,3), (4,4), (6,6), (9,9);") + tk.MustExec("insert into t values (4), (9);") + tk.MustExec("select /*+ INL_JOIN(p) */ * from p, t where p.id = t.id;") + rows := [][]interface{}{ + {"IndexJoin"}, + {"├─TableReader(Build)"}, + {"│ └─Selection"}, + {"│ └─TableFullScan"}, + {"└─IndexLookUp(Probe)"}, + {" ├─Selection(Build)"}, + {" │ └─IndexRangeScan"}, + {" └─TableRowIDScan(Probe)"}, + } + tk.MustQuery("explain analyze format='brief' select /*+ INL_JOIN(p) */ * from p, t where p.id = t.id;").CheckAt([]int{0}, rows) +} + // Close issue 25729 func TestIssue25729(t *testing.T) { config.UpdateGlobal(func(conf *config.Config) {