Skip to content

Commit

Permalink
table: tiny clean up and add logs (pingcap#5186)
Browse files Browse the repository at this point in the history
* table: tiny clean up and add logs
  • Loading branch information
zimulala authored Nov 22, 2017
1 parent 9e524cb commit ee7b085
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,10 @@ func (t *Table) UpdateRecord(ctx context.Context, h int64, oldData, newData []ty
for _, col := range t.WritableCols() {
var value types.Datum
if col.State != model.StatePublic {
// If col is in write only or write reorganization state
// and the value is not default, keep the original value.
value, err = table.GetColOriginDefaultValue(ctx, col.ToInfo())
if err != nil {
return errors.Trace(err)
}
cmp, errCmp := oldData[col.Offset].CompareDatum(ctx.GetSessionVars().StmtCtx, &value)
if errCmp != nil {
return errors.Trace(errCmp)
}
if cmp != 0 {
value = oldData[col.Offset]
}
// If col is in write only or write reorganization state we should keep the oldData.
// Because the oldData must be the orignal data(it's changed by other TiDBs.) or the orignal default value.
// TODO: Use newData directly.
value = oldData[col.Offset]
} else {
value = newData[col.Offset]
}
Expand Down Expand Up @@ -582,14 +573,15 @@ func (t *Table) removeRowData(ctx context.Context, h int64) error {
func (t *Table) removeRowIndices(ctx context.Context, h int64, rec []types.Datum) error {
for _, v := range t.DeletableIndices() {
vals, err := v.FetchValues(rec)
if vals == nil {
// TODO: check this
continue
if err != nil {
log.Infof("remove row index %v failed %v, txn %d, handle %d, data %v", v.Meta(), err, ctx.Txn().StartTS, h, rec)
return errors.Trace(err)
}
if err = v.Delete(ctx.Txn(), vals, h); err != nil {
if v.Meta().State != model.StatePublic && kv.ErrNotExist.Equal(err) {
// If the index is not in public state, we may have not created the index,
// or already deleted the index, so skip ErrNotExist error.
log.Debugf("remove row index %v doesn't exist, txn %d, handle %d", v.Meta(), ctx.Txn().StartTS, h)
continue
}
return errors.Trace(err)
Expand Down

0 comments on commit ee7b085

Please sign in to comment.