mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql parser support oceanbase hints
This commit is contained in:
+30
-9
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLCommentHint;
|
||||
import com.alibaba.druid.sql.ast.SQLOrderBy;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||
@@ -26,17 +30,34 @@ import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlDeleteStatement extends SQLDeleteStatement {
|
||||
|
||||
private boolean lowPriority = false;
|
||||
private boolean quick = false;
|
||||
private boolean ignore = false;
|
||||
private boolean lowPriority = false;
|
||||
private boolean quick = false;
|
||||
private boolean ignore = false;
|
||||
|
||||
private SQLTableSource from;
|
||||
private SQLTableSource using;
|
||||
private SQLOrderBy orderBy;
|
||||
private Limit limit;
|
||||
private SQLTableSource from;
|
||||
private SQLTableSource using;
|
||||
private SQLOrderBy orderBy;
|
||||
private Limit limit;
|
||||
|
||||
private List<SQLCommentHint> hints;
|
||||
|
||||
public MySqlDeleteStatement(){
|
||||
super(JdbcConstants.MYSQL);
|
||||
}
|
||||
|
||||
public List<SQLCommentHint> getHints() {
|
||||
if (hints == null) {
|
||||
hints = new ArrayList<SQLCommentHint>();
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
public MySqlDeleteStatement() {
|
||||
super (JdbcConstants.MYSQL);
|
||||
public int getHintsSize() {
|
||||
if (hints == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hints.size();
|
||||
}
|
||||
|
||||
public boolean isLowPriority() {
|
||||
|
||||
@@ -420,7 +420,9 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
boolean isHint = false;
|
||||
int startHintSp = bufPos + 1;
|
||||
if (ch == '!') {
|
||||
if (ch == '!' //
|
||||
|| ch == '+' // oceanbase hints
|
||||
) {
|
||||
isHint = true;
|
||||
scanChar();
|
||||
bufPos++;
|
||||
|
||||
@@ -262,6 +262,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
if (lexer.token() == Token.COMMENT) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.HINT) {
|
||||
this.getExprParser().parseHints(deleteStatement.getHints());
|
||||
}
|
||||
|
||||
if (identifierEquals(LOW_PRIORITY)) {
|
||||
deleteStatement.setLowPriority(true);
|
||||
|
||||
@@ -857,6 +857,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
@Override
|
||||
public boolean visit(MySqlDeleteStatement x) {
|
||||
print0(ucase ? "DELETE " : "delete ");
|
||||
|
||||
for (int i = 0, size = x.getHintsSize(); i < size; ++i) {
|
||||
SQLCommentHint hint = x.getHints().get(i);
|
||||
hint.accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
if (x.isLowPriority()) {
|
||||
print0(ucase ? "LOW_PRIORITY " : "low_priority ");
|
||||
|
||||
Reference in New Issue
Block a user