-
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, executor: fix tp.Flen size when union with castIntAsString #8442
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
@AndrewDi Thanks! Please fix the CI. |
@shenli it seems like ci server can not download image.
|
/run-all-tests |
@AndrewDi I have rerun ci and env is ok. But it failed. PTAL |
planner/core/logical_plan_builder.go
Outdated
@@ -659,6 +659,9 @@ func unionJoinFieldType(a, b *types.FieldType) *types.FieldType { | |||
resultTp.Decimal = mathutil.Max(a.Decimal, b.Decimal) | |||
// `Flen - Decimal` is the fraction before '.' | |||
resultTp.Flen = mathutil.Max(a.Flen-a.Decimal, b.Flen-b.Decimal) + resultTp.Decimal | |||
if (a.EvalType() == types.ETInt || b.EvalType() == types.ETInt) && resultTp.Flen < mysql.MaxIntWidth { |
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 resultTp is also EvalInt, the truncation would not happen. (Check TestIndexRangeElimininatedProjection
)
We may need to check
resultTp.EvalType() != types.ETInt && (a.EvalType() == types.ETInt || b.EvalType() == types.ETInt) && resultTp.Flen < mysql.MaxIntWidth
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.
Good, check more strict.
89b815d
to
bf1bd1c
Compare
That's wired, I just update branch, and CI check successful. |
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.
LGTM
@XuHuaiyu PTAL |
/run-all-tests |
/run-common-test |
executor/executor_test.go
Outdated
tk.MustExec("drop table if exists t1") | ||
tk.MustExec("CREATE TABLE t1 (uid int(1))") | ||
tk.MustExec("INSERT INTO t1 SELECT 150") | ||
tk.MustQuery("SELECT 'a' UNION SELECT uid FROM t1;").Check(testkit.Rows("a", "150")) |
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.
add order by
for union,
since unionExec is executed parallelly.
8966283
to
3051695
Compare
/run-common-test |
/run-common-test |
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.
LGTM
@AndrewDi Could you cherry-pick this commit to the release-2.1 and release-2.0 branch? |
What problem does this PR solve?
fix #8231, fix tp.Flen size when union with castIntAsString
What is changed and how it works?
When execute
func unionJoinFieldType(a, b *types.FieldType) *types.FieldType
, if any union type is int and result.Flen is less than mysql.MaxIntWidth then setresultTp.Flen = mysql.MaxIntWidth
Check List
Tests
This change is