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: BuildContext read location from EvalContext instead of SessionVars #52451

Merged
merged 1 commit into from Apr 11, 2024

Conversation

lcwangchao
Copy link
Collaborator

What problem does this PR solve?

Issue Number: ref #52366

Problem Summary:

Some codes are using BuildContext.GetSessionVars().Location() to read the time zone info. Because we are going to remove GetSessionVars in the future, it's better to replace it with BuildContext.Location().

We should notice that SessionVars.Location() reads the timezone info from another place that is different from BuildContext.Location(). When replacing it, we should ensure they are same to avoid to introduce new bugs.

What changed and how does it work?

  • replaced BuildContext.GetSessionVars().Location() with BuildContext.Location() .
  • To make sure the logic is the same after the PR, we add some asserts to check the timezone info in sessionVars and statement context is the same.
  • Modify some tests to make sure the asserts can pass.

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 sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 9, 2024
Copy link

tiprow bot commented Apr 9, 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/test-infra repository.

@@ -72,6 +72,7 @@ func (sg *Pool) Get() (sessionctx.Context, error) {
}
ctx.GetSessionVars().SetStatusFlag(mysql.ServerStatusAutocommit, true)
ctx.GetSessionVars().InRestrictedSQL = true
ctx.GetSessionVars().StmtCtx.SetTimeZone(ctx.GetSessionVars().Location())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To make sure the timezone info are the same in session and statement context. PTAL @tangenta

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

tc := ctx.TypeCtx()
tcLoc := tc.Location().String()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We moved most asserts to SessionEvalContext. So we only need to check the Expression.Location() and EvalContext.TypeCtx().Locaion() are the same

Copy link

codecov bot commented Apr 9, 2024

Codecov Report

Merging #52451 (e37338a) into master (fab13af) will increase coverage by 2.7584%.
Report is 16 commits behind head on master.
The diff coverage is 96.5517%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52451        +/-   ##
================================================
+ Coverage   72.1286%   74.8870%   +2.7584%     
================================================
  Files          1467       1493        +26     
  Lines        426911     442103     +15192     
================================================
+ Hits         307925     331078     +23153     
+ Misses        99739      90578      -9161     
- Partials      19247      20447      +1200     
Flag Coverage Δ
integration 50.8957% <96.5517%> (?)
unit 71.4836% <93.1034%> (+0.4809%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.1030% <ø> (+10.0078%) ⬆️

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Apr 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/test-infra repository.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Apr 10, 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/test-infra repository.

@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Apr 10, 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/test-infra repository.

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 Apr 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-10 03:47:33.488435954 +0000 UTC m=+1020515.015976500: ☑️ agreed by tangenta.
  • 2024-04-10 08:13:50.966972597 +0000 UTC m=+1036492.494513142: ☑️ agreed by YangKeao.

Copy link

ti-chi-bot bot commented Apr 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, tangenta, XuHuaiyu, YangKeao

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 Apr 11, 2024
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit da0de56 into pingcap:master Apr 11, 2024
24 checks passed
@lcwangchao lcwangchao deleted the build_ctx_loc branch April 11, 2024 08:32
3AceShowHand pushed a commit to 3AceShowHand/tidb that referenced this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants