func lockRow(txn kv.Transaction, t table.Table, h int64) error { // Get row lock key lockKey := t.RecordKey(h, nil) // set row lock key to current txn err := txn.Set(lockKey, []byte(txn.String())) return errors.Trace(err) }
func setRow(txn kv.Transaction, handle int64, tbl *simpleTableInfo, gen genValueFunc) error { rowKey := tablecodec.EncodeRowKey(tbl.tID, codec.EncodeInt(nil, handle)) txn.Set(rowKey, []byte(txn.String())) columnValues := gen(handle, tbl) for i, v := range columnValues { cKey, cVal, err := encodeColumnKV(tbl.tID, handle, tbl.cIDs[i], v) if err != nil { return errors.Trace(err) } err = txn.Set(cKey, cVal) if err != nil { return errors.Trace(err) } } for i, idxCol := range tbl.indices { idxVal := columnValues[idxCol] encoded, err := codec.EncodeKey(nil, idxVal, types.NewDatum(handle)) if err != nil { return errors.Trace(err) } idxKey := tablecodec.EncodeIndexSeekKey(tbl.tID, tbl.iIDs[i], encoded) err = txn.Set(idxKey, []byte{0}) if err != nil { return errors.Trace(err) } } return nil }