use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
@Override
public boolean visit(InsertIntoClause x) {
if (x.getTableName() instanceof SQLName) {
String ident = ((SQLName) x.getTableName()).toString();
setCurrentTable(x, ident);
TableStat stat = getTableStat(ident);
stat.incrementInsertCount();
Map<String, String> aliasMap = getAliasMap();
if (aliasMap != null) {
if (x.getAlias() != null) {
putAliasMap(aliasMap, x.getAlias(), ident);
}
putAliasMap(aliasMap, ident, ident);
}
}
accept(x.getColumns());
accept(x.getQuery());
accept(x.getReturning());
accept(x.getErrorLogging());
return false;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
@Override
public boolean visit(OracleForStatement x) {
x.getRange().setParent(x);
SQLName index = x.getIndex();
this.getVariants().put(index.toString(), x);
x.getRange().accept(this);
accept(x.getStatements());
return false;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
public boolean visit(OracleSelectQueryBlock x) {
if (x.getWhere() != null) {
x.getWhere().setParent(x);
}
if (x.getInto() instanceof SQLName) {
String tableName = x.getInto().toString();
TableStat stat = getTableStat(tableName);
if (stat != null) {
stat.incrementInsertCount();
}
}
visit((SQLSelectQueryBlock) x);
return true;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLServerStatementParser method parseBlock.
public SQLStatement parseBlock() {
accept(Token.BEGIN);
if (identifierEquals("TRANSACTION") || identifierEquals("TRAN")) {
lexer.nextToken();
SQLStartTransactionStatement startTrans = new SQLStartTransactionStatement();
if (lexer.token() == Token.IDENTIFIER) {
SQLName name = this.exprParser.name();
startTrans.setName(name);
}
return startTrans;
}
SQLBlockStatement block = new SQLBlockStatement();
parseStatementList(block.getStatementList());
accept(Token.END);
return block;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLServerStatementParser method parseInsert0.
protected void parseInsert0(SQLInsertInto insert, boolean acceptSubQuery) {
SQLServerInsertStatement insertStatement = (SQLServerInsertStatement) insert;
SQLServerTop top = this.getExprParser().parseTop();
if (top != null) {
insertStatement.setTop(top);
}
if (lexer.token() == Token.INTO) {
lexer.nextToken();
}
SQLName tableName = this.exprParser.name();
insertStatement.setTableName(tableName);
if (lexer.token() == Token.LITERAL_ALIAS) {
insertStatement.setAlias(as());
}
parseInsert0_hinits(insertStatement);
if (lexer.token() == Token.IDENTIFIER && !lexer.stringVal().equalsIgnoreCase("OUTPUT")) {
insertStatement.setAlias(lexer.stringVal());
lexer.nextToken();
}
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
this.exprParser.exprList(insertStatement.getColumns(), insertStatement);
accept(Token.RPAREN);
}
SQLServerOutput output = this.getExprParser().parserOutput();
if (output != null) {
insertStatement.setOutput(output);
}
if (lexer.token() == Token.VALUES) {
lexer.nextToken();
for (; ; ) {
accept(Token.LPAREN);
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
this.exprParser.exprList(values.getValues(), values);
insertStatement.getValuesList().add(values);
accept(Token.RPAREN);
if (!parseCompleteValues && insertStatement.getValuesList().size() >= parseValuesSize) {
lexer.skipToEOF();
break;
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
} else {
break;
}
}
} else if (acceptSubQuery && (lexer.token() == Token.SELECT || lexer.token() == Token.LPAREN)) {
SQLQueryExpr queryExpr = (SQLQueryExpr) this.exprParser.expr();
insertStatement.setQuery(queryExpr.getSubQuery());
} else if (lexer.token() == Token.DEFAULT) {
lexer.nextToken();
accept(Token.VALUES);
insertStatement.setDefaultValues(true);
}
}
Aggregations