diff --git a/ddl/column_type_change_test.go b/ddl/column_type_change_test.go index 71fa1da9ee927..c68f87c9a7dde 100644 --- a/ddl/column_type_change_test.go +++ b/ddl/column_type_change_test.go @@ -661,7 +661,7 @@ func TestColumnTypeChangeFromStringToOthers(t *testing.T) { // MySQL will get "ERROR 1366 (HY000): Incorrect DECIMAL value: '0' for column '' at row -1" error. tk.MustExec("insert into t(vc) values ('abc')") - tk.MustGetErrCode("alter table t modify vc decimal(5,3)", errno.ErrBadNumber) + tk.MustGetErrCode("alter table t modify vc decimal(5,3)", errno.ErrTruncatedWrongValue) } func TestColumnTypeChangeFromNumericToOthers(t *testing.T) { @@ -1298,7 +1298,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\" ")) diff --git a/types/convert_test.go b/types/convert_test.go index 53ec0c93b1e55..88a60171ed3ad 100644 --- a/types/convert_test.go +++ b/types/convert_test.go @@ -251,7 +251,7 @@ func TestConvertType(t *testing.T) { // Test Datum.ToDecimal with bad number. d := NewDatum("hello") _, err = d.ToDecimal(sc) - require.Truef(t, terror.ErrorEqual(err, ErrBadNumber), "err %v", err) + require.Truef(t, terror.ErrorEqual(err, ErrTruncatedWrongVal), "err %v", err) sc.IgnoreTruncate = true v, err = d.ToDecimal(sc) diff --git a/types/mydecimal.go b/types/mydecimal.go index c2229462dc8ae..0e2ca156a8bc4 100644 --- a/types/mydecimal.go +++ b/types/mydecimal.go @@ -403,7 +403,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 '-': @@ -431,7 +431,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)