mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlShowEventsStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLExpr schema;
|
||||
private SQLExpr like;
|
||||
private SQLExpr where;
|
||||
|
||||
public SQLExpr getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public void setSchema(SQLExpr schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public SQLExpr getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(SQLExpr like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public SQLExpr getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(SQLExpr where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, schema);
|
||||
acceptChild(visitor, like);
|
||||
acceptChild(visitor, where);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlShowFunctionCodeStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLExpr name;
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLExpr functionName) {
|
||||
this.name = functionName;
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlShowFunctionStatusStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLExpr like;
|
||||
private SQLExpr where;
|
||||
|
||||
public SQLExpr getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(SQLExpr like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public SQLExpr getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(SQLExpr where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, like);
|
||||
acceptChild(visitor, where);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlShowGrantsStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLExpr user;
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, user);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(SQLExpr user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
+118
-89
@@ -52,6 +52,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplicateStatement
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetTransactionIsolationLevelStatement;
|
||||
@@ -73,6 +74,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesState
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEnginesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowErrorsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionCodeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
@@ -110,26 +115,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
MySqlUpdateStatement stmt = (MySqlUpdateStatement) super.parseUpdateStatement();
|
||||
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
|
||||
SQLExpr temp = this.exprParser.expr();
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
limit.setOffset(temp);
|
||||
lexer.nextToken();
|
||||
limit.setRowCount(exprParser.expr());
|
||||
} else if (identifierEquals("OFFSET")) {
|
||||
limit.setRowCount(temp);
|
||||
lexer.nextToken();
|
||||
limit.setOffset(exprParser.expr());
|
||||
} else {
|
||||
limit.setRowCount(temp);
|
||||
}
|
||||
|
||||
stmt.setLimit(limit);
|
||||
}
|
||||
stmt.setLimit(parseLimit());
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -193,15 +179,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
deleteStatement.setOrderBy(orderBy);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
SQLExpr rowCount = exprParser.expr();
|
||||
limit.setRowCount(rowCount);
|
||||
|
||||
deleteStatement.setLimit(limit);
|
||||
}
|
||||
deleteStatement.setLimit(parseLimit());
|
||||
|
||||
return deleteStatement;
|
||||
}
|
||||
@@ -472,7 +450,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (identifierEquals("ERRORS")) {
|
||||
lexer.nextToken();
|
||||
|
||||
|
||||
MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement();
|
||||
stmt.setCount(true);
|
||||
|
||||
@@ -491,26 +469,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement();
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
|
||||
SQLExpr temp = this.exprParser.expr();
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
limit.setOffset(temp);
|
||||
lexer.nextToken();
|
||||
limit.setRowCount(exprParser.expr());
|
||||
} else if (identifierEquals("OFFSET")) {
|
||||
limit.setRowCount(temp);
|
||||
lexer.nextToken();
|
||||
limit.setOffset(exprParser.expr());
|
||||
} else {
|
||||
limit.setRowCount(temp);
|
||||
}
|
||||
|
||||
stmt.setLimit(limit);
|
||||
}
|
||||
stmt.setLimit(parseLimit());
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -617,25 +576,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setFrom(this.exprParser.expr());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
|
||||
SQLExpr temp = this.exprParser.expr();
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
limit.setOffset(temp);
|
||||
lexer.nextToken();
|
||||
limit.setRowCount(exprParser.expr());
|
||||
} else if (identifierEquals("OFFSET")) {
|
||||
limit.setRowCount(temp);
|
||||
lexer.nextToken();
|
||||
limit.setOffset(exprParser.expr());
|
||||
} else {
|
||||
limit.setRowCount(temp);
|
||||
}
|
||||
stmt.setLimit(limit);
|
||||
}
|
||||
stmt.setLimit(parseLimit());
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -730,6 +671,89 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("EVENTS")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowEventsStatement stmt = new MySqlShowEventsStatement();
|
||||
|
||||
if (lexer.token() == Token.FROM || lexer.token() == Token.IN) {
|
||||
lexer.nextToken();
|
||||
stmt.setSchema(this.exprParser.name());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LIKE) {
|
||||
lexer.nextToken();
|
||||
stmt.setLike(this.exprParser.expr());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.WHERE) {
|
||||
lexer.nextToken();
|
||||
stmt.setWhere(this.exprParser.expr());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("FUNCTION")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("CODE")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowFunctionCodeStatement stmt = new MySqlShowFunctionCodeStatement();
|
||||
stmt.setName(this.exprParser.name());
|
||||
return stmt;
|
||||
}
|
||||
|
||||
acceptIdentifier("STATUS");
|
||||
MySqlShowFunctionStatusStatement stmt = new MySqlShowFunctionStatusStatement();
|
||||
|
||||
if (lexer.token() == Token.LIKE) {
|
||||
lexer.nextToken();
|
||||
stmt.setLike(this.exprParser.expr());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.WHERE) {
|
||||
lexer.nextToken();
|
||||
stmt.setWhere(this.exprParser.expr());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
//MySqlShowFunctionStatusStatement
|
||||
|
||||
if (identifierEquals("ENGINE")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowEngineStatement stmt = new MySqlShowEngineStatement();
|
||||
stmt.setName(this.exprParser.name());
|
||||
stmt.setOption(MySqlShowEngineStatement.Option.valueOf(lexer.stringVal().toUpperCase()));
|
||||
lexer.nextToken();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("STORAGE")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("ENGINES");
|
||||
MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement();
|
||||
stmt.setStorage(true);
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("ENGINES")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("GRANTS")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowGrantsStatement stmt = new MySqlShowGrantsStatement();
|
||||
|
||||
if (lexer.token() == Token.FOR) {
|
||||
lexer.nextToken();
|
||||
stmt.setUser(this.exprParser.name());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.stringVal());
|
||||
}
|
||||
|
||||
@@ -754,26 +778,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
private MySqlShowWarningsStatement parseShowWarnings() throws ParserException {
|
||||
MySqlShowWarningsStatement stmt = new MySqlShowWarningsStatement();
|
||||
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
|
||||
SQLExpr temp = this.exprParser.expr();
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
limit.setOffset(temp);
|
||||
lexer.nextToken();
|
||||
limit.setRowCount(exprParser.expr());
|
||||
} else if (identifierEquals("OFFSET")) {
|
||||
limit.setRowCount(temp);
|
||||
lexer.nextToken();
|
||||
limit.setOffset(exprParser.expr());
|
||||
} else {
|
||||
limit.setRowCount(temp);
|
||||
}
|
||||
|
||||
stmt.setLimit(limit);
|
||||
}
|
||||
stmt.setLimit(parseLimit());
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -1421,4 +1426,28 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
||||
private Limit parseLimit() {
|
||||
if (lexer.token() == Token.LIMIT) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
|
||||
|
||||
SQLExpr temp = this.exprParser.expr();
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
limit.setOffset(temp);
|
||||
lexer.nextToken();
|
||||
limit.setRowCount(exprParser.expr());
|
||||
} else if (identifierEquals("OFFSET")) {
|
||||
limit.setRowCount(temp);
|
||||
lexer.nextToken();
|
||||
limit.setOffset(exprParser.expr());
|
||||
} else {
|
||||
limit.setRowCount(temp);
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesState
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEnginesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowErrorsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionCodeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
@@ -306,4 +310,20 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(MySqlShowErrorsStatement x);
|
||||
|
||||
void endVisit(MySqlShowErrorsStatement x);
|
||||
|
||||
boolean visit(MySqlShowEventsStatement x);
|
||||
|
||||
void endVisit(MySqlShowEventsStatement x);
|
||||
|
||||
boolean visit(MySqlShowFunctionCodeStatement x);
|
||||
|
||||
void endVisit(MySqlShowFunctionCodeStatement x);
|
||||
|
||||
boolean visit(MySqlShowFunctionStatusStatement x);
|
||||
|
||||
void endVisit(MySqlShowFunctionStatusStatement x);
|
||||
|
||||
boolean visit(MySqlShowGrantsStatement x);
|
||||
|
||||
void endVisit(MySqlShowGrantsStatement x);
|
||||
}
|
||||
|
||||
+44
-1
@@ -51,6 +51,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesState
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEnginesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowErrorsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionCodeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
@@ -656,11 +660,50 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowErrorsStatement x) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowErrorsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowEventsStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowEventsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionCodeStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionCodeStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionStatusStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionStatusStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowGrantsStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowGrantsStatement x) {
|
||||
}
|
||||
}
|
||||
|
||||
+105
-32
@@ -83,6 +83,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesState
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEnginesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowErrorsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionCodeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
@@ -1469,9 +1473,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSetNamesStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSetCharSetStatement x) {
|
||||
print("SET CHARACTER SET ");
|
||||
@@ -1486,15 +1490,15 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSetCharSetStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowAuthorsStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1502,12 +1506,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print("SHOW AUTHORS");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowBinaryLogsStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowBinaryLogsStatement x) {
|
||||
print("SHOW BINARY LOGS");
|
||||
@@ -1522,9 +1526,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowMasterLogsStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowCollationStatement x) {
|
||||
print("SHOW COLLATION");
|
||||
@@ -1538,12 +1542,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCollationStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowBinLogEventsStatement x) {
|
||||
print("SHOW BINLOG EVENTS");
|
||||
@@ -1561,10 +1565,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowBinLogEventsStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1583,7 +1587,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCharacterSetStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1594,19 +1598,19 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowContributorsStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowCreateDatabaseStatement x) {
|
||||
print("SHOW CREATE DATABASE ");
|
||||
x.getDatabase().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateDatabaseStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1618,31 +1622,31 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateEventStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowCreateFunctionStatement x) {
|
||||
print("SHOW CREATE FUNCTION ");
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateFunctionStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowCreateProcedureStatement x) {
|
||||
print("SHOW CREATE PROCEDURE ");
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateProcedureStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1654,7 +1658,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateTableStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1666,7 +1670,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateTriggerStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1678,7 +1682,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowCreateViewStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1692,7 +1696,66 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowEngineStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowEventsStatement x) {
|
||||
print("SHOW EVENTS");
|
||||
if (x.getSchema() != null) {
|
||||
print(" FROM ");
|
||||
x.getSchema().accept(this);
|
||||
}
|
||||
|
||||
if (x.getLike() != null) {
|
||||
print(" LIKE ");
|
||||
x.getLike().accept(this);
|
||||
}
|
||||
|
||||
if (x.getWhere() != null) {
|
||||
print(" WHERE ");
|
||||
x.getWhere().accept(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowEventsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionCodeStatement x) {
|
||||
print("SHOW FUNCTION CODE ");
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionCodeStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionStatusStatement x) {
|
||||
print("SHOW FUNCTION STATUS");
|
||||
if (x.getLike() != null) {
|
||||
print(" LIKE ");
|
||||
x.getLike().accept(this);
|
||||
}
|
||||
|
||||
if (x.getWhere() != null) {
|
||||
print(" WHERE ");
|
||||
x.getWhere().accept(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionStatusStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1707,7 +1770,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowEnginesStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1726,6 +1789,16 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowErrorsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowGrantsStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowGrantsStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesState
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEnginesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowErrorsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionCodeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
@@ -725,4 +729,44 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
public void endVisit(MySqlShowErrorsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowEventsStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowEventsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionCodeStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionCodeStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowFunctionStatusStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowFunctionStatusStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowGrantsStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowGrantsStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,10 +184,6 @@ public class OracleExprParser extends SQLExprParser {
|
||||
accept(Token.RPAREN);
|
||||
|
||||
return primaryRest(extract);
|
||||
case TIMESTAMP:
|
||||
return primaryRest(parseTimestamp());
|
||||
case DATE:
|
||||
return primaryRest(parseDate());
|
||||
case BINARY_FLOAT:
|
||||
OracleBinaryFloatExpr floatExpr = new OracleBinaryFloatExpr();
|
||||
floatExpr.setValue(Float.parseFloat(lexer.numberString()));
|
||||
@@ -284,6 +280,12 @@ public class OracleExprParser extends SQLExprParser {
|
||||
sqlExpr = cursorExpr;
|
||||
return primaryRest(sqlExpr);
|
||||
default:
|
||||
if (identifierEquals("DATE")) {
|
||||
return primaryRest(parseDate());
|
||||
}
|
||||
if (identifierEquals("TIMESTAMP")) {
|
||||
return primaryRest(parseTimestamp());
|
||||
}
|
||||
return super.primary();
|
||||
}
|
||||
}
|
||||
@@ -460,7 +462,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public OracleDateExpr parseDate() {
|
||||
accept(Token.DATE);
|
||||
identifierEquals("DATE");
|
||||
|
||||
OracleDateExpr timestamp = new OracleDateExpr();
|
||||
|
||||
@@ -472,7 +474,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public SQLExpr parseTimestamp() {
|
||||
accept(Token.TIMESTAMP);
|
||||
acceptIdentifier("TIMESTAMP");
|
||||
|
||||
if (lexer.token() != Token.LITERAL_ALIAS && lexer.token() != Token.LITERAL_CHARS) {
|
||||
return new SQLIdentifierExpr("TIMESTAMP");
|
||||
|
||||
@@ -95,8 +95,6 @@ public class OracleLexer extends Lexer {
|
||||
map.put("PRIOR", Token.PRIOR);
|
||||
map.put("WITH", Token.WITH);
|
||||
map.put("EXTRACT", Token.EXTRACT);
|
||||
map.put("DATE", Token.DATE);
|
||||
map.put("TIMESTAMP", Token.TIMESTAMP);
|
||||
map.put("COLUMN", Token.COLUMN);
|
||||
|
||||
map.put("CURSOR", Token.CURSOR);
|
||||
|
||||
@@ -799,7 +799,7 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
clause.setType(AsOfFlashbackQueryClause.Type.SCN);
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
accept(Token.TIMESTAMP);
|
||||
acceptIdentifier("TIMESTAMP");
|
||||
clause.setType(AsOfFlashbackQueryClause.Type.TIMESTAMP);
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
return clause;
|
||||
} else {
|
||||
AsOfFlashbackQueryClause clause = new AsOfFlashbackQueryClause();
|
||||
accept(Token.TIMESTAMP);
|
||||
acceptIdentifier("TIMESTAMP");
|
||||
clause.setType(AsOfFlashbackQueryClause.Type.TIMESTAMP);
|
||||
clause.setExpr(createExprParser().expr());
|
||||
|
||||
|
||||
@@ -620,7 +620,7 @@ public class SQLExprParser extends SQLParser {
|
||||
identName = lexer.stringVal();
|
||||
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == Token.REFERENCE || lexer.token() == Token.DATE || lexer.token() == Token.TIMESTAMP) {
|
||||
} else if (lexer.token() == Token.REFERENCE) {
|
||||
identName = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SQLParser {
|
||||
return alias;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.KEY || lexer.token() == Token.CASE || lexer.token() == Token.TIMESTAMP) {
|
||||
if (lexer.token() == Token.KEY || lexer.token() == Token.CASE) {
|
||||
alias = lexer.token.name();
|
||||
lexer.nextToken();
|
||||
return alias;
|
||||
@@ -97,7 +97,7 @@ public class SQLParser {
|
||||
alias = "'" + lexer.stringVal() + "'";
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == Token.TIME || lexer.token() == Token.CASE || lexer.token() == Token.AT
|
||||
|| lexer.token() == Token.TIMESTAMP || lexer.token() == Token.LOG) {
|
||||
|| lexer.token() == Token.LOG) {
|
||||
alias = lexer.token.name();
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@@ -140,8 +140,6 @@ public enum Token {
|
||||
CONNECT("CONNECT"),
|
||||
WITH("WITH"),
|
||||
EXTRACT("EXTRACT"),
|
||||
TIMESTAMP("TIMESTAMP"),
|
||||
DATE("DATE"),
|
||||
CURSOR("CURSOR"),
|
||||
TO("TO"),
|
||||
MODEL("MODEL"),
|
||||
|
||||
Reference in New Issue
Block a user