Skip to content

Commit d406be6

Browse files
authored
statistics: fix Clone method to include checked field in ColAndIdxExistenceMap (#60171)
close #60104
1 parent 37855f9 commit d406be6

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

pkg/statistics/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ go_test(
7979
"sample_test.go",
8080
"scalar_test.go",
8181
"statistics_test.go",
82+
"table_test.go",
8283
],
8384
data = glob(["testdata/**"]),
8485
embed = [":statistics"],
8586
flaky = True,
86-
shard_count = 37,
87+
shard_count = 38,
8788
deps = [
8889
"//pkg/config",
8990
"//pkg/meta/model",

pkg/statistics/table.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func (m *ColAndIdxExistenceMap) ColNum() int {
163163
// Clone deeply copies the map.
164164
func (m *ColAndIdxExistenceMap) Clone() *ColAndIdxExistenceMap {
165165
mm := NewColAndIndexExistenceMap(len(m.colAnalyzed), len(m.idxAnalyzed))
166+
mm.checked = m.checked
166167
mm.colAnalyzed = maps.Clone(m.colAnalyzed)
167168
mm.idxAnalyzed = maps.Clone(m.idxAnalyzed)
168169
return mm

pkg/statistics/table_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 PingCAP, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package statistics
16+
17+
import (
18+
"testing"
19+
20+
"github.com/stretchr/testify/require"
21+
)
22+
23+
func TestCloneColAndIdxExistenceMap(t *testing.T) {
24+
m := NewColAndIndexExistenceMapWithoutSize()
25+
m.InsertCol(1, true)
26+
m.InsertIndex(1, true)
27+
m.SetChecked()
28+
29+
m2 := m.Clone()
30+
require.Equal(t, m, m2)
31+
}

0 commit comments

Comments
 (0)