-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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, planner: make the Value
field of the Constant
struct private | tidb-test=pr/2355
#54244
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
034f277
to
f9244e7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54244 +/- ##
=================================================
- Coverage 74.7940% 50.8441% -23.9499%
=================================================
Files 1523 1643 +120
Lines 361510 608416 +246906
=================================================
+ Hits 270388 309344 +38956
- Misses 71504 275391 +203887
- Partials 19618 23681 +4063
Flags with carried forward coverage won't be shown. Click here to find out more.
|
f9244e7
to
d556b83
Compare
Value
field of the Constant
struct privateValue
field of the Constant
struct private | tidb-test=pr/2355
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
d556b83
to
2b15a89
Compare
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
2b15a89
to
8a1cd57
Compare
[FORMAT CHECKER NOTIFICATION] Notice: To remove the For example:
📖 For more info, you can check the "Contribute Code" section in the development guide. |
@YangKeao: The following test failed, say
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. |
@YangKeao: The following tests failed, say
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. |
PR needs rebase. 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. |
What problem does this PR solve?
Issue Number: close #53504
Problem Summary:
Using
.Value
directly can easily cause wrong result and dangerous bug, especially for plan cache. We have found #53504 #53505 (and potentially many others). It's not possible to depend on test cases to avoid making mistakes in the future. Therefore, I propose to make.Value
private.What changed and how does it work?
However, it's not simple to make
.Value
private, because:Constant
is always constructed directly, likeConstant{Value:..., ...}
. If we avoid using.Value
directly, all these codes need to be changed.expression
pkg is too big, and we also need to ensure the codes inexpression
pkg cannot access the.Value
. However, golang allows the codes in the same package to access the private field.Therefore, I wrote a linter to filter out all selector expression to get the
.Value
.It's also hard to keep the correctness. I've considered the following three situations:
.Value
field, and I'm sure it's not a parameter and deferred function..Value
field. If the current context is not in plan cache, evaluating parameter and deferred function is also fine.For most of the codes in optimizing stage, it should call 2. For the code in executing stage, it usually should call 3. We provide
GetValue()
,GetValueWithoutOverOptimization()
, and.Eval
for these three circumstances.Check List
Tests
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.