Skip to content

Commit 262850a

Browse files
committed
Merge branch 'master' into aa_merge_master_2
2 parents 3cf9e5f + 6ff1adf commit 262850a

File tree

315 files changed

+20535
-13918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+20535
-13918
lines changed

.github/skills/tidb-test-guidelines/SKILL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ description: Decide where to place TiDB tests and how to write them (basic struc
2424
- If a test must use multiple sessions or domains (for example, cross-session cache behavior), keep the extra stores/testkits but document why in the test.
2525
- Keep per-test runtime short; consolidate similar checks only if runtime stays reasonable.
2626
- Use behavior-based test names; never use issue-id-only names.
27+
- In test code, use the variable name `tk` for `*testkit.TestKit` (avoid `testKit`).
28+
- When merging multiple tests into one, keep a single `store` and a single `tk` unless multi-session behavior is required; do not create a new store/tk inside the same test body without a documented reason.
2729

2830
## Placement rules
2931

@@ -38,9 +40,11 @@ description: Decide where to place TiDB tests and how to write them (basic struc
3840

3941
- Apply the same rules (placement, shard_count, naming) to other packages beyond `pkg/planner`.
4042
- Use existing testdata patterns (`*_in.json`, `*_out.json`, `*_xut.json`) in the same directory when extending suites. When tests use testdata, run with `-record --tags=intest` as needed.
43+
- For `pkg/planner/core/casetest/rule` predicate pushdown cases, keep SQL in `predicate_pushdown_suite_in.json` and record both `EXPLAIN format='brief'` and query results via the test runner (see `rule_predicate_pushdown_test.go`).
4144
- When moving benchmarks between packages, update any `TestBenchDaily` wrappers that list them and keep `Makefile` `bench-daily` entries aligned with the new package location.
4245
- When updating tests in any `pkg/*` package, ask AI to update the corresponding case map under `references/`.
4346
- When updating tests in any other directory, also update this skill: add or extend a case map under `references/` and add guidance in this `SKILL.md` so future changes stay consistent.
47+
- When merging issue regression tests into existing behavior tests, keep the issue id in SQL comments (e.g. `/* issue:12345 */`) or nearby comments for traceability.
4448
- Prefer unit tests over `tests/integrationtest` for end-to-end coverage unless you need to avoid union-storage executor differences or require full workflow validation.
4549
- When tests read source files under Bazel, use `go/runfiles` and ensure the target file is exported via `exports_files()` in its owning `BUILD.bazel`.
4650
- For Bazel runfiles, be ready to include the workspace prefix (from `TEST_WORKSPACE`) in the runfile path if needed.

.github/skills/tidb-test-guidelines/references/planner-case-map.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@
120120
## pkg/planner/core/casetest
121121

122122
### Tests
123-
- `pkg/planner/core/casetest/integration_test.go` - planner/core/casetest: Cascades integration cases for verbose explain outputs, TiFlash isolation/MPP/partition behaviors, fix-control regressions, and issue-specific plan checks.
123+
- `pkg/planner/core/casetest/integration_test.go` - planner/core/casetest: Cascades integration cases for verbose explain outputs, TiFlash isolation/MPP/partition behaviors, fix-control regressions, and merged issue regressions.
124124
- `pkg/planner/core/casetest/main_test.go` - Configures default goleak settings and registers testdata.
125-
- `pkg/planner/core/casetest/plan_test.go` - planner/core/casetest: Tests prefer range scan and normalized plan output.
125+
- `pkg/planner/core/casetest/plan_test.go` - planner/core/casetest: Tests plan digest stability, normalized plan output, and related regressions.
126126
- `pkg/planner/core/casetest/stats_test.go` - planner/core/casetest: Tests group NDVs.
127-
- `pkg/planner/core/casetest/tiflash_predicate_push_down_test.go` - planner/core/casetest: Tests TiFlash late materialization and inverted index plans.
128127

129128
### Testdata
130129
- `pkg/planner/core/casetest/testdata/integration_suite_in.json`
@@ -167,7 +166,7 @@
167166
## pkg/planner/core/casetest/cbotest
168167

169168
### Tests
170-
- `pkg/planner/core/casetest/cbotest/cbo_test.go` - planner/core/casetest/cbotest: Tests CBO regressions, no-analyze stats, and straight join cases.
169+
- `pkg/planner/core/casetest/cbotest/cbo_test.go` - planner/core/casetest/cbotest: Tests CBO analyze suites, no-analyze stats, straight join cases, and merged issue regressions.
171170
- `pkg/planner/core/casetest/cbotest/main_test.go` - Configures default goleak settings and registers testdata.
172171

173172
### Testdata
@@ -293,7 +292,7 @@
293292
## pkg/planner/core/casetest/join
294293

295294
### Tests
296-
- `pkg/planner/core/casetest/join/join_test.go` - planner/core/casetest/join: Tests semijoin order, NULL-safe join EQ, join condition simplification, join key preservation, and issue regressions.
295+
- `pkg/planner/core/casetest/join/join_test.go` - planner/core/casetest/join: Tests semijoin order, NULL-safe join EQ, join condition simplification, join key preservation, and merged issue regressions.
297296
- `pkg/planner/core/casetest/join/main_test.go` - Configures default goleak settings and registers testdata.
298297

299298
## pkg/planner/core/casetest/logicalplan
@@ -306,7 +305,7 @@
306305

307306
### Tests
308307
- `pkg/planner/core/casetest/mpp/main_test.go` - Configures default goleak settings and registers testdata.
309-
- `pkg/planner/core/casetest/mpp/mpp_test.go` - planner/core/casetest/mpp: Tests MPP joins (broadcast/shuffle), exchange pruning, fine-grained join/agg, pushdown rules, versioning, and issue regressions.
308+
- `pkg/planner/core/casetest/mpp/mpp_test.go` - planner/core/casetest/mpp: Tests MPP joins (broadcast/shuffle), exchange pruning, join/agg pushdown, versioning, and merged issue regressions.
310309

311310
### Testdata
312311
- `pkg/planner/core/casetest/mpp/testdata/integration_suite_in.json`
@@ -324,7 +323,7 @@
324323
### Tests
325324
- `pkg/planner/core/casetest/partition/integration_partition_test.go` - planner/core/casetest/partition: Tests list/list-columns pruning and dynamic/static plan differences.
326325
- `pkg/planner/core/casetest/partition/main_test.go` - Configures default goleak settings and registers testdata.
327-
- `pkg/planner/core/casetest/partition/partition_pruner_test.go` - planner/core/casetest/partition: Tests hash/list partition pruning and partition info extraction.
326+
- `pkg/planner/core/casetest/partition/partition_pruner_test.go` - planner/core/casetest/partition: Tests partition pruning rules, extract functions, and merged issue regressions.
328327

329328
### Testdata
330329
- `pkg/planner/core/casetest/partition/testdata/integration_partition_suite_in.json`
@@ -338,7 +337,7 @@
338337

339338
### Tests
340339
- `pkg/planner/core/casetest/physicalplantest/main_test.go` - Configures default goleak settings and registers testdata.
341-
- `pkg/planner/core/casetest/physicalplantest/physical_plan_test.go` - planner/core/casetest/physicalplantest: Tests refine/agg eliminator with plan suite data.
340+
- `pkg/planner/core/casetest/physicalplantest/physical_plan_test.go` - planner/core/casetest/physicalplantest: Tests plan suite cases, MPP hints, agg elimination, and merged issue regressions.
342341

343342
### Testdata
344343
- `pkg/planner/core/casetest/physicalplantest/testdata/cascades_template_in.json`
@@ -358,7 +357,7 @@
358357
- `pkg/planner/core/casetest/plancache/plan_cache_rebuild_test.go` - planner/core/casetest/plancache: Tests cached-plan clone/rebuild correctness and fast point get cloning.
359358
- `pkg/planner/core/casetest/plancache/plan_cache_suite_test.go` - planner/core/casetest/plancache: Tests prepared/non-prepared plan cache regressions, bindings, MV index, and resource groups.
360359
- `pkg/planner/core/casetest/plancache/plan_cache_test.go` - planner/core/casetest/plancache: Tests deallocate prepare cache separation and cache key benchmarks.
361-
- `pkg/planner/core/casetest/plancache/plan_cacheable_checker_test.go` - planner/core/casetest/plancache: Tests cacheable checks, IN-list fix control, and issue regressions.
360+
- `pkg/planner/core/casetest/plancache/plan_cacheable_checker_test.go` - planner/core/casetest/plancache: Tests cacheable checks, IN-list fix control, and merged issue regressions.
362361

363362
### Testdata
364363
- `pkg/planner/core/casetest/plancache/testdata/plan_cache_suite_in.json`
@@ -396,9 +395,9 @@
396395
- `pkg/planner/core/casetest/rule/rule_eliminate_projection_test.go` - planner/core/casetest/rule: Tests projection elimination with expression indexes.
397396
- `pkg/planner/core/casetest/rule/rule_inject_extra_projection_test.go` - planner/core/casetest/rule: Tests cast injection for aggregate function modes.
398397
- `pkg/planner/core/casetest/rule/rule_join_reorder_test.go` - planner/core/casetest/rule: Tests join reorder hints, hash-join toggle, and TiFlash/dynamic partitions.
399-
- `pkg/planner/core/casetest/rule/rule_outer2inner_test.go` - planner/core/casetest/rule: Tests outer-to-inner rewrites with regressions.
398+
- `pkg/planner/core/casetest/rule/rule_outer2inner_test.go` - planner/core/casetest/rule: Tests outer-to-inner rewrites with merged issue regressions.
400399
- `pkg/planner/core/casetest/rule/rule_outer_to_semi_join_test.go` - planner/core/casetest/rule: Tests outer-to-semi join rewrite correctness.
401-
- `pkg/planner/core/casetest/rule/rule_predicate_pushdown_test.go` - planner/core/casetest/rule: Tests predicate pushdown cases with collation-sensitive constants.
400+
- `pkg/planner/core/casetest/rule/rule_predicate_pushdown_test.go` - planner/core/casetest/rule: Tests predicate pushdown cases and records plan+result for selected cases.
402401
- `pkg/planner/core/casetest/rule/rule_predicate_simplification_test.go` - planner/core/casetest/rule: Tests predicate simplification across complex schemas.
403402

404403
### Testdata
@@ -477,7 +476,7 @@
477476
### Tests
478477
- `pkg/planner/core/casetest/windows/main_test.go` - Configures default goleak settings and registers testdata.
479478
- `pkg/planner/core/casetest/windows/widow_with_exist_subquery_test.go` - planner/core/casetest/windows: Tests window functions with correlated EXISTS subqueries.
480-
- `pkg/planner/core/casetest/windows/window_push_down_test.go` - planner/core/casetest/windows: Tests TiFlash window pushdown plans and warnings.
479+
- `pkg/planner/core/casetest/windows/window_push_down_test.go` - planner/core/casetest/windows: Tests TiFlash window pushdown plans, warnings, and merged issue regressions.
481480

482481
### Testdata
483482
- `pkg/planner/core/casetest/windows/testdata/window_push_down_suite_in.json`

.gitignore

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,80 @@
1+
# OS / filesystem
12
__MACOSX
2-
bin
3-
/tidb-server/tidb-server
4-
/tidb-server/debug
5-
coverage.out
3+
.DS_Store
4+
5+
# Editor / IDE
66
.idea/
77
*.iml
8+
.ijwb/
9+
.vscode
810
*.swp
9-
*.log
10-
*.test.bin
1111
tags
12-
profile.coverprofile
13-
mysql_tester
14-
tests/integrationtest/integration-test.out
15-
tests/integrationtest/integrationtest_tidb-server
16-
tests/integrationtest/s/
17-
tests/integrationtest/replayer/
18-
*.fail.go
12+
13+
# Local tooling metadata
14+
.specstory
15+
.cursor
16+
.codex
17+
.trae
18+
19+
# Go workspace / tooling
20+
go.work
21+
go.work.sum
22+
.golangci.bck.yml
23+
24+
# Binaries / generated tools
25+
bin
26+
/tidb-server/tidb-server
27+
/tidb-server/debug
1928
tools/bin/
20-
vendor
29+
mysql_tester
30+
genkeyword
2131
/_tools/
22-
.DS_Store
23-
.vscode
24-
bench_daily.json
25-
coverage.txt
26-
var
27-
fix.sql
28-
export-20*/
29-
*-coverage.xml
30-
*-junit-report.xml
31-
compose-dev.yaml
32-
# Files generated when testing
33-
out
32+
33+
# Dependencies
34+
vendor
35+
36+
# Bazel
37+
# skywalking-eyes 0.4 cannot handle the git glob syntax correctly. As a temporary workaround,
38+
# we explicitly list the bazel-related files and directories to be ignored.
39+
# TODO: test and consider upgrading skywalking-eyes in the future.
3440
/_bazel
41+
bazel-*
3542
bazel-bin
3643
bazel-out
3744
bazel-testlogs
3845
bazel-tidb
3946
MODULE.bazel.lock
40-
.ijwb/
41-
/oom_record/
42-
*.log.json
43-
genkeyword
47+
48+
# Testing / coverage / reports
49+
# Files generated when testing
50+
out
4451
test_coverage
52+
coverage.out
53+
coverage.txt
4554
coverage.dat
46-
.specstory
47-
.golangci.bck.yml
48-
go.work
49-
go.work.sum
50-
.cursor
51-
.codex
55+
profile.coverprofile
56+
*-coverage.xml
57+
*-junit-report.xml
58+
*.test.bin
59+
*.fail.go
60+
*.log
61+
*.log.json
5262
*__failpoint_stash__
63+
/oom_record/
64+
65+
# Integration tests
66+
tests/integrationtest/integration-test.out
67+
tests/integrationtest/integrationtest_tidb-server
68+
tests/integrationtest/s/
69+
tests/integrationtest/replayer/
70+
71+
# Local dev artifacts
72+
bench_daily.json
73+
compose-dev.yaml
74+
fix.sql
75+
export-20*/
76+
var
77+
5378
# Personal config files
5479
/*config.toml
5580
.cache
56-
.trae

AGENTS.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ This file provides guidance to agents when working with code in this repository.
4949

5050
- When creating new source files (for example: `*.go`), include the standard TiDB copyright (and Apache 2.0 license) header at the top; copy the header from an existing file in the same directory and update the year if needed.
5151

52+
### Notes
53+
54+
- Notes directory: `docs/note/<component>/` is the canonical location for component notes. If missing, create it and add an entry here.
55+
- Notes rules: update existing sections when topics overlap; append new sections only for new topics. Purpose: capture decisions, pitfalls, and test patterns.
56+
- Planner rule notes: `docs/note/planner/rule/rule_ai_notes.md`.
57+
- If a single notes file exceeds 2000 lines, split by functionality into multiple markdown files and update references here.
58+
5259
## Building
5360

5461
### Bazel bootstrap (`make bazel_prepare`)
@@ -68,7 +75,7 @@ Recommended local build flow:
6875
make bazel_prepare
6976

7077
# build
71-
make
78+
make bazel_bin
7279

7380
# optional: regenerate generated code if needed
7481
make gogenerate
@@ -136,6 +143,13 @@ The following points must be achieved:
136143
2. Existing tests should be reused as much as possible, and existing test data and table structures should be utilized. Modifications should be made on this basis to accommodate the new tests.
137144
3. Some tests use the JSON files in `testdata` as the test set (`xxxx_in.json`) and the validation set (`xxxx_out.json` and `xxxx_xut.json`). It is necessary to modify the test set before running the unit test.
138145

146+
#### Regression tests for bug fixes
147+
148+
- A bug fix should include a regression test that reproduces the issue.
149+
- Verify the new/updated test fails on the buggy code (before the fix), and passes after the fix.
150+
- Example approaches: run the test on `upstream/master` (or the target base commit) before applying the fix, or temporarily revert the fix and confirm the test fails.
151+
- Include the exact test command in the PR description under `Tests` (for example: `go test -run TestXxx --tags=intest ./pkg/...`).
152+
139153
### Integration Tests
140154

141155
Integration tests are located in the `/tests/integrationtest` directory.
@@ -249,6 +263,17 @@ curl -f "http://${PD_ADDR}/pd/api/v1/version"
249263
- **Environment check**: Check for running playground processes before starting.
250264
- **Fmt-only changes**: If PR only involves code formatting (gofmt, indentation), do NOT run time-consuming `realtikvtest`. Just ensure local compilation passes.
251265

266+
## Issue Instructions
267+
268+
- When submitting an issue, follow the GitHub templates under `.github/ISSUE_TEMPLATE/` and fill in all required fields.
269+
- Bug reports should include minimal reproduction steps, expected/actual behavior, and the TiDB version (for example: the output of `SELECT tidb_version()`).
270+
- Search existing issues/PRs first to avoid duplicates (try `gh` first; for example: `gh search issues --repo pingcap/tidb --include-prs "<keywords>"`), and include any relevant logs/configuration/SQL plans to help diagnosis.
271+
- Apply labels to help triage:
272+
- `type/*` is usually applied by the issue template; add `type/regression` when applicable.
273+
- Add at least one `component/*` label (for example: `component/ddl`, `component/br`, `component/parser`).
274+
- For bug/regression issues, `severity/*` and affected-version label(s) are required (for example: `affects-8.5`; use `may-affects-*` if unsure).
275+
- If you don't have permission to add labels, include a `Suggested labels: ...` line in the issue body.
276+
252277
## Pull Request Instructions
253278

254279
### PR title

0 commit comments

Comments
 (0)