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: Correct the type inference between erroneous string and time | tidb-test=pr/2357 #54252

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jun 26, 2024

What problem does this PR solve?

Issue Number: close #53857

Problem Summary:

What changed and how does it work?

This PR has fixed three bugs.

the first bug:

the problem is that when the strings types 10:10:10.00transfers to the duration, it will lose the decimal. because it loses the decimal, it will get the wrong value when its duration type value transfers to the string.

the second bug:

the problem is with the duration type transfer to the strings. it should set the flen as -1. otherwise, the result is wrong because the string is truncated.

the third bug:

when var_char's flen is set as -1, but in the planner explain, it is shown as var_char(5).

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 do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2024
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.0219%. Comparing base (4381699) to head (60a8194).
Report is 12 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54252         +/-   ##
=================================================
- Coverage   72.8121%   56.0219%   -16.7902%     
=================================================
  Files          1526       1646        +120     
  Lines        435911     607319     +171408     
=================================================
+ Hits         317396     340232      +22836     
- Misses        98873     243777     +144904     
- Partials      19642      23310       +3668     
Flag Coverage Δ
integration 37.2036% <90.9090%> (?)
unit 71.8173% <100.0000%> (+0.0177%) ⬆️

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.7422% <ø> (+6.6274%) ⬆️

@hawkingrei hawkingrei marked this pull request as draft June 27, 2024 00:06
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 27, 2024
@hawkingrei hawkingrei marked this pull request as ready for review June 27, 2024 15:15
@ti-chi-bot ti-chi-bot bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-triage-completed labels Jun 27, 2024
@hawkingrei hawkingrei force-pushed the fix53857 branch 2 times, most recently from 9bb567a to c765f5d Compare June 28, 2024 01:03
@hawkingrei hawkingrei changed the title planner: incorrect result using CTE and subquery planner: incorrect result using CTE and subquery | tidb-test=pr/2357 Jun 29, 2024
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

@hawkingrei hawkingrei requested a review from XuHuaiyu June 29, 2024 08:17
@hawkingrei
Copy link
Member Author

/retest

2 similar comments
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

@hawkingrei hawkingrei changed the title planner: incorrect result using CTE and subquery | tidb-test=pr/2357 types: Correct the type inference between erroneous string and time | tidb-test=pr/2357 Jun 29, 2024
@hawkingrei hawkingrei force-pushed the fix53857 branch 2 times, most recently from 22c163a to 32f4e30 Compare June 30, 2024 03:29
@@ -2258,9 +2258,10 @@ func WrapWithCastAsString(ctx BuildContext, expr Expression) Expression {
}

// Because we can't control the length of cast(float as char) for now, we can't determine the argLen.
if exprTp.GetType() == mysql.TypeFloat || exprTp.GetType() == mysql.TypeDouble {
if exprTp.GetType() == mysql.TypeFloat || exprTp.GetType() == mysql.TypeDouble || exprTp.GetType() == mysql.TypeDuration {
Copy link
Member Author

Choose a reason for hiding this comment

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

Duration -> string, flen should be set as -1.

Copy link
Contributor

@yibin87 yibin87 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 Jul 1, 2024
Comment on lines 2332 to 2333
tp.SetDecimal(types.GetFsp(expr.String()))
tp.SetFlen(types.UnspecifiedLength)
Copy link
Member Author

Choose a reason for hiding this comment

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

Duration -> stirng should set right Flen and Decimal.

@hawkingrei hawkingrei requested a review from tangenta July 1, 2024 03:09
Copy link

ti-chi-bot bot commented Jul 1, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tangenta, yibin87
Once this PR has been reviewed and has the lgtm label, please ask for approval from hawkingrei and additionally assign windtalker for approval(Please ensuring that each of them provides their approval before proceeding). For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 1, 2024
Copy link

ti-chi-bot bot commented Jul 1, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-01 02:08:41.462678488 +0000 UTC m=+1203847.948167319: ☑️ agreed by yibin87.
  • 2024-07-01 04:09:13.466270915 +0000 UTC m=+1211079.951759747: ☑️ agreed by tangenta.

*
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
*
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
*
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Copy link

tiprow bot commented Jul 3, 2024

@hawkingrei: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow cbf82b1 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Jul 3, 2024

@hawkingrei: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test cbf82b1 link true /test unit-test
idc-jenkins-ci-tidb/check_dev_2 cbf82b1 link true /test check-dev2
idc-jenkins-ci-tidb/build cbf82b1 link true /test build
pull-integration-ddl-test cbf82b1 link true /test pull-integration-ddl-test
pull-mysql-client-test cbf82b1 link true /test pull-mysql-client-test
idc-jenkins-ci-tidb/mysql-test cbf82b1 link true /test mysql-test
idc-jenkins-ci-tidb/check_dev cbf82b1 link true /test check-dev

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 2, 2024
Copy link

ti-chi-bot bot commented Aug 2, 2024

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

incorrect result using CTE and subquery
3 participants