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

Merged
merged 5 commits into from Nov 27, 2018

Conversation

Projects
None yet
6 participants
@AndrewDi
Contributor

AndrewDi commented Nov 25, 2018

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 set resultTp.Flen = mysql.MaxIntWidth

Check List

Tests

  • Unit test

This change is Reviewable

@sre-bot

This comment has been minimized.

sre-bot commented Nov 25, 2018

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.

@shenli

This comment has been minimized.

Member

shenli commented Nov 25, 2018

@AndrewDi Thanks! Please fix the CI.

@AndrewDi

This comment has been minimized.

Contributor

AndrewDi commented Nov 25, 2018

@shenli it seems like ci server can not download image.

Build-agent version 0.1.1073-1f69f340 (2018-11-20T18:07:03+0000)
Starting container golang:1.11
  image cache not found on this host, downloading golang:1.11

Error response from daemon: error parsing HTTP 404 response body: invalid character 'p' after top-level value: "404 page not found\n"
@zhouqiang-cl

This comment has been minimized.

Member

zhouqiang-cl commented Nov 25, 2018

/run-all-tests

@zhouqiang-cl

This comment has been minimized.

Member

zhouqiang-cl commented Nov 25, 2018

@AndrewDi I have rerun ci and env is ok. But it failed. PTAL

@XuHuaiyu XuHuaiyu changed the title from Planner: fix tp.Flen size when union with castIntAsString to planner, executor: fix tp.Flen size when union with castIntAsString Nov 26, 2018

@@ -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 {

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Nov 26, 2018

Contributor

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

This comment has been minimized.

@AndrewDi

AndrewDi Nov 26, 2018

Contributor

Good, check more strict.

@AndrewDi AndrewDi force-pushed the AndrewDi:fix_union_issue_8231 branch from 89b815d to bf1bd1c Nov 26, 2018

@AndrewDi

This comment has been minimized.

Contributor

AndrewDi commented Nov 26, 2018

@AndrewDi I have rerun ci and env is ok. But it failed. PTAL

That's wired, I just update branch, and CI check successful.

@zz-jason

This comment has been minimized.

Member

zz-jason commented Nov 26, 2018

@XuHuaiyu PTAL

@XuHuaiyu

This comment has been minimized.

Contributor

XuHuaiyu commented Nov 26, 2018

/run-all-tests

@XuHuaiyu

This comment has been minimized.

Contributor

XuHuaiyu commented Nov 26, 2018

/run-common-test
/run-integration-common-test
/run-sqllogic-test

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"))

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Nov 26, 2018

Contributor

add order by for union,
since unionExec is executed parallelly.

@AndrewDi AndrewDi force-pushed the AndrewDi:fix_union_issue_8231 branch from 8966283 to 3051695 Nov 27, 2018

@XuHuaiyu

This comment has been minimized.

Contributor

XuHuaiyu commented Nov 27, 2018

/run-common-test
/run-integration-common-test
/run-sqllogic-test

@XuHuaiyu

This comment has been minimized.

Contributor

XuHuaiyu commented Nov 27, 2018

/run-common-test
/run-integration-common-test

@XuHuaiyu

LGTM

@XuHuaiyu XuHuaiyu added status/LGT2 and removed status/LGT1 labels Nov 27, 2018

@zz-jason zz-jason merged commit 487bb50 into pingcap:master Nov 27, 2018

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@zz-jason

This comment has been minimized.

Member

zz-jason commented Nov 27, 2018

@AndrewDi Could you cherry-pick this commit to the release-2.1 and release-2.0 branch?

zz-jason added a commit to AndrewDi/tidb that referenced this pull request Nov 28, 2018

ngaut added a commit to AndrewDi/tidb that referenced this pull request Nov 28, 2018

zz-jason added a commit to AndrewDi/tidb that referenced this pull request Nov 28, 2018

zz-jason added a commit to AndrewDi/tidb that referenced this pull request Nov 28, 2018

@AndrewDi AndrewDi deleted the AndrewDi:fix_union_issue_8231 branch Dec 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment