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
*: support check an index #5932
Changes from 6 commits
3e94985
c8b299b
0aed863
9277961
b5d86fc
4909e48
db04731
dcb7d65
041665f
7971727
6e2f519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,6 +409,70 @@ func (e *CheckTableExec) run(ctx context.Context) error { | |
return nil | ||
} | ||
|
||
// CheckIndexExec represents the executor of check an index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check -> checking |
||
// It is built from the "admin check index" statement, and it checks if the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it checks the consistency of the index data with the records of the table. |
||
// index matches the records in the table. | ||
type CheckIndexExec struct { | ||
baseExecutor | ||
|
||
dbName string | ||
tableName string | ||
idxName string | ||
src Executor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/Executor/*IndexLookUpExecutor/ is more readable ? |
||
done bool | ||
is infoschema.InfoSchema | ||
} | ||
|
||
// Open implements the Executor Open interface. | ||
func (e *CheckIndexExec) Open(ctx context.Context) error { | ||
if err := e.baseExecutor.Open(ctx); err != nil { | ||
return errors.Trace(err) | ||
} | ||
if err := e.src.Open(ctx); err != nil { | ||
return errors.Trace(err) | ||
} | ||
e.done = false | ||
return nil | ||
} | ||
|
||
// Next implements the Executor Next interface. | ||
func (e *CheckIndexExec) Next(ctx context.Context) (Row, error) { | ||
if e.done { | ||
return nil, nil | ||
} | ||
err := e.run(ctx) | ||
e.done = true | ||
return nil, errors.Trace(err) | ||
} | ||
|
||
// NextChunk implements the Executor NextChunk interface. | ||
func (e *CheckIndexExec) NextChunk(ctx context.Context, chk *chunk.Chunk) error { | ||
if e.done { | ||
return nil | ||
} | ||
err := e.run(ctx) | ||
e.done = true | ||
return errors.Trace(err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just call |
||
} | ||
|
||
func (e *CheckIndexExec) run(ctx context.Context) error { | ||
err := admin.CheckIndicesCount(e.ctx, e.dbName, e.tableName, []string{e.idxName}) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
|
||
for { | ||
row, err := e.src.Next(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
if row == nil { | ||
break | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// SelectLockExec represents a select lock executor. | ||
// It is built from the "SELECT .. FOR UPDATE" or the "SELECT .. LOCK IN SHARE MODE" statement. | ||
// For "SELECT .. FOR UPDATE" statement, it locks every row key from source Executor. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,6 +403,7 @@ func (s *testParserSuite) TestDMLStmt(c *C) { | |
{"admin show ddl;", true}, | ||
{"admin show ddl jobs;", true}, | ||
{"admin check table t1, t2;", true}, | ||
{"admin check index idx;", true}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the |
||
{"admin cancel ddl jobs 1", true}, | ||
{"admin cancel ddl jobs 1, 2", true}, | ||
|
||
|
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 the missing handle and corresponding index value in the error message.