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

types: remove param explicitTz from types.ParseTime #48574

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Nov 14, 2023

What problem does this PR solve?

Issue Number: close #48573

Problem Summary:

In #41146 a input parameter explicitTz was introduced to function types.ParseTime to avoid data race. Now after some refactoring works after 47355, we use types.Context which is immutable to replace stmtctx.StatementContext. So it is still thread-safe after we remove explicitTz.

What is changed and how it works?

Remove param explicitTz from types.ParseTime to keep a clear semantic for function types.ParseTime .

We also remove explicitTz in Time.check and now Time.check and Time.Check are all same. Then just remove Time.check to use Time.Check only

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 14, 2023
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

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 14, 2023
@lcwangchao lcwangchao force-pushed the parse_time_remove_exp_tz branch from 713a9d3 to d1487ab Compare November 14, 2023 03:24
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Merging #48574 (79212ca) into master (1c8d383) will increase coverage by 1.3901%.
Report is 2 commits behind head on master.
The diff coverage is 90.9090%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48574        +/-   ##
================================================
+ Coverage   71.4240%   72.8142%   +1.3901%     
================================================
  Files          1404       1428        +24     
  Lines        407213     413827      +6614     
================================================
+ Hits         290848     301325     +10477     
+ Misses        96412      93536      -2876     
+ Partials      19953      18966       -987     
Flag Coverage Δ
integration 43.3058% <64.8148%> (?)
unit 71.4251% <88.8888%> (+0.0010%) ⬆️

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

Components Coverage Δ
dumpling 53.9874% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7938% <0.0000%> (-4.2918%) ⬇️

@lcwangchao lcwangchao force-pushed the parse_time_remove_exp_tz branch from d1487ab to bfc4792 Compare November 14, 2023 05:13
@lcwangchao
Copy link
Collaborator Author

/retest

2 similar comments
@lcwangchao
Copy link
Collaborator Author

/retest

@YangKeao
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 15, 2023
Copy link

ti-chi-bot bot commented Nov 15, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-14 03:21:52.864890449 +0000 UTC m=+4132910.452000596: ☑️ agreed by YangKeao.
  • 2023-11-15 06:15:58.109682529 +0000 UTC m=+4229755.696792672: ☑️ agreed by wjhuang2016.

@YangKeao YangKeao requested a review from XuHuaiyu November 15, 2023 06:27
@@ -89,8 +89,11 @@ func getTimeCurrentTimeStamp(ctx sessionctx.Context, tp byte, fsp int) (t types.
// GetTimeValue gets the time value with type tp.
func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, explicitTz *time.Location) (d types.Datum, err error) {
var value types.Time
tc := ctx.GetSessionVars().StmtCtx.TypeCtx()
if explicitTz != nil {
tc = tc.WithLocation(explicitTz)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tc.WithLocation(explicitTz) will create a new context with old one not modified. So there is no data race any more

t1, err = tmp.GoTime(ctx.Location())
}
if err != nil {
if t1, err = tmp.GoTime(ctx.Location()); err != nil {
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 only need to care about ctx.Location() here after explicitTz removed

} else {
t1 = t1.In(ctx.Location())
}
t1 = t1.In(ctx.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.

We only need to care about ctx.Location() here after explicitTz removed

Copy link

ti-chi-bot bot commented Nov 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, wjhuang2016, 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 Nov 15, 2023
@ti-chi-bot ti-chi-bot bot merged commit db2e239 into pingcap:master Nov 15, 2023
13 of 16 checks passed
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove param explicitTz from types.ParseTime
5 participants