Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: lzmhhh123 <lzmhhh123@gmail.com>
  • Loading branch information
lzmhhh123 committed Mar 11, 2021
1 parent 77320da commit 7f3e19e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ func (s *testSerialSuite2) TestIssue20874(c *C) {

func (s *testSuite1) TestAnalyzeClusteredIndexPrimary(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t0")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t0(a varchar(20), primary key(a) clustered)")
Expand All @@ -937,5 +938,7 @@ func (s *testSuite1) TestAnalyzeClusteredIndexPrimary(c *C) {
tk.MustExec("insert into t1 values('1111')")
tk.MustExec("analyze table t0 index primary")
tk.MustExec("analyze table t1 index primary")
tk.MustQuery("show stats_buckets").Check(testkit.Rows(""))
tk.MustQuery("show stats_buckets").Check(testkit.Rows(
"test t0 PRIMARY 1 0 1 1 1111 1111 0",
"test t1 PRIMARY 1 0 1 1 1111 1111 0"))
}
4 changes: 3 additions & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,8 @@ func (b *PlanBuilder) buildAnalyzeIndex(as *ast.AnalyzeTableStmt, opts map[ast.A
for _, idxName := range as.IndexNames {
if isPrimaryIndex(idxName) {
handleCols := BuildHandleColsForAnalyze(b.ctx, tblInfo)
if handleCols != nil {
// Fast analyze use analyze column to solve int handle.
if handleCols != nil && handleCols.IsInt() && b.ctx.GetSessionVars().EnableFastAnalyze {
for i, id := range physicalIDs {
if id == tblInfo.ID {
id = -1
Expand All @@ -1749,6 +1750,7 @@ func (b *PlanBuilder) buildAnalyzeIndex(as *ast.AnalyzeTableStmt, opts map[ast.A
}
p.ColTasks = append(p.ColTasks, AnalyzeColumnsTask{HandleCols: handleCols, analyzeInfo: info, TblInfo: tblInfo})
}
continue
}
}
idx := tblInfo.FindIndexByName(idxName.L)
Expand Down

0 comments on commit 7f3e19e

Please sign in to comment.