-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 http index mvcc interface #5304
Conversation
/run-all-tests |
server/region_handler.go
Outdated
return kvResp.MvccGetByKey, nil | ||
} | ||
|
||
func (t *regionHandlerTool) formValue2DatumRow(values url.Values, idxCols []*model.ColumnInfo) ([]types.Datum, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment for the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler_test.go
Outdated
@@ -32,6 +32,7 @@ import ( | |||
"github.com/pingcap/tidb/store/tikv/mocktikv" | |||
"github.com/pingcap/tidb/tablecodec" | |||
"github.com/pingcap/tidb/util/codec" | |||
"io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this before "github.com/xxxxx".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler.go
Outdated
@@ -592,8 +608,38 @@ func (rh mvccTxnHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | |||
} | |||
} | |||
|
|||
func (rh mvccTxnHandler) handleMvccGetByIdx(params map[string]string, values url.Values) (interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
server/region_handler.go
Outdated
} | ||
|
||
val := vals[0] | ||
if len(val) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference between NULL
and empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler.go
Outdated
func (t *regionHandlerTool) formValue2DatumRow(values url.Values, idxCols []*model.ColumnInfo) ([]types.Datum, error) { | ||
data := make([]types.Datum, len(idxCols)) | ||
for i, col := range idxCols { | ||
var d types.Datum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use data[i] directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
keyLocation, err := t.regionCache.LocateKey(t.bo, encodeKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated with L676-L693
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler_test.go
Outdated
@@ -282,6 +300,46 @@ func (ts *TidbRegionHandlerTestSuite) TestGetMvcc(c *C) { | |||
err = decoder.Decode(&data2) | |||
c.Assert(err, IsNil) | |||
c.Assert(data2, DeepEquals, data) | |||
|
|||
// tests for normal index key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we define an independent function to test index key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
c.Assert(err, IsNil) | ||
decodeKeyMvcc(resp.Body, c, true) | ||
|
||
// tests for index key which includes null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests for index key that contains an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/run-all-tests |
PTAL @shenli and @AndreMouche . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
server/region_handler.go
Outdated
data[i].SetMysqlJSON(elem) | ||
default: | ||
return nil, errors.NotSupportedf("Not supported datum type %d.", col.Tp) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the function of ConvertTo
instead of line908-987?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/region_handler.go
Outdated
func (t *regionHandlerTool) getMvccByIdxValue(idx table.Index, values url.Values, idxCols []*model.ColumnInfo, handleStr string) (*kvrpcpb.MvccGetByKeyResponse, error) { | ||
idxRow, err := t.formValue2DatumRow(values, idxCols) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add the error trace? Some places have not added in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error traces for the whole file.
server/region_handler.go
Outdated
key, err1 = url.QueryUnescape(key) | ||
if err1 != nil { | ||
if err == nil { | ||
err = err1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we return err here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I just follow the style of url package. Fixed.
server/region_handler.go
Outdated
value, err1 = url.QueryUnescape(value) | ||
if err1 != nil { | ||
if err == nil { | ||
err = err1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
LGTM |
/run-all-tests |
@AndreMouche PTAL