@ -278,8 +278,9 @@ func (c *index) Exist(rm kv.RetrieverMutator, indexedValues []types.Datum, h int
|
||||
func (c *index) FetchValues(r []types.Datum) ([]types.Datum, error) {
|
||||
vals := make([]types.Datum, len(c.idxInfo.Columns))
|
||||
for i, ic := range c.idxInfo.Columns {
|
||||
if ic.Offset < 0 || ic.Offset > len(r) {
|
||||
return nil, table.ErrIndexOutBound.Gen("Index column offset out of bound")
|
||||
if ic.Offset < 0 || ic.Offset >= len(r) {
|
||||
return nil, table.ErrIndexOutBound.Gen("Index column %s offset out of bound, offset: %d, row: %v",
|
||||
ic.Name, ic.Offset, r)
|
||||
}
|
||||
vals[i] = r[ic.Offset]
|
||||
}
|
||||
|
||||
@ -169,6 +169,9 @@ func (s *testIndexSuite) TestIndex(c *C) {
|
||||
|
||||
err = txn.Commit()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err = index.FetchValues(make([]types.Datum, 0))
|
||||
c.Assert(err, NotNil)
|
||||
}
|
||||
|
||||
func (s *testIndexSuite) TestCombineIndexSeek(c *C) {
|
||||
|
||||
@ -418,7 +418,10 @@ func (t *Table) addIndices(ctx context.Context, recordID int64, r []types.Datum,
|
||||
// if index is in delete only or delete reorganization state, we can't add it.
|
||||
continue
|
||||
}
|
||||
colVals, _ := v.FetchValues(r)
|
||||
colVals, err2 := v.FetchValues(r)
|
||||
if err2 != nil {
|
||||
return 0, errors.Trace(err2)
|
||||
}
|
||||
var dupKeyErr error
|
||||
if v.Meta().Unique || v.Meta().Primary {
|
||||
entryKey, err1 := t.genIndexKeyStr(colVals)
|
||||
|
||||
Reference in New Issue
Block a user