Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: support getting the MVCC of the temporary index #40830

Merged
merged 4 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions server/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (t *tikvHandlerTool) getHandle(tb table.PhysicalTable, params map[string]st
return handle, nil
}

func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values, idxCols []*model.ColumnInfo, handle kv.Handle) (*helper.MvccKV, error) {
func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values, idxCols []*model.ColumnInfo, handle kv.Handle) ([]*helper.MvccKV, error) {
sc := new(stmtctx.StatementContext)
// HTTP request is not a database session, set timezone to UTC directly here.
// See https://github.com/pingcap/tidb/blob/master/docs/tidb_http_api.md for more details.
Expand All @@ -227,7 +227,18 @@ func (t *tikvHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values,
if err != nil {
return nil, err
}
return &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}, err
idxData := &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}
tablecodec.IndexKey2TempIndexKey(idx.Meta().ID, encodedKey)
data, err = t.GetMvccByEncodedKey(encodedKey)
tangenta marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
regionID, err = t.getRegionIDByKey(encodedKey)
if err != nil {
return nil, err
}
tempIdxData := &helper.MvccKV{Key: strings.ToUpper(hex.EncodeToString(encodedKey)), RegionID: regionID, Value: data}
return append([]*helper.MvccKV{}, idxData, tempIdxData), err
}

// formValue2DatumRow converts URL query string to a Datum Row.
Expand Down
12 changes: 6 additions & 6 deletions server/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,16 @@ partition by range (a)

func decodeKeyMvcc(closer io.ReadCloser, t *testing.T, valid bool) {
decoder := json.NewDecoder(closer)
var data helper.MvccKV
var data []helper.MvccKV
err := decoder.Decode(&data)
require.NoError(t, err)
if valid {
require.NotNil(t, data.Value.Info)
require.Greater(t, len(data.Value.Info.Writes), 0)
require.NotNil(t, data[0].Value.Info)
require.Greater(t, len(data[0].Value.Info.Writes), 0)
} else {
require.Nil(t, data.Value.Info.Lock)
require.Nil(t, data.Value.Info.Writes)
require.Nil(t, data.Value.Info.Values)
require.Nil(t, data[0].Value.Info.Lock)
require.Nil(t, data[0].Value.Info.Writes)
require.Nil(t, data[0].Value.Info.Values)
}
}

Expand Down