Search in sources :

Example 1 with MySqlUseIndexHint

use of com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint in project druid by alibaba.

the class MySqlSelectIntoParser method parseTableSourceRest.

protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
    if (identifierEquals("USING")) {
        return tableSource;
    }
    if (lexer.token() == Token.USE) {
        lexer.nextToken();
        MySqlUseIndexHint hint = new MySqlUseIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    if (identifierEquals("IGNORE")) {
        lexer.nextToken();
        MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    if (identifierEquals("FORCE")) {
        lexer.nextToken();
        MySqlForceIndexHint hint = new MySqlForceIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    return super.parseTableSourceRest(tableSource);
}
Also used : MySqlForceIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlForceIndexHint) MySqlUseIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint) MySqlIgnoreIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint)

Example 2 with MySqlUseIndexHint

use of com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint in project druid by alibaba.

the class MySqlSelectParser method parseTableSourceRest.

protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
    if (identifierEquals("USING")) {
        return tableSource;
    }
    if (lexer.token() == Token.USE) {
        lexer.nextToken();
        MySqlUseIndexHint hint = new MySqlUseIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    if (identifierEquals("IGNORE")) {
        lexer.nextToken();
        MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    if (identifierEquals("FORCE")) {
        lexer.nextToken();
        MySqlForceIndexHint hint = new MySqlForceIndexHint();
        parseIndexHint(hint);
        tableSource.getHints().add(hint);
    }
    if (lexer.token() == Token.PARTITION) {
        lexer.nextToken();
        accept(Token.LPAREN);
        this.exprParser.names(((SQLExprTableSource) tableSource).getPartitions(), tableSource);
        accept(Token.RPAREN);
    }
    return super.parseTableSourceRest(tableSource);
}
Also used : MySqlForceIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlForceIndexHint) MySqlUseIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint) MySqlIgnoreIndexHint(com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint)

Aggregations

MySqlForceIndexHint (com.alibaba.druid.sql.dialect.mysql.ast.MySqlForceIndexHint)2 MySqlIgnoreIndexHint (com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint)2 MySqlUseIndexHint (com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint)2