diff --git a/pkg/statistics/BUILD.bazel b/pkg/statistics/BUILD.bazel index a1074ff243673..499f386d8e73b 100644 --- a/pkg/statistics/BUILD.bazel +++ b/pkg/statistics/BUILD.bazel @@ -79,11 +79,12 @@ go_test( "sample_test.go", "scalar_test.go", "statistics_test.go", + "table_test.go", ], data = glob(["testdata/**"]), embed = [":statistics"], flaky = True, - shard_count = 37, + shard_count = 38, deps = [ "//pkg/config", "//pkg/meta/model", diff --git a/pkg/statistics/table.go b/pkg/statistics/table.go index 646cf464085da..a54b94295c022 100644 --- a/pkg/statistics/table.go +++ b/pkg/statistics/table.go @@ -163,6 +163,7 @@ func (m *ColAndIdxExistenceMap) ColNum() int { // Clone deeply copies the map. func (m *ColAndIdxExistenceMap) Clone() *ColAndIdxExistenceMap { mm := NewColAndIndexExistenceMap(len(m.colAnalyzed), len(m.idxAnalyzed)) + mm.checked = m.checked mm.colAnalyzed = maps.Clone(m.colAnalyzed) mm.idxAnalyzed = maps.Clone(m.idxAnalyzed) return mm diff --git a/pkg/statistics/table_test.go b/pkg/statistics/table_test.go new file mode 100644 index 0000000000000..7c4ed913f4ee5 --- /dev/null +++ b/pkg/statistics/table_test.go @@ -0,0 +1,31 @@ +// Copyright 2025 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package statistics + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCloneColAndIdxExistenceMap(t *testing.T) { + m := NewColAndIndexExistenceMapWithoutSize() + m.InsertCol(1, true) + m.InsertIndex(1, true) + m.SetChecked() + + m2 := m.Clone() + require.Equal(t, m, m2) +}