diff --git a/executor/analyze.go b/executor/analyze.go index 52f79e79664c9..95a4f310eed1b 100755 --- a/executor/analyze.go +++ b/executor/analyze.go @@ -850,7 +850,7 @@ func (e *AnalyzeFastExec) updateCollectorSamples(sValue []byte, sKey kv.Key, sam for j, idxInfo := range e.idxsInfo { idxVals := make([]types.Datum, 0, len(idxInfo.Columns)) for _, idxCol := range idxInfo.Columns { - for _, colInfo := range e.colsInfo { + for _, colInfo := range e.tblInfo.Columns { if colInfo.Name == idxCol.Name { v, err := e.getValueByInfo(colInfo, values) if err != nil { diff --git a/executor/analyze_test.go b/executor/analyze_test.go index a400105140314..f757e2d71a677 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -361,6 +361,17 @@ func (s *testSuite1) TestIssue15751(c *C) { tk.MustExec("ANALYZE TABLE t0") } +func (s *testSuite1) TestIssue15752(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t0") + tk.MustExec("CREATE TABLE t0(c0 INT)") + tk.MustExec("INSERT INTO t0 VALUES (0)") + tk.MustExec("CREATE INDEX i0 ON t0(c0)") + tk.MustExec("set @@tidb_enable_fast_analyze=1") + tk.MustExec("ANALYZE TABLE t0 INDEX i0") +} + func (s *testSuite1) TestAnalyzeIncremental(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test")