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

expression: fix unexpected error msg for cast string to decimal #47267

Merged
merged 3 commits into from
Sep 27, 2023

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Sep 25, 2023

What problem does this PR solve?

Issue Number: close #44274

Problem Summary: When you use ErrTruncated, you should use it like here. Otherwise the err msg will got %s %d

For cast, should use ErrTruncatedWrongVal, just like mysql.

MySQL [test]> select CAST('61QW' AS DECIMAL);
+-------------------------+
| CAST('61QW' AS DECIMAL) |
+-------------------------+
|                      61 |
+-------------------------+
1 row in set, 1 warning (0.000 sec)

MySQL [test]> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect DECIMAL value: '61QW' |
+---------+------+-------------------------------------------+
1 row in set (0.001 sec)

What is changed and how it works?

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

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 25, 2023
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #47267 (2db9112) into master (dd70123) will decrease coverage by 0.2221%.
Report is 28 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #47267        +/-   ##
================================================
- Coverage   72.9209%   72.6988%   -0.2221%     
================================================
  Files          1340       1369        +29     
  Lines        400295     407419      +7124     
================================================
+ Hits         291899     296189      +4290     
- Misses        89463      92411      +2948     
+ Partials      18933      18819       -114     
Flag Coverage Δ
integration 36.5160% <100.0000%> (?)
unit 72.5647% <100.0000%> (-0.3563%) ⬇️

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

Components Coverage Δ
dumpling 53.9913% <ø> (ø)
parser 84.8729% <ø> (-0.0611%) ⬇️
br 48.7037% <ø> (-4.3715%) ⬇️

@@ -2059,3 +2059,15 @@ func TestIssue41986(t *testing.T) {
// shouldn't report they can't find column error and return the right result.
tk.MustQuery("SELECT GROUP_CONCAT(effective_date order by stlmnt_hour DESC) FROM ( SELECT (COALESCE(pct.clearing_time, 0)/3600000) AS stlmnt_hour ,COALESCE(pct.effective_date, '1970-01-01 08:00:00') AS effective_date FROM poi_clearing_time_topic pct ORDER BY pct.effective_date DESC ) a;").Check(testkit.Rows("2023-08-25 00:00:00"))
}

func TestCastErrMsg(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better move it to tests/integrationtest. It will have better performance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 27, 2023
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 27, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 27, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-27 03:18:15.366352013 +0000 UTC m=+417685.084694216: ☑️ agreed by Defined2014.
  • 2023-09-27 03:27:13.641861436 +0000 UTC m=+418223.360203654: ☑️ agreed by XuHuaiyu.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed do-not-merge/needs-triage-completed labels Sep 27, 2023
@ti-chi-bot ti-chi-bot bot merged commit 99d9d41 into pingcap:master Sep 27, 2023
13 of 16 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #47314.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 27, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #47315.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 27, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #47317.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 27, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR 1265 (01000): Data truncated for column '%s' at row %d
4 participants