Search in sources :

Example 46 with SQLName

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

the class SQLStatementParser method parseDropProcedure.

protected SQLDropProcedureStatement parseDropProcedure(boolean acceptDrop) {
    if (acceptDrop) {
        accept(Token.DROP);
    }
    SQLDropProcedureStatement stmt = new SQLDropProcedureStatement(getDbType());
    accept(Token.PROCEDURE);
    if (lexer.token() == Token.IF) {
        lexer.nextToken();
        accept(Token.EXISTS);
        stmt.setIfExists(true);
    }
    SQLName name = this.exprParser.name();
    stmt.setName(name);
    return stmt;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName)

Example 47 with SQLName

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

the class SQLStatementParser method parseDropView.

protected SQLDropViewStatement parseDropView(boolean acceptDrop) {
    if (acceptDrop) {
        accept(Token.DROP);
    }
    SQLDropViewStatement stmt = new SQLDropViewStatement(getDbType());
    accept(Token.VIEW);
    if (lexer.token() == Token.IF) {
        lexer.nextToken();
        accept(Token.EXISTS);
        stmt.setIfExists(true);
    }
    for (; ; ) {
        SQLName name = this.exprParser.name();
        stmt.addPartition(new SQLExprTableSource(name));
        if (lexer.token() == Token.COMMA) {
            lexer.nextToken();
            continue;
        }
        break;
    }
    if (identifierEquals("RESTRICT")) {
        lexer.nextToken();
        stmt.setRestrict(true);
    } else if (identifierEquals("CASCADE")) {
        lexer.nextToken();
        if (identifierEquals("CONSTRAINTS")) {
            // for oracle
            lexer.nextToken();
        }
        stmt.setCascade(true);
    }
    return stmt;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName)

Example 48 with SQLName

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

the class SQLStatementParser method parseDropSequece.

protected SQLDropSequenceStatement parseDropSequece(boolean acceptDrop) {
    if (acceptDrop) {
        accept(Token.DROP);
    }
    lexer.nextToken();
    SQLName name = this.exprParser.name();
    SQLDropSequenceStatement stmt = new SQLDropSequenceStatement(getDbType());
    stmt.setName(name);
    return stmt;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName)

Example 49 with SQLName

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

the class SchemaStatVisitor method visit.

@Override
public boolean visit(SQLDropIndexStatement x) {
    setMode(x, Mode.DropIndex);
    SQLExprTableSource table = x.getTableName();
    if (table != null) {
        SQLName name = (SQLName) table.getExpr();
        String ident = name.toString();
        setCurrentTable(ident);
        TableStat stat = getTableStat(ident);
        stat.incrementDropIndexCount();
        Map<String, String> aliasMap = getAliasMap();
        putAliasMap(aliasMap, ident, ident);
    }
    return false;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName) TableStat(com.alibaba.druid.stat.TableStat)

Example 50 with SQLName

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

the class SchemaStatVisitor method visit.

@Override
public boolean visit(SQLForeignKeyImpl x) {
    for (SQLName column : x.getReferencingColumns()) {
        column.accept(this);
    }
    String table = x.getReferencedTableName().getSimpleName();
    setCurrentTable(table);
    TableStat stat = getTableStat(table);
    stat.incrementReferencedCount();
    for (SQLName column : x.getReferencedColumns()) {
        String columnName = column.getSimpleName();
        addColumn(table, columnName);
    }
    return false;
}
Also used : SQLName(com.alibaba.druid.sql.ast.SQLName) TableStat(com.alibaba.druid.stat.TableStat)

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