Skip to content

Commit

Permalink
stats: fix merge cm sketch panic (#13391) (#13395)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Nov 12, 2019
1 parent a9ef955 commit 1f720ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ func (s *testSuite1) TestFastAnalyze(c *C) {

// Test CM Sketch built from fast analyze.
tk.MustExec("create table t1(a int, b int, index idx(a, b))")
// Should not panic.
tk.MustExec("analyze table t1")
tk.MustExec("insert into t1 values (1,1),(1,1),(1,2),(1,2)")
tk.MustExec("analyze table t1")
tk.MustQuery("explain select a from t1 where a = 1").Check(testkit.Rows(
Expand Down
3 changes: 3 additions & 0 deletions statistics/cmsketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ func (c *CMSketch) mergeTopN(lTopN map[uint64][]*TopNMeta, rTopN map[uint64][]*T

// MergeCMSketch merges two CM Sketch.
func (c *CMSketch) MergeCMSketch(rc *CMSketch, numTopN uint32) error {
if c == nil || rc == nil {
return nil
}
if c.depth != rc.depth || c.width != rc.width {
return errors.New("Dimensions of Count-Min Sketch should be the same")
}
Expand Down

0 comments on commit 1f720ab

Please sign in to comment.