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

executor: fix test on dev branch #31556

Merged
merged 2 commits into from
Jan 11, 2022
Merged
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
25 changes: 12 additions & 13 deletions executor/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/domain"
mysql "github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/planner/core"
Expand Down Expand Up @@ -221,7 +220,7 @@ func TestAdminRecoverIndex(t *testing.T) {
// Make some corrupted index.
ctx := mock.NewContext()
ctx.Store = store
is := d.InfoSchema()
is := domain.InfoSchema()
dbName := model.NewCIStr("test")
tblName := model.NewCIStr("admin_test")
tbl, err := is.TableByName(dbName, tblName)
Expand Down Expand Up @@ -1541,12 +1540,12 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.NoError(t, err)
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8003]admin_test err:[admin:8223]index:<nil> != record:&admin.RecordData{Handle:-1, Values:[]types.Datum{types.Datum{k:0x1, decimal:0x0, length:0x0, i:-10, collation:\"\", b:[]uint8(nil), x:interface {}(nil)}}}")
require.True(t, executor.ErrAdminCheckTable.Equal(err))
require.EqualError(t, err, "[admin:8223]data inconsistency in table: admin_test, index: c2, handle: -1, index-values:\"\" != record-values:\"handle: -1, values: [KindInt64 -10]\"")
require.True(t, consistency.ErrAdminCheckInconsistent.Equal(err))
tk.MustExec("set @@tidb_redact_log=1;")
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8003]admin_test err:[admin:8223]index:\"?\" != record:\"?\"")
require.EqualError(t, err, "[admin:8223]data inconsistency in table: admin_test, index: c2, handle: ?, index-values:\"?\" != record-values:\"?\"")
tk.MustExec("set @@tidb_redact_log=0;")
r := tk.MustQuery("admin recover index admin_test c2")
r.Check(testkit.Rows("1 7"))
Expand All @@ -1563,11 +1562,11 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.NoError(t, err)
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8133]handle 0, index:types.Datum{k:0x1, decimal:0x0, length:0x0, i:0, collation:\"\", b:[]uint8(nil), x:interface {}(nil)} != record:<nil>")
require.EqualError(t, err, "[admin:8223]data inconsistency in table: admin_test, index: c2, handle: 0, index-values:\"handle: 0, values: [KindInt64 0 KindInt64 0]\" != record-values:\"\"")
tk.MustExec("set @@tidb_redact_log=1;")
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8133]handle \"?\", index:\"?\" != record:\"?\"")
require.EqualError(t, err, "[admin:8223]data inconsistency in table: admin_test, index: c2, handle: ?, index-values:\"?\" != record-values:\"?\"")
tk.MustExec("set @@tidb_redact_log=0;")

// Add one row of index.
Expand All @@ -1586,11 +1585,11 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.NoError(t, err)
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle 2, index:types.Datum{k:0x1, decimal:0x0, length:0x0, i:13, collation:\"\", b:[]uint8(nil), x:interface {}(nil)} != record:types.Datum{k:0x1, decimal:0x0, length:0x0, i:12, collation:\"\", b:[]uint8(nil), x:interface {}(nil)}, compare err:<nil>")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"2\", index-values:\"KindInt64 13\" != record-values:\"KindInt64 12\", compare err:<nil>")
tk.MustExec("set @@tidb_redact_log=1;")
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle \"?\", index:\"?\" != record:\"?\", compare err:\"?\"")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"?\", index-values:\"?\" != record-values:\"?\", compare err:\"?\"")
tk.MustExec("set @@tidb_redact_log=0;")

// Table count = index count.
Expand All @@ -1605,11 +1604,11 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.NoError(t, err)
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle 10, index:types.Datum{k:0x1, decimal:0x0, length:0x0, i:19, collation:\"\", b:[]uint8(nil), x:interface {}(nil)} != record:types.Datum{k:0x1, decimal:0x0, length:0x0, i:20, collation:\"\", b:[]uint8(nil), x:interface {}(nil)}, compare err:<nil>")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"10\", index-values:\"KindInt64 19\" != record-values:\"KindInt64 20\", compare err:<nil>")
tk.MustExec("set @@tidb_redact_log=1;")
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle \"?\", index:\"?\" != record:\"?\", compare err:\"?\"")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"?\", index-values:\"?\" != record-values:\"?\", compare err:\"?\"")
tk.MustExec("set @@tidb_redact_log=0;")

// Table count = index count.
Expand All @@ -1624,11 +1623,11 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.NoError(t, err)
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle 10, index:types.Datum{k:0x1, decimal:0x0, length:0x0, i:19, collation:\"\", b:[]uint8(nil), x:interface {}(nil)} != record:types.Datum{k:0x1, decimal:0x0, length:0x0, i:20, collation:\"\", b:[]uint8(nil), x:interface {}(nil)}, compare err:<nil>")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"10\", index-values:\"KindInt64 19\" != record-values:\"KindInt64 20\", compare err:<nil>")
tk.MustExec("set @@tidb_redact_log=1;")
err = tk.ExecToErr("admin check table admin_test")
require.Error(t, err)
require.EqualError(t, err, "[executor:8134]col c2, handle \"?\", index:\"?\" != record:\"?\", compare err:\"?\"")
require.EqualError(t, err, "[executor:8134]data inconsistency in table: admin_test, index: c2, col: c2, handle: \"?\", index-values:\"?\" != record-values:\"?\", compare err:\"?\"")
tk.MustExec("set @@tidb_redact_log=0;")

// Recover records.
Expand Down