tidb
tidb copied to clipboard
expression,*: remove the session context inside `ParamMarker`
What problem does this PR solve?
Issue Number: close #53533
Problem Summary:
Previously, the code stores a reference to the session context in ParamMarker. It convenient for re-using the expression in the plan cache inside a single session. However, it blocks us from achieving the following goals:
- We cannot evaluate the expression whiling the params on session is changing. It will happen if we enabled lazy-cursor fetch.
- The plan cache cannot be re-used across different sessions, because the expression will always reference to the session on which it's cached.
This PR depends on #53922 now.
What changed and how does it work?
- Remove the session context inside
ParamMarker, and pass it through argument. - Add
EvalContextargument forGetTypeandGetUserVar. - Add a new method
StringWithCtxto stringify the expression with a given context.
It's also fine to use the StringWithCtx with nil argument directly, but it'll print ? for the params.
The biggest challenge is that the String is implicitly used in many places: like formatter and error / warnings. I wrote a linter to detect all the cases, you can find it in /build/linter/printexpression. It ensures that all struct/interface (and the reference/slice of them) which implements StringWithCtx but doesn't implement String cannot be used as an argument of format function.
Check List
Tests
- [x] 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.
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
None
Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all
Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all
Codecov Report
Attention: Patch coverage is 76.08696% with 88 lines in your changes missing coverage. Please review.
Project coverage is 56.0800%. Comparing base (
91bf332) to head (bbfa315). Report is 14 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #53534 +/- ##
=================================================
- Coverage 72.8313% 56.0800% -16.7514%
=================================================
Files 1530 1654 +124
Lines 435981 610615 +174634
=================================================
+ Hits 317531 342433 +24902
- Misses 98809 244809 +146000
- Partials 19641 23373 +3732
| Flag | Coverage Δ | |
|---|---|---|
| integration | 37.2379% <49.4565%> (?) |
|
| unit | 71.8274% <71.3483%> (+0.0040%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| dumpling | 52.9656% <ø> (ø) |
|
| parser | ∅ <ø> (∅) |
|
| br | 52.5143% <ø> (+6.3727%) |
:arrow_up: |
/retest
[LGTM Timeline notifier]
Timeline:
2024-06-06 06:10:49.939162458 +0000 UTC m=+13003.992474383: :ballot_box_with_check: agreed by qw4990.2024-06-11 07:42:09.227344304 +0000 UTC m=+450483.280656229: :ballot_box_with_check: agreed by lcwangchao.
/retest
/retest
/retest
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: lance6716, lcwangchao, qw4990, XuHuaiyu, zimulala
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [XuHuaiyu,lance6716,lcwangchao,qw4990,zimulala]
- ~~pkg/executor/importer/OWNERS~~ [lance6716]
- ~~pkg/expression/OWNERS~~ [XuHuaiyu]
- ~~pkg/planner/OWNERS~~ [qw4990]
- ~~pkg/table/OWNERS~~ [zimulala]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/retest
@YangKeao: 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_2 | bbfa315f2735564989449492a0afbc2aba5e8e13 | link | true | /test check-dev2 |
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/test-infra repository. I understand the commands that are listed here.