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

Error message for DECIMAL overflow is just "ERROR 1690 (22003): %s value is out of range in '%s'" #27964

Closed
kennytm opened this issue Sep 11, 2021 · 4 comments · Fixed by #28338
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. component/expression fixes-5.3.0 This bug is fixed at 5.3.0 severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@kennytm
Copy link
Contributor

kennytm commented Sep 11, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

select cast(9e40 as decimal(65)) * cast(9e40 as decimal(65));

2. What did you expect to see? (Required)

ERROR 1690 (22003): DECIMAL value is out of range in '(cast(9e40 as decimal(65,0)) * cast(9e40 as decimal(65,0)))'

3. What did you see instead (Required)

ERROR 1690 (22003): %s value is out of range in '%s'

4. What is your TiDB version? (Required)

Both master and v5.1.1.

Release Version: v5.3.0-alpha-77-g5fb3cd42f
Edition: Community
Git Commit Hash: 5fb3cd42f7ab7460adb2b3196c62bd6c7a903823
Git Branch: master
UTC Build Time: 2021-09-11 09:24:20
GoVersion: go1.17
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@kennytm kennytm added type/bug The issue is confirmed as a bug. component/expression sig/execution SIG execution severity/minor affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. labels Sep 11, 2021
@unconsolable
Copy link
Contributor

I tried to fill the error args as follows in (*builtinArithmeticMultiplyDecimalSig).vecEvalDecimal

if terror.ErrorEqual(err, types.ErrOverflow) {
	return types.ErrOverflow.GenWithStackByArgs("DECIMAL", fmt.Sprintf("(%s * %s)", b.args[0].String(), b.args[1].String()))
}

But the error is still not the same as expected

ERROR 1690 (22003): DECIMAL value is out of range in '(90000000000000000000000000000000000000000 * 90000000000000000000000000000000000000000)'

But I found that for BIGINT UNSIGNED the error is incompatible with MySQL either.

tidb> select cast(9e40 as unsigned) * cast(9e40 as unsigned);
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(18446744073709551615 * 18446744073709551615)'
mysql> select cast(9e40 as unsigned) * cast(9e40 as unsigned);
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(cast(9e40 as unsigned) * cast(9e40 as unsigned))'

@kennytm
Copy link
Contributor Author

kennytm commented Sep 25, 2021

i think it is fine as long as the error doesn't literally say %s.

@kennytm
Copy link
Contributor Author

kennytm commented Sep 25, 2021

Note that this error affects more than *. All arithmetic operators should be checked.

examples:

set @a = cast(9e40 as decimal(65)) * cast(9e39 as decimal(65));

select @a + @a;
-- EXPECTED: ERROR 1690 (22003): DECIMAL value is out of range in '((@`a`) + (@`a`))'
-- ACTUAL:   ERROR 1690 (22003): %s value is out of range in '%s'
select @a - (-@a);
-- EXPECTED: ERROR 1690 (22003): DECIMAL value is out of range in '((@`a`) - -((@`a`)))'
-- ACTUAL:   ERROR 1690 (22003): %s value is out of range in '%s'
select @a / 0.1;
-- EXPECTED: ERROR 1690 (22003): DECIMAL value is out of range in '((@`a`) / 0.1)'
-- ACTUAL:   ERROR 1690 (22003): %s value is out of range in '%s'

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. component/expression fixes-5.3.0 This bug is fixed at 5.3.0 severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants