[parser] parser: improve index merge hint (#590)
* add primary * add test for primary
This commit is contained in:
6114
parser/parser.go
6114
parser/parser.go
File diff suppressed because it is too large
Load Diff
@ -6571,6 +6571,10 @@ IndexNameList:
|
||||
{
|
||||
$$ = []model.CIStr{model.NewCIStr($1)}
|
||||
}
|
||||
| IndexNameList ',' "PRIMARY"
|
||||
{
|
||||
$$ = append($1.([]model.CIStr), model.NewCIStr($3))
|
||||
}
|
||||
|
||||
IndexHintList:
|
||||
IndexHint
|
||||
|
||||
@ -3010,12 +3010,12 @@ func (s *testParserSuite) TestOptimizerHints(c *C) {
|
||||
}
|
||||
|
||||
// Test USE_INDEX_MERGE
|
||||
stmt, _, err = parser.Parse("select /*+ USE_INDEX_MERGE(t1, c1), use_index_merge(t2, c1) */ c1, c2 from t1, t2 where t1.c1 = t2.c1", "", "")
|
||||
stmt, _, err = parser.Parse("select /*+ USE_INDEX_MERGE(t1, c1), use_index_merge(t2, c1), use_index_merge(t3, c1, primary, c2) */ c1, c2 from t1, t2, t3 where t1.c1 = t2.c1 and t3.c2 = t1.c2", "", "")
|
||||
c.Assert(err, IsNil)
|
||||
selectStmt = stmt[0].(*ast.SelectStmt)
|
||||
|
||||
hints = selectStmt.TableHints
|
||||
c.Assert(hints, HasLen, 2)
|
||||
c.Assert(hints, HasLen, 3)
|
||||
c.Assert(hints[0].HintName.L, Equals, "use_index_merge")
|
||||
c.Assert(hints[0].Tables, HasLen, 1)
|
||||
c.Assert(hints[0].Tables[0].TableName.L, Equals, "t1")
|
||||
@ -3028,6 +3028,14 @@ func (s *testParserSuite) TestOptimizerHints(c *C) {
|
||||
c.Assert(hints[1].Indexes, HasLen, 1)
|
||||
c.Assert(hints[1].Indexes[0].L, Equals, "c1")
|
||||
|
||||
c.Assert(hints[2].HintName.L, Equals, "use_index_merge")
|
||||
c.Assert(hints[2].Tables, HasLen, 1)
|
||||
c.Assert(hints[2].Tables[0].TableName.L, Equals, "t3")
|
||||
c.Assert(hints[2].Indexes, HasLen, 3)
|
||||
c.Assert(hints[2].Indexes[0].L, Equals, "c1")
|
||||
c.Assert(hints[2].Indexes[1].L, Equals, "primary")
|
||||
c.Assert(hints[2].Indexes[2].L, Equals, "c2")
|
||||
|
||||
// Test READ_FROM_STORAGE
|
||||
stmt, _, err = parser.Parse("select /*+ READ_FROM_STORAGE(tiflash[t1, t2], tikv[t3]) */ c1, c2 from t1, t2, t1 t3 where t1.c1 = t2.c1 and t2.c1 = t3.c1", "", "")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
Reference in New Issue
Block a user