Skip to content

Commit

Permalink
add IGNORE_INDEX hint (pingcap#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
foreyes authored and lzmhhh123 committed Sep 12, 2019
1 parent f76bd9a commit 47e54b3
Show file tree
Hide file tree
Showing 5 changed files with 7,085 additions and 7,041 deletions.
2 changes: 1 addition & 1 deletion ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ func (n *TableOptimizerHint) Restore(ctx *RestoreCtx) error {
}
table.Restore(ctx)
}
case "index", "use_index_merge":
case "use_index", "ignore_index", "use_index_merge":
n.Tables[0].Restore(ctx)
ctx.WritePlain(" ")
for i, index := range n.Indexes {
Expand Down
9 changes: 6 additions & 3 deletions ast/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ func (ts *testMiscSuite) TestUserSpec(c *C) {

func (ts *testMiscSuite) TestTableOptimizerHintRestore(c *C) {
testCases := []NodeRestoreTestCase{
{"INDEX(t1 c1)", "INDEX(`t1` `c1`)"},
{"INDEX(@sel_1 t1 c1)", "INDEX(@`sel_1` `t1` `c1`)"},
{"INDEX(t1@sel_1 c1)", "INDEX(`t1`@`sel_1` `c1`)"},
{"USE_INDEX(t1 c1)", "USE_INDEX(`t1` `c1`)"},
{"USE_INDEX(@sel_1 t1 c1)", "USE_INDEX(@`sel_1` `t1` `c1`)"},
{"USE_INDEX(t1@sel_1 c1)", "USE_INDEX(`t1`@`sel_1` `c1`)"},
{"IGNORE_INDEX(t1 c1)", "IGNORE_INDEX(`t1` `c1`)"},
{"IGNORE_INDEX(@sel_1 t1 c1)", "IGNORE_INDEX(@`sel_1` `t1` `c1`)"},
{"IGNORE_INDEX(t1@sel_1 c1)", "IGNORE_INDEX(`t1`@`sel_1` `c1`)"},
{"TIDB_SMJ(`t1`)", "TIDB_SMJ(`t1`)"},
{"TIDB_SMJ(t1)", "TIDB_SMJ(`t1`)"},
{"TIDB_SMJ(t1,t2)", "TIDB_SMJ(`t1`, `t2`)"},
Expand Down
4 changes: 3 additions & 1 deletion misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ var tokenMap = map[string]int{
"IDENTIFIED": identified,
"IF": ifKwd,
"IGNORE": ignore,
"IGNORE_INDEX": hintIgnoreIndex,
"IMPORT": importKwd,
"IN": in,
"INCREMENTAL": incremental,
Expand Down Expand Up @@ -341,7 +342,6 @@ var tokenMap = map[string]int{
"IS": is,
"ISSUER": issuer,
"ISOLATION": isolation,
"USE_TOJA": hintUseToja,
"JOBS": jobs,
"JOB": job,
"JOIN": join,
Expand Down Expand Up @@ -623,8 +623,10 @@ var tokenMap = map[string]int{
"UPDATE": update,
"USAGE": usage,
"USE": use,
"USE_INDEX": hintUseIndex,
"USE_INDEX_MERGE": hintUseIndexMerge,
"USE_PLAN_CACHE": hintUsePlanCache,
"USE_TOJA": hintUseToja,
"USER": user,
"USING": using,
"UTC_DATE": utcDate,
Expand Down
Loading

0 comments on commit 47e54b3

Please sign in to comment.