Skip to content

Commit

Permalink
fix bad error message for numeric conversion issue#32744
Browse files Browse the repository at this point in the history
Signed-off-by: fanrenhoo <[email protected]>
  • Loading branch information
fanrenhoo committed Apr 17, 2022
1 parent 345b1a8 commit d261d88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ddl/column_type_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ func TestColumnTypeChangeFromJsonToOthers(t *testing.T) {
tk.MustExec("alter table t modify ui decimal(20, 10)")
tk.MustExec("alter table t modify f64 decimal(20, 10)")
// MySQL will get "ERROR 1366 (HY000): Incorrect DECIMAL value: '0' for column '' at row -1".
tk.MustGetErrCode("alter table t modify str decimal(20, 10)", errno.ErrBadNumber)
tk.MustGetErrCode("alter table t modify str decimal(20, 10)", errno.ErrTruncatedWrongValue)
tk.MustExec("alter table t modify nul decimal(20, 10)")
tk.MustQuery("select * from t").Check(testkit.Rows("{\"obj\": 100} [-1, 0, 1] null 1.0000000000 0.0000000000 -22.0000000000 22.0000000000 323232323.3232323500 \"json string\" <nil>"))

Expand Down
4 changes: 2 additions & 2 deletions types/mydecimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (d *MyDecimal) FromString(str []byte) error {
}
if len(str) == 0 {
*d = zeroMyDecimal
return ErrBadNumber
return ErrTruncatedWrongVal.GenWithStackByArgs("DECIMAL", str)
}
switch str[0] {
case '-':
Expand Down Expand Up @@ -430,7 +430,7 @@ func (d *MyDecimal) FromString(str []byte) error {
}
if digitsInt+digitsFrac == 0 {
*d = zeroMyDecimal
return ErrBadNumber
return ErrTruncatedWrongVal.GenWithStackByArgs("DECIMAL", str)
}
wordsInt := digitsToWords(digitsInt)
wordsFrac := digitsToWords(digitsFrac)
Expand Down

0 comments on commit d261d88

Please sign in to comment.