Skip to content

Commit

Permalink
types: fix update unsigned column with overflow string issue (#47817) (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 11, 2024
1 parent b32b212 commit aa25027
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 13 additions & 0 deletions pkg/executor/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,19 @@ func TestIssue23553(t *testing.T) {
tk.MustExec(`update tt a inner join (select m0 from tt where status!=1 group by m0 having count(*)>1) b on a.m0=b.m0 set a.status=1`)
}

// see issue https://github.com/pingcap/tidb/issues/47816
func TestUpdateUnsignedWithOverflow(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec(`use test`)
tk.MustExec("create table t1(id int, a int unsigned)")
tk.MustExec("set sql_mode=''")
tk.MustExec("insert into t1 values(1, 10), (2, 20)")
tk.MustExec("update t1 set a='-1' where id=1")
tk.MustExec("update t1 set a='1000000000000000000' where id=2")
tk.MustQuery("select id, a from t1 order by id asc").Check(testkit.Rows("1 0", "2 4294967295"))
}

func TestLockUnchangedUniqueKeys(t *testing.T) {
store := testkit.CreateMockStore(t)

Expand Down
3 changes: 0 additions & 3 deletions pkg/types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,9 +1197,6 @@ func (d *Datum) convertToUint(sc *stmtctx.StatementContext, target *FieldType) (
val, err = ConvertFloatToUint(sc, d.GetFloat64(), upperBound, tp)
case KindString, KindBytes:
uval, err1 := StrToUint(sc, d.GetString(), false)
if err1 != nil && ErrOverflow.Equal(err1) && !sc.ShouldIgnoreOverflowError() {
return ret, errors.Trace(err1)
}
val, err = ConvertUintToUint(uval, upperBound, tp)
if err == nil {
err = err1
Expand Down

0 comments on commit aa25027

Please sign in to comment.