use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLServerOutputVisitor method visit.
@Override
public boolean visit(SQLServerExecStatement x) {
print0(ucase ? "EXEC " : "exec ");
SQLName returnStatus = x.getReturnStatus();
if (returnStatus != null) {
returnStatus.accept(this);
print0(" = ");
}
SQLName moduleName = x.getModuleName();
if (moduleName != null) {
moduleName.accept(this);
print(' ');
} else {
print0(" (");
}
printAndAccept(x.getParameters(), ", ");
if (moduleName == null) {
print(')');
}
return false;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLCreateTableParser method parseCrateTable.
public SQLCreateTableStatement parseCrateTable(boolean acceptCreate) {
if (acceptCreate) {
accept(Token.CREATE);
}
SQLCreateTableStatement createTable = newCreateStatement();
if (identifierEquals("GLOBAL")) {
lexer.nextToken();
if (identifierEquals("TEMPORARY")) {
lexer.nextToken();
createTable.setType(SQLCreateTableStatement.Type.GLOBAL_TEMPORARY);
} else {
throw new ParserException("syntax error " + lexer.token() + " " + lexer.stringVal());
}
} else if (lexer.token() == Token.IDENTIFIER && lexer.stringVal().equalsIgnoreCase("LOCAL")) {
lexer.nextToken();
if (lexer.token() == Token.IDENTIFIER && lexer.stringVal().equalsIgnoreCase("TEMPORAY")) {
lexer.nextToken();
createTable.setType(SQLCreateTableStatement.Type.LOCAL_TEMPORARY);
} else {
throw new ParserException("syntax error");
}
}
accept(Token.TABLE);
createTable.setName(this.exprParser.name());
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
for (; ; ) {
if (//
lexer.token() == Token.IDENTIFIER || lexer.token() == Token.LITERAL_ALIAS) {
SQLColumnDefinition column = this.exprParser.parseColumn();
createTable.getTableElementList().add(column);
} else if (//
lexer.token == Token.PRIMARY || //
lexer.token == Token.UNIQUE || //
lexer.token == Token.CHECK || lexer.token == Token.CONSTRAINT) {
SQLConstraint constraint = this.exprParser.parseConstaint();
constraint.setParent(createTable);
createTable.getTableElementList().add((SQLTableElement) constraint);
} else if (lexer.token() == Token.TABLESPACE) {
throw new ParserException("TODO " + lexer.token());
} else {
SQLColumnDefinition column = this.exprParser.parseColumn();
createTable.getTableElementList().add(column);
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
if (lexer.token() == Token.RPAREN) {
// compatible for sql server
break;
}
continue;
}
break;
}
// while
// (this.tokenList.current().equals(OracleToken.ConstraintToken)) {
// parseConstaint(table.getConstraints());
//
// if (this.tokenList.current().equals(OracleToken.CommaToken))
// ;
// lexer.nextToken();
// }
accept(Token.RPAREN);
if (identifierEquals("INHERITS")) {
lexer.nextToken();
accept(Token.LPAREN);
SQLName inherits = this.exprParser.name();
createTable.setInherits(new SQLExprTableSource(inherits));
accept(Token.RPAREN);
}
}
return createTable;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLStatementParser method parseDropTablespace.
protected SQLDropTableSpaceStatement parseDropTablespace(boolean acceptDrop) {
SQLDropTableSpaceStatement stmt = new SQLDropTableSpaceStatement(getDbType());
if (lexer.isKeepComments() && lexer.hasComment()) {
stmt.addBeforeComment(lexer.readAndResetComments());
}
if (acceptDrop) {
accept(Token.DROP);
}
accept(Token.TABLESPACE);
if (lexer.token() == Token.IF) {
lexer.nextToken();
accept(Token.EXISTS);
stmt.setIfExists(true);
}
SQLName name = this.exprParser.name();
stmt.setName(name);
return stmt;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLStatementParser method parseDropTrigger.
protected SQLDropTriggerStatement parseDropTrigger(boolean acceptDrop) {
if (acceptDrop) {
accept(Token.DROP);
}
lexer.nextToken();
SQLName name = this.exprParser.name();
SQLDropTriggerStatement stmt = new SQLDropTriggerStatement(getDbType());
stmt.setName(name);
return stmt;
}
use of com.alibaba.druid.sql.ast.SQLName in project druid by alibaba.
the class SQLStatementParser method parseAlterTableDropPartition.
protected SQLAlterTableDropPartition parseAlterTableDropPartition(boolean ifExists) {
lexer.nextToken();
SQLAlterTableDropPartition dropPartition = new SQLAlterTableDropPartition();
dropPartition.setIfExists(ifExists);
if (lexer.token() == Token.LPAREN) {
accept(Token.LPAREN);
parseAssignItems(dropPartition.getPartitions(), dropPartition);
accept(Token.RPAREN);
if (identifierEquals("PURGE")) {
lexer.nextToken();
dropPartition.setPurge(true);
}
} else {
SQLName partition = this.exprParser.name();
dropPartition.addPartition(partition);
}
return dropPartition;
}
Aggregations