Skip to content

Conversation

JaySon-Huang
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #61133

Problem Summary:
TiDB accept this kind of invalid expression index. If tiflash replica is created and new rows inserted, it cause TiFlash crashes becuase unexpectedly need to create a "Nothing" data type in the storage layer. pingcap/tiflash#9891

TiDB [email protected]:test> CREATE TABLE `t2` (
                        ->   `id` int,
                        ->   KEY `idx_name` ((null))
                        -> );
TiDB [email protected]:test> show create table t2 \G
***************************[ 1. row ]***************************
Table        | t2
Create Table | CREATE TABLE `t2` (
  `id` int DEFAULT NULL,
  KEY `idx_name` ((null))

What changed and how does it work?

For a valid expression, the return value type stored in generated column should never be TypeNull. Add a check whether col.FieldType.GetType() == mysql.TypeNull is true. If it is true, then refuse to create the expression index.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix a bug that invalid expression index could be created

Signed-off-by: JaySon-Huang <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 15, 2025
Copy link

tiprow bot commented May 15, 2025

Hi @JaySon-Huang. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.2518%. Comparing base (da5de78) to head (3dea9d1).
Report is 7 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61135        +/-   ##
================================================
+ Coverage   73.1620%   75.2518%   +2.0898%     
================================================
  Files          1724       1746        +22     
  Lines        477317     489003     +11686     
================================================
+ Hits         349215     367984     +18769     
+ Misses       106687      98140      -8547     
- Partials      21415      22879      +1464     
Flag Coverage Δ
integration 49.3963% <100.0000%> (?)
unit 72.7842% <0.0000%> (+0.4065%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 62.6206% <ø> (+14.8793%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: JaySon-Huang <[email protected]>
@JaySon-Huang
Copy link
Contributor Author

/test check-dev2

Copy link

tiprow bot commented May 15, 2025

@JaySon-Huang: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 15, 2025
Copy link

ti-chi-bot bot commented May 16, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, wjhuang2016

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 16, 2025
Copy link

ti-chi-bot bot commented May 16, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-15 10:27:06.844560293 +0000 UTC m=+21993.100457687: ☑️ agreed by wjhuang2016.
  • 2025-05-16 07:51:13.658427139 +0000 UTC m=+99039.914324535: ☑️ agreed by lance6716.

@ti-chi-bot ti-chi-bot bot merged commit 555b81c into pingcap:master May 16, 2025
27 checks passed
Copy link

ti-chi-bot bot commented May 16, 2025

@JaySon-Huang: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/check_dev 3dea9d1 link unknown /test check-dev

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@JaySon-Huang JaySon-Huang deleted the reject_invalid_expr_idx branch May 16, 2025 09:24
ti-chi-bot bot pushed a commit to pingcap/tiflash that referenced this pull request May 19, 2025
ref #9891, ref pingcap/tidb#61133

ddl: Fix integration test of expr index
TiDB disable the invalid expression index `((null))` from being created by pingcap/tidb#61135. Update the integration test cases

Signed-off-by: JaySon-Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should refuse to create expression index with ((null))
3 participants