Skip to content

Conversation

@YangKeao
Copy link
Member

@YangKeao YangKeao commented Jun 10, 2025

What problem does this PR solve?

Issue Number: close #61582, close #61583, close #61584, close #61585

Problem Summary:

The legacy SEM has many hard coded rules. This PR introduced a new SEM mechanism to make it possible to update the SEM rules without changing the code.

What changed and how does it work?

  1. Add a new config security.sem-config.
  2. Define the format of sem config and add a package /pkg/util/sem/v2 to parse this sem config.
  3. Add a package as the compatibility wrapper between legacy sem and the new sem in /pkg/util/sem/compat.
  4. Rewrite most of the legacy sem logic with the wrapper.
  5. Modify most of the SEM tests to test both the legacy one and the new one.

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.

Add a config `security.sem-config` to make the SEM rule configurable.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Jun 10, 2025
@YangKeao
Copy link
Member Author

YangKeao commented Jun 10, 2025

Don't be afraid of the lines dear reviewers! Most of them are just tests!

@codecov
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

❌ Patch coverage is 80.78704% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.9377%. Comparing base (78eadf2) to head (d05041a).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61634        +/-   ##
================================================
+ Coverage   72.7869%   74.9377%   +2.1507%     
================================================
  Files          1812       1864        +52     
  Lines        493988     504033     +10045     
================================================
+ Hits         359559     377711     +18152     
+ Misses       112580     103109      -9471     
- Partials      21849      23213      +1364     
Flag Coverage Δ
integration 48.8038% <3.0092%> (?)
unit 72.4666% <80.7870%> (+0.2224%) ⬆️

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

Components Coverage Δ
dumpling 52.7568% <ø> (-0.1133%) ⬇️
parser ∅ <ø> (∅)
br 63.1955% <ø> (+16.8782%) ⬆️
🚀 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.

@YangKeao YangKeao force-pushed the sem-61582 branch 4 times, most recently from 8fbc4ac to 3a73dc4 Compare June 11, 2025 03:56
@YangKeao YangKeao requested review from CbcWestwolf and bb7133 June 11, 2025 04:02
@YangKeao YangKeao force-pushed the sem-61582 branch 2 times, most recently from 4280a89 to efe243e Compare June 26, 2025 12:40
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 30, 2025
@YangKeao
Copy link
Member Author

YangKeao commented Jul 1, 2025

/retest

@YangKeao YangKeao force-pushed the sem-61582 branch 8 times, most recently from 8e64cdf to f6a93d9 Compare July 28, 2025 06:08
@YangKeao
Copy link
Member Author

YangKeao commented Aug 7, 2025

/retest

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

planner part LGTM

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, bb7133, CbcWestwolf, GMHDBJD, windtalker, yudongusa

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

The pull request process is described here

Details 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

@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

6 similar comments
@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

@YangKeao
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 259852d into pingcap:master Aug 18, 2025
28 checks passed
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. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement restricted_privileges Implement restricted_variables Implement restricted_databases and restricted_tables Add SEMv2 config and parser.

7 participants