@@ -41,13 +41,26 @@ func (s *testSuite) TestShowStatsHistograms(c *C) {
4141 tk .MustExec ("drop table if exists t" )
4242 tk .MustExec ("create table t (a int, b int)" )
4343 tk .MustExec ("analyze table t" )
44- result := tk .MustQuery ("show stats_histograms" ).Sort ()
44+ result := tk .MustQuery ("show stats_histograms" )
45+ c .Assert (len (result .Rows ()), Equals , 0 )
46+ tk .MustExec ("insert into t values(1,1)" )
47+ tk .MustExec ("analyze table t" )
48+ result = tk .MustQuery ("show stats_histograms" ).Sort ()
4549 c .Assert (len (result .Rows ()), Equals , 2 )
4650 c .Assert (result .Rows ()[0 ][2 ], Equals , "a" )
4751 c .Assert (result .Rows ()[1 ][2 ], Equals , "b" )
4852 result = tk .MustQuery ("show stats_histograms where column_name = 'a'" )
4953 c .Assert (len (result .Rows ()), Equals , 1 )
5054 c .Assert (result .Rows ()[0 ][2 ], Equals , "a" )
55+
56+ tk .MustExec ("drop table t" )
57+ tk .MustExec ("create table t(a int, b int, c int, index idx_b(b), index idx_c_a(c, a))" )
58+ tk .MustExec ("insert into t values(1,null,1),(2,null,2),(3,3,3),(4,null,4),(null,null,null)" )
59+ res := tk .MustQuery ("show stats_histograms where table_name = 't'" )
60+ c .Assert (len (res .Rows ()), Equals , 0 )
61+ tk .MustExec ("analyze table t index idx_b" )
62+ res = tk .MustQuery ("show stats_histograms where table_name = 't' and column_name = 'idx_b'" )
63+ c .Assert (len (res .Rows ()), Equals , 1 )
5164}
5265
5366func (s * testSuite ) TestShowStatsBuckets (c * C ) {
0 commit comments