Skip to content

Commit

Permalink
cherry pick pingcap#15889 to release-3.0
Browse files Browse the repository at this point in the history
Signed-off-by: sre-bot <sre-bot@pingcap.com>
  • Loading branch information
lzmhhh123 authored and sre-bot committed Apr 1, 2020
1 parent 62dab0a commit 3161c7c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,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 {
Expand Down
24 changes: 24 additions & 0 deletions executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,30 @@ func (s *testSuite1) TestFastAnalyze(c *C) {
"test t2 a 0 1 2 1 18446744073709551615 18446744073709551615"))
}

<<<<<<< HEAD
=======
func (s *testSuite1) TestIssue15751(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, c1 INT, PRIMARY KEY(c0, c1))")
tk.MustExec("INSERT INTO t0 VALUES (0, 0)")
tk.MustExec("set @@tidb_enable_fast_analyze=1")
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")
}

>>>>>>> 5d846cf... statistic: fix error when fast analyze on only indexes (#15889)
func (s *testSuite1) TestAnalyzeIncremental(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down

0 comments on commit 3161c7c

Please sign in to comment.