Skip to content

Commit 28d0325

Browse files
authored
server: support getting the MVCC of the temporary index (#40830)
close #40826
1 parent 97e1563 commit 28d0325

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

server/http_handler.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (t *tikvHandlerTool) getHandle(tb table.PhysicalTable, params map[string]st
206206
return handle, nil
207207
}
208208

209-
func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values, idxCols []*model.ColumnInfo, handle kv.Handle) (*helper.MvccKV, error) {
209+
func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values, idxCols []*model.ColumnInfo, handle kv.Handle) ([]*helper.MvccKV, error) {
210210
sc := new(stmtctx.StatementContext)
211211
// HTTP request is not a database session, set timezone to UTC directly here.
212212
// See https://github.com/pingcap/tidb/blob/master/docs/tidb_http_api.md for more details.
@@ -227,7 +227,18 @@ func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values,
227227
if err != nil {
228228
return nil, err
229229
}
230-
return &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}, err
230+
idxData := &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}
231+
tablecodec.IndexKey2TempIndexKey(idx.Meta().ID, encodedKey)
232+
data, err = t.GetMvccByEncodedKey(encodedKey)
233+
if err != nil {
234+
return nil, err
235+
}
236+
regionID, err = t.getRegionIDByKey(encodedKey)
237+
if err != nil {
238+
return nil, err
239+
}
240+
tempIdxData := &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}
241+
return append([]*helper.MvccKV{}, idxData, tempIdxData), err
231242
}
232243

233244
// formValue2DatumRow converts URL query string to a Datum Row.

server/http_handler_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -539,16 +539,16 @@ partition by range (a)
539539

540540
func decodeKeyMvcc(closer io.ReadCloser, t *testing.T, valid bool) {
541541
decoder := json.NewDecoder(closer)
542-
var data helper.MvccKV
542+
var data []helper.MvccKV
543543
err := decoder.Decode(&data)
544544
require.NoError(t, err)
545545
if valid {
546-
require.NotNil(t, data.Value.Info)
547-
require.Greater(t, len(data.Value.Info.Writes), 0)
546+
require.NotNil(t, data[0].Value.Info)
547+
require.Greater(t, len(data[0].Value.Info.Writes), 0)
548548
} else {
549-
require.Nil(t, data.Value.Info.Lock)
550-
require.Nil(t, data.Value.Info.Writes)
551-
require.Nil(t, data.Value.Info.Values)
549+
require.Nil(t, data[0].Value.Info.Lock)
550+
require.Nil(t, data[0].Value.Info.Writes)
551+
require.Nil(t, data[0].Value.Info.Values)
552552
}
553553
}
554554

0 commit comments

Comments
 (0)