Skip to content

Commit

Permalink
fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta committed Mar 15, 2021
1 parent cb0846c commit 45de1c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4851,9 +4851,9 @@ func (s *testSplitTable) TestClusterIndexSplitTableIntegration(c *C) {
tk.MustGetErrMsg("split table t between ('aaa', 0.0) and (100.0, 'aaa') regions 10;", errMsg)

// lower bound >= upper bound.
errMsg = "Split table `t` region lower value (aaa,0) should less than the upper value (aaa,0)"
errMsg = "[executor:8212]Failed to split region ranges: Split table `t` region lower value (aaa,0) should less than the upper value (aaa,0)"
tk.MustGetErrMsg("split table t between ('aaa', 0.0) and ('aaa', 0.0) regions 10;", errMsg)
errMsg = "Split table `t` region lower value (bbb,0) should less than the upper value (aaa,0)"
errMsg = "[executor:8212]Failed to split region ranges: Split table `t` region lower value (bbb,0) should less than the upper value (aaa,0)"
tk.MustGetErrMsg("split table t between ('bbb', 0.0) and ('aaa', 0.0) regions 10;", errMsg)

// Exceed limit 1000.
Expand Down
24 changes: 7 additions & 17 deletions executor/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,8 @@ func (e *SplitIndexRegionExec) getSplitIdxPhysicalKeysFromBound(physicalID int64
}

if bytes.Compare(lowerIdxKey, upperIdxKey) >= 0 {
lowerStr, err1 := datumSliceToString(e.lower)
upperStr, err2 := datumSliceToString(e.upper)
if err1 != nil || err2 != nil {
errMsg := fmt.Sprintf("Split index `%v` region lower value %v should less than the upper value %v",
e.indexInfo.Name, e.lower, e.upper)
return nil, ErrInvalidSplitRegionRanges.GenWithStackByArgs(errMsg)
}
lowerStr := datumSliceToString(e.lower)
upperStr := datumSliceToString(e.upper)
errMsg := fmt.Sprintf("Split index `%v` region lower value %v should less than the upper value %v",
e.indexInfo.Name, lowerStr, upperStr)
return nil, ErrInvalidSplitRegionRanges.GenWithStackByArgs(errMsg)
Expand Down Expand Up @@ -307,20 +302,20 @@ func getUint64FromBytes(bs []byte, pad byte) uint64 {
return binary.BigEndian.Uint64(buf)
}

func datumSliceToString(ds []types.Datum) (string, error) {
func datumSliceToString(ds []types.Datum) string {
str := "("
for i, d := range ds {
s, err := d.ToString()
if err != nil {
return str, err
return fmt.Sprintf("%v", ds)
}
if i > 0 {
str += ","
}
str += s
}
str += ")"
return str, nil
return str
}

// SplitTableRegionExec represents a split table regions executor.
Expand Down Expand Up @@ -602,13 +597,8 @@ func (e *SplitTableRegionExec) getSplitTablePhysicalKeysFromBound(physicalID int
return nil, err
}
if lowerHandle.Compare(upperHandle) >= 0 {
lowerStr, err1 := datumSliceToString(e.lower)
upperStr, err2 := datumSliceToString(e.upper)
if err1 != nil || err2 != nil {
errMsg := fmt.Sprintf("Split table `%v` region lower value %v should less than the upper value %v",
e.tableInfo.Name.O, e.lower, e.upper)
return nil, ErrInvalidSplitRegionRanges.GenWithStackByArgs(errMsg)
}
lowerStr := datumSliceToString(e.lower)
upperStr := datumSliceToString(e.upper)
errMsg := fmt.Sprintf("Split table `%v` region lower value %v should less than the upper value %v",
e.tableInfo.Name.O, lowerStr, upperStr)
return nil, ErrInvalidSplitRegionRanges.GenWithStackByArgs(errMsg)
Expand Down

0 comments on commit 45de1c3

Please sign in to comment.