Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: label more expressions as thread-safe and add more test cases #57171

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Nov 6, 2024

What problem does this PR solve?

Issue Number: ref #54057

Problem Summary: expression: label more expressions as thread-safe and add more test cases

What changed and how does it work?

expression: label more expressions as thread-safe and add more test cases

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.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 6, 2024
Copy link

tiprow bot commented Nov 6, 2024

Hi @qw4990. 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.

for k := 0; k < 100; k++ {
vs := []string{"1", "2"}
if rand.Intn(2) < 1 { // is true
tk.MustExec("prepare st from 'select a from t where (a-?) is true'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can use expression.ParseSimpleExpr and use expr.Eval to do evaluation. It is more lightweight to save some performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but it seems it's unnecessary to save the performance here, and using SQL makes this test case more clear and easy-to-maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just got your point. I'll use your suggestion to implement a lightweight test framework in my next PR and use it to test all builtin funcs.

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.3249%. Comparing base (6004c3e) to head (5f058cf).
Report is 12 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #57171         +/-   ##
=================================================
- Coverage   73.0078%   56.3249%   -16.6830%     
=================================================
  Files          1657       1783        +126     
  Lines        457652     637590     +179938     
=================================================
+ Hits         334122     359122      +25000     
- Misses       103015     254298     +151283     
- Partials      20515      24170       +3655     
Flag Coverage Δ
integration 37.0696% <0.0000%> (?)
unit 72.3921% <91.6666%> (+0.1033%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 52.3081% <ø> (+6.5889%) ⬆️

store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`set global tidb_enable_instance_plan_cache=1`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to reset this var in defer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion but this seems unnecessary since we're using Bazel and it runs each package seperately, and all test cases in this package "instanceplancache" would set "tidb_enable_instance_plan_cache=1".

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 6, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 6, 2024
Copy link

ti-chi-bot bot commented Nov 6, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-06 08:33:10.251459975 +0000 UTC m=+1029903.090615513: ☑️ agreed by lcwangchao.
  • 2024-11-06 08:34:30.892434495 +0000 UTC m=+1029983.731590026: ☑️ agreed by time-and-fate.

@ti-chi-bot ti-chi-bot bot added the approved label Nov 6, 2024
Copy link

ti-chi-bot bot commented Nov 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lcwangchao, time-and-fate, XuHuaiyu

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

@qw4990
Copy link
Contributor Author

qw4990 commented Nov 6, 2024

/test check-dev2

Copy link

tiprow bot commented Nov 6, 2024

@qw4990: 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.

@qw4990
Copy link
Contributor Author

qw4990 commented Nov 6, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Nov 6, 2024
@ti-chi-bot ti-chi-bot bot merged commit 7ef4f02 into pingcap:master Nov 6, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. 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.

4 participants