Search in sources :

Example 11 with Limit

use of com.alibaba.cobar.parser.ast.fragment.Limit 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);
    }
}
Also used : DataType(com.alibaba.cobar.parser.ast.fragment.ddl.datatype.DataType) BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) VariableExpression(com.alibaba.cobar.parser.ast.expression.primary.VariableExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) TernaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.TernaryOperatorExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) ShowProfile(com.alibaba.cobar.parser.ast.stmt.dal.ShowProfile) Limit(com.alibaba.cobar.parser.ast.fragment.Limit)

Example 12 with Limit

use of com.alibaba.cobar.parser.ast.fragment.Limit in project cobar by alibaba.

the class MySQLOutputASTVisitor method visit.

@Override
public void visit(ShowBinLogEvent node) {
    appendable.append("SHOW BINLOG EVENTS");
    String logName = node.getLogName();
    if (logName != null)
        appendable.append(" IN ").append(logName);
    Expression pos = node.getPos();
    if (pos != null) {
        appendable.append(" FROM ");
        pos.accept(this);
    }
    Limit limit = node.getLimit();
    if (limit != null) {
        appendable.append(' ');
        limit.accept(this);
    }
}
Also used : BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) VariableExpression(com.alibaba.cobar.parser.ast.expression.primary.VariableExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) TernaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.TernaryOperatorExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) LiteralString(com.alibaba.cobar.parser.ast.expression.primary.literal.LiteralString) Limit(com.alibaba.cobar.parser.ast.fragment.Limit)

Example 13 with Limit

use of com.alibaba.cobar.parser.ast.fragment.Limit in project cobar by alibaba.

the class MySQLOutputASTVisitor method visit.

@Override
public void visit(DMLUpdateStatement node) {
    appendable.append("UPDATE ");
    if (node.isLowPriority()) {
        appendable.append("LOW_PRIORITY ");
    }
    if (node.isIgnore()) {
        appendable.append("IGNORE ");
    }
    node.getTableRefs().accept(this);
    appendable.append(" SET ");
    boolean isFst = true;
    for (Pair<Identifier, Expression> p : node.getValues()) {
        if (isFst)
            isFst = false;
        else
            appendable.append(", ");
        p.getKey().accept(this);
        appendable.append(" = ");
        p.getValue().accept(this);
    }
    Expression where = node.getWhere();
    if (where != null) {
        appendable.append(" WHERE ");
        where.accept(this);
    }
    OrderBy order = node.getOrderBy();
    if (order != null) {
        appendable.append(' ');
        order.accept(this);
    }
    Limit limit = node.getLimit();
    if (limit != null) {
        appendable.append(' ');
        limit.accept(this);
    }
}
Also used : OrderBy(com.alibaba.cobar.parser.ast.fragment.OrderBy) Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier) BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) VariableExpression(com.alibaba.cobar.parser.ast.expression.primary.VariableExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) TernaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.TernaryOperatorExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) Limit(com.alibaba.cobar.parser.ast.fragment.Limit)

Example 14 with Limit

use of com.alibaba.cobar.parser.ast.fragment.Limit in project cobar by alibaba.

the class MySQLOutputASTVisitor method visit.

@Override
public void visit(ShowWarnings node) {
    appendable.append("SHOW ");
    if (node.isCount()) {
        appendable.append("COUNT(*) WARNINGS");
    } else {
        appendable.append("WARNINGS");
        Limit limit = node.getLimit();
        if (limit != null) {
            appendable.append(' ');
            limit.accept(this);
        }
    }
}
Also used : Limit(com.alibaba.cobar.parser.ast.fragment.Limit)

Aggregations

Limit (com.alibaba.cobar.parser.ast.fragment.Limit)14 Expression (com.alibaba.cobar.parser.ast.expression.Expression)10 VariableExpression (com.alibaba.cobar.parser.ast.expression.primary.VariableExpression)7 OrderBy (com.alibaba.cobar.parser.ast.fragment.OrderBy)7 BinaryOperatorExpression (com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression)5 PolyadicOperatorExpression (com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression)5 TernaryOperatorExpression (com.alibaba.cobar.parser.ast.expression.TernaryOperatorExpression)5 UnaryOperatorExpression (com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression)5 BetweenAndExpression (com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression)5 ComparisionEqualsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression)5 ComparisionIsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression)5 ComparisionNullSafeEqualsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression)5 InExpression (com.alibaba.cobar.parser.ast.expression.comparison.InExpression)5 LogicalAndExpression (com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression)5 LogicalOrExpression (com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression)5 QueryExpression (com.alibaba.cobar.parser.ast.expression.misc.QueryExpression)5 UserExpression (com.alibaba.cobar.parser.ast.expression.misc.UserExpression)5 CaseWhenOperatorExpression (com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression)5 MatchExpression (com.alibaba.cobar.parser.ast.expression.primary.MatchExpression)5 RowExpression (com.alibaba.cobar.parser.ast.expression.primary.RowExpression)5