From 7f6b0bbcfd2a61a17285953b3a2c92ce19a54fb7 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Thu, 6 Jun 2024 13:10:35 +0800 Subject: [PATCH] * Signed-off-by: Weizhen Wang --- statistics/handle/handle_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index d9524383e6f6c..ee7030aa7273f 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -28,6 +28,7 @@ import ( "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/parser/model" + "github.com/pingcap/tidb/parser/mysql" "github.com/pingcap/tidb/session" "github.com/pingcap/tidb/sessionctx/variable" "github.com/pingcap/tidb/statistics" @@ -505,11 +506,20 @@ func TestInitStats(t *testing.T) { require.Equal(t, uint8(0x36), cols[1].LastAnalyzePos.GetBytes()[0]) require.Equal(t, uint8(0x37), cols[2].LastAnalyzePos.GetBytes()[0]) require.Equal(t, uint8(0x38), cols[3].LastAnalyzePos.GetBytes()[0]) + table1 := h.GetTableStats(tbl.Meta()) + for _, column := range table1.Columns { + if mysql.HasPriKeyFlag(column.Info.GetFlag()) { + // primary key column has no stats info, because primary key's is_index is false. so it cannot load the topn + require.Nil(t, column.TopN) + } + require.False(t, column.IsFullLoad()) + } h.Clear() require.NoError(t, h.Update(is)) - table1 := h.GetTableStats(tbl.Meta()) + table1 = h.GetTableStats(tbl.Meta()) assertTableEqual(t, table0, table1) h.SetLease(0) + } func TestInitStatsVer2(t *testing.T) {