use of com.alibaba.cobar.parser.ast.stmt.dal.ShowProfile in project cobar by alibaba.
the class MySQLDALParser method showProfile.
private ShowProfile showProfile() throws SQLSyntaxErrorException {
lexer.nextToken();
List<ShowProfile.Type> types = new LinkedList<ShowProfile.Type>();
ShowProfile.Type type = showPrifileType();
if (type == null) {
types = Collections.emptyList();
} else if (lexer.token() == PUNC_COMMA) {
types = new LinkedList<ShowProfile.Type>();
types.add(type);
for (; lexer.token() == PUNC_COMMA; ) {
lexer.nextToken();
type = showPrifileType();
types.add(type);
}
} else {
types = new ArrayList<ShowProfile.Type>();
types.add(type);
}
Expression forQuery = null;
if (lexer.token() == KW_FOR) {
lexer.nextToken();
matchIdentifier("QUERY");
forQuery = exprParser.expression();
}
Limit limit = limit();
return new ShowProfile(types, forQuery, limit);
}
use of com.alibaba.cobar.parser.ast.stmt.dal.ShowProfile in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(ShowProfile node) {
appendable.append("SHOW PROFILE");
List<ShowProfile.Type> types = node.getTypes();
boolean isFst = true;
for (ShowProfile.Type type : types) {
if (isFst) {
isFst = false;
appendable.append(' ');
} else {
appendable.append(", ");
}
appendable.append(type.name().replace('_', ' '));
}
Expression query = node.getForQuery();
if (query != null) {
appendable.append(" FOR QUERY ");
query.accept(this);
}
Limit limit = node.getLimit();
if (limit != null) {
appendable.append(' ');
limit.accept(this);
}
}
Aggregations