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

http: add http api for get db and table info that is related to the tableID #8256

Merged
merged 4 commits into from
Nov 22, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test
  • Loading branch information
crazycs520 committed Nov 13, 2018

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit bb45bde8b2a07b79294f959b74b56965d65f79ea
6 changes: 3 additions & 3 deletions server/http_handler.go
Original file line number Diff line number Diff line change
@@ -1368,8 +1368,8 @@ func (h allServerInfoHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
writeData(w, clusterInfo)
}

// DBTableInfo is use ro report the db, table info and the current schema version.
type DBTableInfo struct {
// dbTableInfo is used to report the db, table info and the current schema version.
type dbTableInfo struct {
DBInfo *model.DBInfo `json:"db_info"`
TableInfo *model.TableInfo `json:"table_info"`
SchemaVersion int64 `json:"schema_version"`
@@ -1391,7 +1391,7 @@ func (h dbTableHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}

dbTblInfo := DBTableInfo{
dbTblInfo := dbTableInfo{
SchemaVersion: schema.SchemaMetaVersion(),
}
tbl, ok := schema.TableByID(int64(tblID))
12 changes: 12 additions & 0 deletions server/http_handler_test.go
Original file line number Diff line number Diff line change
@@ -570,6 +570,18 @@ func (ts *HTTPHandlerTestSuite) TestGetSchema(c *C) {

_, err = http.Get(fmt.Sprintf("http://127.0.0.1:10090/schema/tidb/abc"))
c.Assert(err, IsNil)

resp, err = http.Get(fmt.Sprintf("http://127.0.0.1:10090/db-table/5"))
c.Assert(err, IsNil)
var dbtbl *dbTableInfo
decoder = json.NewDecoder(resp.Body)
err = decoder.Decode(&dbtbl)
c.Assert(err, IsNil)
c.Assert(dbtbl.TableInfo.Name.L, Equals, "user")
c.Assert(dbtbl.DBInfo.Name.L, Equals, "mysql")
se, err := session.CreateSession(ts.store.(kv.Storage))
c.Assert(err, IsNil)
c.Assert(dbtbl.SchemaVersion, Equals, domain.GetDomain(se.(sessionctx.Context)).InfoSchema().SchemaMetaVersion())
}

func (ts *HTTPHandlerTestSuite) TestAllHistory(c *C) {