use of com.alibaba.cobar.parser.ast.expression.primary.Identifier in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(ShowOpenTables node) {
appendable.append("SHOW OPEN TABLES");
Identifier db = node.getSchema();
if (db != null) {
appendable.append(" FROM ");
db.accept(this);
}
printLikeOrWhere(node.getPattern(), node.getWhere());
}
use of com.alibaba.cobar.parser.ast.expression.primary.Identifier in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(ShowTableStatus node) {
appendable.append("SHOW TABLE STATUS");
Identifier schema = node.getDatabase();
if (schema != null) {
appendable.append(" FROM ");
schema.accept(this);
}
printLikeOrWhere(node.getPattern(), node.getWhere());
}
use of com.alibaba.cobar.parser.ast.expression.primary.Identifier in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(ShowEvents node) {
appendable.append("SHOW EVENTS");
Identifier schema = node.getSchema();
if (schema != null) {
appendable.append(" FROM ");
schema.accept(this);
}
printLikeOrWhere(node.getPattern(), node.getWhere());
}
use of com.alibaba.cobar.parser.ast.expression.primary.Identifier in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(ShowTriggers node) {
appendable.append("SHOW TRIGGERS");
Identifier schema = node.getSchema();
if (schema != null) {
appendable.append(" FROM ");
schema.accept(this);
}
printLikeOrWhere(node.getPattern(), node.getWhere());
}
use of com.alibaba.cobar.parser.ast.expression.primary.Identifier in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(DMLInsertStatement node) {
appendable.append("INSERT ");
switch(node.getMode()) {
case DELAY:
appendable.append("DELAYED ");
break;
case HIGH:
appendable.append("HIGH_PRIORITY ");
break;
case LOW:
appendable.append("LOW_PRIORITY ");
break;
case UNDEF:
break;
default:
throw new IllegalArgumentException("unknown mode for INSERT: " + node.getMode());
}
if (node.isIgnore())
appendable.append("IGNORE ");
appendable.append("INTO ");
node.getTable().accept(this);
appendable.append(' ');
List<Identifier> cols = node.getColumnNameList();
if (cols != null && !cols.isEmpty()) {
appendable.append('(');
printList(cols);
appendable.append(") ");
}
QueryExpression select = node.getSelect();
if (select == null) {
appendable.append("VALUES ");
List<RowExpression> rows = node.getRowList();
if (rows != null && !rows.isEmpty()) {
boolean isFst = true;
for (RowExpression row : rows) {
if (row == null || row.getRowExprList().isEmpty())
continue;
if (isFst)
isFst = false;
else
appendable.append(", ");
appendable.append('(');
printList(row.getRowExprList());
appendable.append(')');
}
} else {
throw new IllegalArgumentException("at least one row for INSERT");
}
} else {
select.accept(this);
}
List<Pair<Identifier, Expression>> dup = node.getDuplicateUpdate();
if (dup != null && !dup.isEmpty()) {
appendable.append(" ON DUPLICATE KEY UPDATE ");
boolean isFst = true;
for (Pair<Identifier, Expression> p : dup) {
if (isFst)
isFst = false;
else
appendable.append(", ");
p.getKey().accept(this);
appendable.append(" = ");
p.getValue().accept(this);
}
}
}
Aggregations