Search in sources :

Example 76 with SQLName

use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.

the class MySqlStatementParser method parsePrepare.

public MySqlPrepareStatement parsePrepare() {
    acceptIdentifier("PREPARE");
    SQLName name = exprParser.name();
    accept(Token.FROM);
    SQLExpr from = exprParser.expr();
    return new MySqlPrepareStatement(name, from);
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr) MySqlPrepareStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement)

Example 77 with SQLName

use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.

the class MySqlStatementParser method parseExecute.

public MySqlExecuteStatement parseExecute() {
    acceptIdentifier("EXECUTE");
    MySqlExecuteStatement stmt = new MySqlExecuteStatement();
    SQLName statementName = exprParser.name();
    stmt.setStatementName(statementName);
    if (identifierEquals("USING")) {
        lexer.nextToken();
        exprParser.exprList(stmt.getParameters(), stmt);
    }
    return stmt;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName) MySqlExecuteStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement)

Example 78 with SQLName

use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.

the class MySqlSchemaStatVisitor method visit.

@Override
public boolean visit(MySqlDeclareStatement x) {
    for (SQLDeclareItem item : x.getVarList()) {
        item.setParent(x);
        SQLName var = (SQLName) item.getName();
        this.variants.put(var.toString(), var);
    }
    return false;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName) SQLDeclareItem(com.alibaba.druid.sql.ast.SQLDeclareItem)

Example 79 with SQLName

use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.

the class MySqlStatementParser method parseReplicate.

public MySqlReplaceStatement parseReplicate() {
    MySqlReplaceStatement stmt = new MySqlReplaceStatement();
    accept(Token.REPLACE);
    if (lexer.token() == Token.COMMENT) {
        lexer.nextToken();
    }
    if (identifierEquals(LOW_PRIORITY)) {
        stmt.setLowPriority(true);
        lexer.nextToken();
    }
    if (identifierEquals(DELAYED)) {
        stmt.setDelayed(true);
        lexer.nextToken();
    }
    if (lexer.token() == Token.INTO) {
        lexer.nextToken();
    }
    SQLName tableName = exprParser.name();
    stmt.setTableName(tableName);
    if (lexer.token() == Token.LPAREN) {
        lexer.nextToken();
        if (lexer.token() == Token.SELECT) {
            SQLQueryExpr queryExpr = (SQLQueryExpr) this.exprParser.expr();
            stmt.setQuery(queryExpr);
        } else {
            this.exprParser.exprList(stmt.getColumns(), stmt);
        }
        accept(Token.RPAREN);
    }
    if (lexer.token() == Token.VALUES || identifierEquals("VALUE")) {
        lexer.nextToken();
        parseValueClause(stmt.getValuesList(), 0);
    } else if (lexer.token() == Token.SELECT) {
        SQLQueryExpr queryExpr = (SQLQueryExpr) this.exprParser.expr();
        stmt.setQuery(queryExpr);
    } else if (lexer.token() == Token.SET) {
        lexer.nextToken();
        SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
        stmt.getValuesList().add(values);
        for (; ; ) {
            stmt.addColumn(this.exprParser.name());
            if (lexer.token() == Token.COLONEQ) {
                lexer.nextToken();
            } else {
                accept(Token.EQ);
            }
            values.addValue(this.exprParser.expr());
            if (lexer.token() == (Token.COMMA)) {
                lexer.nextToken();
                continue;
            }
            break;
        }
    } else if (lexer.token() == Token.LPAREN) {
        lexer.nextToken();
        SQLQueryExpr queryExpr = (SQLQueryExpr) this.exprParser.expr();
        stmt.setQuery(queryExpr);
        accept(Token.RPAREN);
    }
    return stmt;
}
Also used : SQLQueryExpr(com.alibaba.druid.sql.ast.expr.SQLQueryExpr) MySqlReplaceStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement) SQLName(com.alibaba.druid.sql.ast.SQLName) ValuesClause(com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause) ValuesClause(com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause)

Example 80 with SQLName

use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.

the class OracleCreateTableParser method parseSubPartition.

protected SQLSubPartition parseSubPartition() {
    acceptIdentifier("SUBPARTITION");
    SQLSubPartition subPartition = new SQLSubPartition();
    SQLName name = this.exprParser.name();
    subPartition.setName(name);
    SQLPartitionValue values = this.exprParser.parsePartitionValues();
    if (values != null) {
        subPartition.setValues(values);
    }
    return subPartition;
}
Also used : SQLSubPartition(com.alibaba.druid.sql.ast.SQLSubPartition) SQLName(com.alibaba.druid.sql.ast.SQLName) SQLPartitionValue(com.alibaba.druid.sql.ast.SQLPartitionValue)

Aggregations

SQLName (com.alibaba.druid.sql.ast.SQLName)102 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)33 TableStat (com.alibaba.druid.stat.TableStat)20 ParserException (com.alibaba.druid.sql.parser.ParserException)17 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)8 SQLObject (com.alibaba.druid.sql.ast.SQLObject)6 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)6 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)6 WallContext (com.alibaba.druid.wall.WallContext)6 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)5 SQLColumnDefinition (com.alibaba.druid.sql.ast.statement.SQLColumnDefinition)5 WallSqlTableStat (com.alibaba.druid.wall.WallSqlTableStat)5 SQLPartition (com.alibaba.druid.sql.ast.SQLPartition)4 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)4 SQLQueryExpr (com.alibaba.druid.sql.ast.expr.SQLQueryExpr)4 SQLCreateTableStatement (com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement)4 SQLTableElement (com.alibaba.druid.sql.ast.statement.SQLTableElement)4 SQLSubPartition (com.alibaba.druid.sql.ast.SQLSubPartition)3 SQLLiteralExpr (com.alibaba.druid.sql.ast.expr.SQLLiteralExpr)3 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)3