mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #2136 from ditdb/master
parse the index hints clause containning multiple similar parts in mysql
This commit is contained in:
+10
-3
@@ -277,11 +277,18 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.USE) {
|
||||
parseIndexHintList(tableSource);
|
||||
|
||||
return super.parseTableSourceRest(tableSource);
|
||||
}
|
||||
|
||||
private void parseIndexHintList(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.USE) {
|
||||
lexer.nextToken();
|
||||
MySqlUseIndexHint hint = new MySqlUseIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals("IGNORE")) {
|
||||
@@ -289,6 +296,7 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals("FORCE")) {
|
||||
@@ -296,9 +304,8 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
|
||||
return super.parseTableSourceRest(tableSource);
|
||||
}
|
||||
|
||||
private void parseIndexHint(MySqlIndexHintImpl hint) {
|
||||
|
||||
@@ -424,26 +424,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
}
|
||||
|
||||
protected SQLTableSource primaryTableSourceRest(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.USE) {
|
||||
lexer.nextToken();
|
||||
MySqlUseIndexHint hint = new MySqlUseIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals("FORCE")) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
parseIndexHintList(tableSource);
|
||||
|
||||
if (lexer.token() == Token.PARTITION) {
|
||||
lexer.nextToken();
|
||||
@@ -460,26 +441,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.USE) {
|
||||
lexer.nextToken();
|
||||
MySqlUseIndexHint hint = new MySqlUseIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.IGNORE)) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.FORCE)) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
parseIndexHintList(tableSource);
|
||||
|
||||
if (lexer.token() == Token.PARTITION) {
|
||||
lexer.nextToken();
|
||||
@@ -491,6 +453,32 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
return super.parseTableSourceRest(tableSource);
|
||||
}
|
||||
|
||||
private void parseIndexHintList(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.USE) {
|
||||
lexer.nextToken();
|
||||
MySqlUseIndexHint hint = new MySqlUseIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.IGNORE)) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.FORCE)) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
parseIndexHintList(tableSource);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseIndexHint(MySqlIndexHintImpl hint) {
|
||||
if (lexer.token() == Token.INDEX) {
|
||||
lexer.nextToken();
|
||||
|
||||
Reference in New Issue
Block a user