From 5de1105f97918295a1b3ad23c8b551ae00b9a255 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Fri, 6 Dec 2024 16:32:59 +0800 Subject: [PATCH] statistics: lite init used wrong value to build table stats ver (#58021) close pingcap/tidb#58020 --- pkg/statistics/handle/bootstrap.go | 2 +- pkg/statistics/handle/handletest/handle_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/statistics/handle/bootstrap.go b/pkg/statistics/handle/bootstrap.go index c354fb9d9d911..efde5b994aac2 100644 --- a/pkg/statistics/handle/bootstrap.go +++ b/pkg/statistics/handle/bootstrap.go @@ -134,7 +134,7 @@ func (*Handle) initStatsHistograms4ChunkLite(cache statstypes.StatsCache, iter * id := row.GetInt64(2) ndv := row.GetInt64(3) nullCount := row.GetInt64(5) - statsVer := row.GetInt64(7) + statsVer := row.GetInt64(8) // All the objects in the table share the same stats version. if statsVer != statistics.Version0 { table.StatsVer = int(statsVer) diff --git a/pkg/statistics/handle/handletest/handle_test.go b/pkg/statistics/handle/handletest/handle_test.go index 5307cf95ca866..ad07df8879ab6 100644 --- a/pkg/statistics/handle/handletest/handle_test.go +++ b/pkg/statistics/handle/handletest/handle_test.go @@ -1414,6 +1414,7 @@ func TestInitStatsLite(t *testing.T) { require.NoError(t, h.InitStatsLite(context.Background())) statsTbl1 := h.GetTableStats(tblInfo) checkAllEvicted(t, statsTbl1) + require.Equal(t, int(statistics.Version2), statsTbl1.StatsVer) { // internal.AssertTableEqual(t, statsTbl0, statsTbl1) // statsTbl0 is loaded when the cache has pseudo table.