{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/47460177","id":47460177,"diff_hunk":"@@ -0,0 +1,161 @@\n+// Copyright 2015 PingCAP, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package inspectkv\n+\n+import (\n+\t\"testing\"\n+\n+\t. \"github.com/pingcap/check\"\n+\t\"github.com/pingcap/tidb/kv\"\n+\t\"github.com/pingcap/tidb/meta\"\n+\t\"github.com/pingcap/tidb/meta/autoid\"\n+\t\"github.com/pingcap/tidb/model\"\n+\t\"github.com/pingcap/tidb/mysql\"\n+\t\"github.com/pingcap/tidb/sessionctx/variable\"\n+\t\"github.com/pingcap/tidb/store/localstore\"\n+\t\"github.com/pingcap/tidb/store/localstore/goleveldb\"\n+\t\"github.com/pingcap/tidb/table/tables\"\n+\t\"github.com/pingcap/tidb/util/mock\"\n+\t\"github.com/pingcap/tidb/util/types\"\n+)\n+\n+func TestT(t *testing.T) {\n+\tTestingT(t)\n+}\n+\n+var _ = Suite(&testInspectSuite{})\n+\n+type testInspectSuite struct {\n+}\n+\n+func (s *testInspectSuite) TestInspect(c *C) {\n+\tdriver := localstore.Driver{Driver: goleveldb.MemoryDriver{}}\n+\tstore, err := driver.Open(\"memory:test_inspect\")\n+\tc.Assert(err, IsNil)\n+\tdefer store.Close()\n+\n+\ttxn, err := store.Begin()\n+\tc.Assert(err, IsNil)\n+\n+\tt := meta.NewMeta(txn)\n+\n+\tdbInfo := &model.DBInfo{\n+\t\tID:   1,\n+\t\tName: model.NewCIStr(\"a\"),\n+\t}\n+\terr = t.CreateDatabase(dbInfo)\n+\tc.Assert(err, IsNil)\n+\n+\tcol := &model.ColumnInfo{\n+\t\tName:         model.NewCIStr(\"c\"),\n+\t\tID:           0,\n+\t\tOffset:       0,\n+\t\tDefaultValue: 1,\n+\t\tState:        model.StatePublic,\n+\t\tFieldType:    *types.NewFieldType(mysql.TypeLong),\n+\t}\n+\tidx := &model.IndexInfo{\n+\t\tName:   model.NewCIStr(\"c\"),\n+\t\tID:     1,\n+\t\tUnique: true,\n+\t\tColumns: []*model.IndexColumn{{\n+\t\t\tName:   model.NewCIStr(\"c\"),\n+\t\t\tOffset: 0,\n+\t\t\tLength: 255,\n+\t\t}},\n+\t\tState: model.StatePublic,\n+\t}\n+\ttbInfo := &model.TableInfo{\n+\t\tID:      1,\n+\t\tName:    model.NewCIStr(\"t\"),\n+\t\tState:   model.StatePublic,\n+\t\tColumns: []*model.ColumnInfo{col},\n+\t\tIndices: []*model.IndexInfo{idx},\n+\t}\n+\terr = t.CreateTable(dbInfo.ID, tbInfo)\n+\tc.Assert(err, IsNil)\n+\n+\towner := &model.Owner{OwnerID: \"owner\"}\n+\terr = t.SetDDLOwner(owner)\n+\tc.Assert(err, IsNil)\n+\tdbInfo2 := &model.DBInfo{\n+\t\tID:    2,\n+\t\tName:  model.NewCIStr(\"b\"),\n+\t\tState: model.StateNone,\n+\t}\n+\tjob := &model.Job{\n+\t\tSchemaID: dbInfo2.ID,\n+\t\tType:     model.ActionCreateSchema,\n+\t}\n+\terr = t.EnQueueDDLJob(job)\n+\tc.Assert(err, IsNil)\n+\tinfo, err := GetDDLInfo(txn)\n+\tc.Assert(err, IsNil)\n+\tc.Assert(info.Owner, DeepEquals, owner)\n+\tc.Assert(info.Job, DeepEquals, job)\n+\tc.Assert(info.ReorgHandle, Equals, int64(0))\n+\ttxn.Commit()","path":"inspectkv/inspectkv_test.go","position":108,"original_position":108,"commit_id":"22bb76409bf168df26fc905dd64ef0b19c169558","original_commit_id":"e6c6b0e7d3cf842a987d207d5f06b89237990e33","user":{"login":"zimulala","id":4242506,"avatar_url":"https://avatars.githubusercontent.com/u/4242506?v=3","gravatar_id":"","url":"https://api.github.com/users/zimulala","html_url":"https://github.com/zimulala","followers_url":"https://api.github.com/users/zimulala/followers","following_url":"https://api.github.com/users/zimulala/following{/other_user}","gists_url":"https://api.github.com/users/zimulala/gists{/gist_id}","starred_url":"https://api.github.com/users/zimulala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zimulala/subscriptions","organizations_url":"https://api.github.com/users/zimulala/orgs","repos_url":"https://api.github.com/users/zimulala/repos","events_url":"https://api.github.com/users/zimulala/events{/privacy}","received_events_url":"https://api.github.com/users/zimulala/received_events","type":"User","site_admin":false},"body":"got it.","created_at":"2015-12-14T04:08:16Z","updated_at":"2015-12-14T04:08:16Z","html_url":"https://github.com/pingcap/tidb/pull/692#discussion_r47460177","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/692","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/47460177"},"html":{"href":"https://github.com/pingcap/tidb/pull/692#discussion_r47460177"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/692"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/692","id":53078636,"html_url":"https://github.com/pingcap/tidb/pull/692","diff_url":"https://github.com/pingcap/tidb/pull/692.diff","patch_url":"https://github.com/pingcap/tidb/pull/692.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/692","number":692,"state":"open","locked":false,"title":"*: Support inspect kv","user":{"login":"zimulala","id":4242506,"avatar_url":"https://avatars.githubusercontent.com/u/4242506?v=3","gravatar_id":"","url":"https://api.github.com/users/zimulala","html_url":"https://github.com/zimulala","followers_url":"https://api.github.com/users/zimulala/followers","following_url":"https://api.github.com/users/zimulala/following{/other_user}","gists_url":"https://api.github.com/users/zimulala/gists{/gist_id}","starred_url":"https://api.github.com/users/zimulala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zimulala/subscriptions","organizations_url":"https://api.github.com/users/zimulala/orgs","repos_url":"https://api.github.com/users/zimulala/repos","events_url":"https://api.github.com/users/zimulala/events{/privacy}","received_events_url":"https://api.github.com/users/zimulala/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-09T05:35:24Z","updated_at":"2015-12-14T04:08:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b74e6762cf7a6d89740f16fb2670b3521bfe896f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/692/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/692/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/692/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/22bb76409bf168df26fc905dd64ef0b19c169558","head":{"label":"pingcap:zimuxia/inspect-kv","ref":"zimuxia/inspect-kv","sha":"22bb76409bf168df26fc905dd64ef0b19c169558","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed SQL database compatible with MySQL protocol.","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","created_at":"2015-09-06T04:01:52Z","updated_at":"2015-12-14T03:39:52Z","pushed_at":"2015-12-14T03:38:36Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"","size":9496,"stargazers_count":3093,"watchers_count":3093,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":314,"mirror_url":null,"open_issues_count":66,"forks":314,"open_issues":66,"watchers":3093,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"683f8afa94e09bbbe9322955fa0841f487695787","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed SQL database compatible with MySQL protocol.","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","created_at":"2015-09-06T04:01:52Z","updated_at":"2015-12-14T03:39:52Z","pushed_at":"2015-12-14T03:38:36Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"","size":9496,"stargazers_count":3093,"watchers_count":3093,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":314,"mirror_url":null,"open_issues_count":66,"forks":314,"open_issues":66,"watchers":3093,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/692"},"html":{"href":"https://github.com/pingcap/tidb/pull/692"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/692"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/692/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/692/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/692/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/22bb76409bf168df26fc905dd64ef0b19c169558"}}}}