-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner, bindinfo: support show bindings order by update_time #26139
Merged
Merged
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6d9c31b
show global bindings order by update_time
Reminiscent cc8202b
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent dface24
fix ut
Reminiscent 1f92ea8
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent f181d84
address comments
Reminiscent e25a6d6
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent d98baa7
Merge branch 'master' into issue#15702
eurekaka 02ba738
add more tests
Reminiscent d19d15d
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent 54cce49
Merge branch 'issue#15702' of https://github.com/Reminiscent/tidb int…
Reminiscent 0ef4f7a
use the stable sort
Reminiscent 897ffe7
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent 89b3956
Merge branch 'master' into issue#15702
ti-chi-bot b4c6af3
Merge branch 'master' into issue#15702
ti-chi-bot 3160baf
Merge branch 'master' into issue#15702
ti-chi-bot 74e543e
Merge branch 'master' into issue#15702
ti-chi-bot 67cb27b
Merge branch 'master' into issue#15702
ti-chi-bot 003c19f
Merge branch 'master' into issue#15702
ti-chi-bot 49a0cce
Merge branch 'master' of https://github.com/pingcap/tidb into issue#1…
Reminiscent 7c87488
Merge branch 'issue#15702' of https://github.com/Reminiscent/tidb int…
Reminiscent 7b25c17
fix ut
Reminiscent aff20d9
Merge branch 'master' into issue#15702
ti-chi-bot 075ae0e
Merge branch 'master' into issue#15702
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,7 +256,28 @@ func (e *ShowExec) fetchShowBind() error { | |
} else { | ||
bindRecords = domain.GetDomain(e.ctx).BindHandle().GetAllBindRecord() | ||
} | ||
// Remove the invalid bindRecord. | ||
ind := 0 | ||
for _, bindData := range bindRecords { | ||
if len(bindData.Bindings) > 0 { | ||
bindRecords[ind] = bindData | ||
ind++ | ||
} | ||
} | ||
bindRecords = bindRecords[:ind] | ||
parser := parser.New() | ||
for _, bindData := range bindRecords { | ||
// For the same origin_sql, sort the bindings according to their update time. | ||
sort.Slice(bindData.Bindings, func(i int, j int) bool { | ||
cmpResult := bindData.Bindings[i].UpdateTime.Compare(bindData.Bindings[j].UpdateTime) | ||
return cmpResult > 0 | ||
}) | ||
} | ||
// For the different origin_sql, sort the bindRecords according to their max update time. | ||
sort.Slice(bindRecords, func(i int, j int) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use stable sort instead? |
||
cmpResult := bindRecords[i].Bindings[0].UpdateTime.Compare(bindRecords[j].Bindings[0].UpdateTime) | ||
return cmpResult > 0 | ||
}) | ||
for _, bindData := range bindRecords { | ||
for _, hint := range bindData.Bindings { | ||
stmt, err := parser.ParseOneStmt(hint.BindSQL, hint.Charset, hint.Collation) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the session binding is deleted,
len(bindData.Bindings)
maybe 0.