-
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, cmd: fix ColumnSubstitute and allow some cases to substitute #38826
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1841e8b
init
wjhuang2016 33215d4
clen
wjhuang2016 db51040
Merge branch 'master' into ox_coll_substitute
AilinKid 5c80ad7
add explain
wjhuang2016 dce94b0
Merge branch 'ox_coll_substitute' of github.com:wjhuang2016/tidb into…
wjhuang2016 2b04bdb
done
wjhuang2016 24450ce
Merge branch 'master' into ox_coll_substitute
wjhuang2016 2df07ee
Merge branch 'master' into ox_coll_substitute
wjhuang2016 d4aaac1
fix
wjhuang2016 a53fff7
fix
wjhuang2016 6884ed4
done
wjhuang2016 28f15f3
fix
wjhuang2016 c81372c
fix test
wjhuang2016 5482443
Update expression/util.go
wjhuang2016 674b0e8
Update planner/core/exhaust_physical_plans.go
wjhuang2016 369c980
refine
wjhuang2016 7b757b6
Merge branch 'master' into ox_coll_substitute
AilinKid 74913d0
Merge branch 'master' into ox_coll_substitute
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
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
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
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 |
---|---|---|
|
@@ -415,7 +415,6 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression | |
if v.InOperand { | ||
newExpr = SetExprColumnInOperand(newExpr) | ||
} | ||
newExpr.SetCoercibility(v.Coercibility()) | ||
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. why remove this, rest is ok for me 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. It may not be substituted in L424. If keep it, a test in constant propagation will fail. |
||
return true, false, newExpr | ||
case *ScalarFunction: | ||
substituted := false | ||
|
@@ -438,7 +437,11 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression | |
// cowExprRef is a copy-on-write util, args array allocation happens only | ||
// when expr in args is changed | ||
refExprArr := cowExprRef{v.GetArgs(), nil} | ||
_, coll := DeriveCollationFromExprs(v.GetCtx(), v.GetArgs()...) | ||
oldCollEt, err := CheckAndDeriveCollationFromExprs(v.GetCtx(), v.FuncName.L, v.RetType.EvalType(), v.GetArgs()...) | ||
if err != nil { | ||
logutil.BgLogger().Error("Unexpected error happened during ColumnSubstitution", zap.Stack("stack")) | ||
return false, false, v | ||
} | ||
var tmpArgForCollCheck []Expression | ||
if collate.NewCollationEnabled() { | ||
tmpArgForCollCheck = make([]Expression, len(v.GetArgs())) | ||
|
@@ -454,9 +457,18 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression | |
changed = false | ||
copy(tmpArgForCollCheck, refExprArr.Result()) | ||
tmpArgForCollCheck[idx] = newFuncExpr | ||
_, newColl := DeriveCollationFromExprs(v.GetCtx(), tmpArgForCollCheck...) | ||
if coll == newColl { | ||
changed = checkCollationStrictness(coll, newFuncExpr.GetType().GetCollate()) | ||
newCollEt, err := CheckAndDeriveCollationFromExprs(v.GetCtx(), v.FuncName.L, v.RetType.EvalType(), tmpArgForCollCheck...) | ||
if err != nil { | ||
logutil.BgLogger().Error("Unexpected error happened during ColumnSubstitution", zap.Stack("stack")) | ||
return false, failed, v | ||
} | ||
if oldCollEt.Collation == newCollEt.Collation { | ||
if newFuncExpr.GetType().GetCollate() == arg.GetType().GetCollate() && newFuncExpr.Coercibility() == arg.Coercibility() { | ||
// It's safe to use the new expression, otherwise some cases in projection push-down will be wrong. | ||
changed = true | ||
} else { | ||
changed = checkCollationStrictness(oldCollEt.Collation, newFuncExpr.GetType().GetCollate()) | ||
} | ||
} | ||
} | ||
hasFail = hasFail || failed || oldChanged != changed | ||
|
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
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.
The change is correct the NOT IN's key name not in('guo') is put in other cond. And the inner filter
exam.stu_id = stu.id
is put at the join key.