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: Add GetUserVarsReader to EvalContext #55866

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

lcwangchao
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #55865

What changed and how does it work?

This PR adds new method GetUserVarsReader to EvalContext so that the user vars can be read directly from the context. It has some benefits:

  1. BuildSimpleExpr can now build expressions like @a+1 without adding optional property SessionVars to the inner context.
  2. We can evaluate an expression like @a+1 or get_var("a") without requiring an additional property SessionVars in EvalContext.
  3. Lazy cursor fetch can now support SQL with user vars.

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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/planner SIG: Planner labels Sep 5, 2024
Copy link

tiprow bot commented Sep 5, 2024

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

@@ -2391,15 +2431,6 @@ func (s *SessionVars) SetStringUserVar(name string, strVal string, collation str
}
}

// UnsetUserVar unset an user defined variable by name.
func (s *SessionVars) UnsetUserVar(varName string) {
Copy link
Collaborator Author

@lcwangchao lcwangchao Sep 5, 2024

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 90.54054% with 7 lines in your changes missing coverage. Please review.

Project coverage is 57.4250%. Comparing base (91aabea) to head (5bf3266).
Report is 28 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55866         +/-   ##
=================================================
- Coverage   72.8505%   57.4250%   -15.4255%     
=================================================
  Files          1598       1754        +156     
  Lines        444454     637621     +193167     
=================================================
+ Hits         323787     366154      +42367     
- Misses       100737     246545     +145808     
- Partials      19930      24922       +4992     
Flag Coverage Δ
integration 40.0030% <55.4054%> (?)
unit 72.5313% <90.5405%> (+0.5607%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 63.0712% <ø> (+17.2979%) ⬆️

Copy link
Member

@YangKeao YangKeao 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

ti-chi-bot bot commented Sep 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-06 08:41:43.05586402 +0000 UTC m=+172.796287957: ☑️ agreed by YangKeao.
  • 2024-09-09 04:02:25.407604359 +0000 UTC m=+242615.148028297: ☑️ agreed by XuHuaiyu.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Sep 9, 2024

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

In response to this:

/retest

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

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

LGTM for the variable

Copy link

ti-chi-bot bot commented Sep 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qw4990, XuHuaiyu, YangKeao, yudongusa

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 the approved label Sep 9, 2024
@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Sep 9, 2024

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

In response to this:

/retest

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 merged commit 7d75f23 into pingcap:master Sep 9, 2024
21 of 23 checks passed
@lcwangchao lcwangchao deleted the evalctxuservarreader branch September 9, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GetUserVarsReader to EvalContext
5 participants