use of com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr in project druid by alibaba.
the class MysqlCreateFullTextTokenFilterStatement method addOption.
public void addOption(String name, SQLExpr value) {
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr(name), value);
assignItem.setParent(this);
options.add(assignItem);
}
use of com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr in project druid by alibaba.
the class MysqlCreateFullTextTokenizerStatement method addOption.
public void addOption(String name, SQLExpr value) {
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr(name), value);
assignItem.setParent(this);
options.add(assignItem);
}
use of com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr in project druid by alibaba.
the class OracleCreateTableParser method parseOrganization.
private void parseOrganization(OracleCreateTableStatement stmt) {
OracleCreateTableStatement.Organization organization = new OracleCreateTableStatement.Organization();
acceptIdentifier("ORGANIZATION");
if (lexer.token() == Token.INDEX) {
lexer.nextToken();
organization.setType("INDEX");
this.getExprParser().parseSegmentAttributes(organization);
// index_org_table_clause http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2129638
if (lexer.identifierEquals(FnvHash.Constants.PCTTHRESHOLD)) {
lexer.nextToken();
if (lexer.token() == Token.LITERAL_INT) {
int pctthreshold = ((SQLNumericLiteralExpr) this.exprParser.primary()).getNumber().intValue();
organization.setPctthreshold(pctthreshold);
}
}
} else if (lexer.identifierEquals("HEAP")) {
lexer.nextToken();
organization.setType("HEAP");
this.getExprParser().parseSegmentAttributes(organization);
} else if (lexer.identifierEquals("EXTERNAL")) {
lexer.nextToken();
organization.setType("EXTERNAL");
accept(Token.LPAREN);
if (lexer.identifierEquals("TYPE")) {
lexer.nextToken();
organization.setExternalType(this.exprParser.name());
}
accept(Token.DEFAULT);
acceptIdentifier("DIRECTORY");
organization.setExternalDirectory(this.exprParser.expr());
if (lexer.identifierEquals("ACCESS")) {
lexer.nextToken();
acceptIdentifier("PARAMETERS");
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
SQLExternalRecordFormat recordFormat = new SQLExternalRecordFormat();
if (lexer.identifierEquals("RECORDS")) {
lexer.nextToken();
if (lexer.identifierEquals("DELIMITED")) {
lexer.nextToken();
accept(Token.BY);
if (lexer.identifierEquals("NEWLINE")) {
lexer.nextToken();
recordFormat.setDelimitedBy(new SQLIdentifierExpr("NEWLINE"));
} else {
throw new ParserException("TODO " + lexer.info());
}
if (lexer.identifierEquals(FnvHash.Constants.NOLOGFILE)) {
lexer.nextToken();
recordFormat.setLogfile(false);
}
if (lexer.identifierEquals(FnvHash.Constants.NOBADFILE)) {
lexer.nextToken();
recordFormat.setBadfile(false);
}
} else {
throw new ParserException("TODO " + lexer.info());
}
}
if (lexer.identifierEquals(FnvHash.Constants.FIELDS)) {
lexer.nextToken();
if (lexer.identifierEquals(FnvHash.Constants.TERMINATED)) {
lexer.nextToken();
accept(Token.BY);
recordFormat.setTerminatedBy(this.exprParser.primary());
} else {
throw new ParserException("TODO " + lexer.info());
}
if (lexer.identifierEquals(FnvHash.Constants.LTRIM)) {
lexer.nextToken();
recordFormat.setLtrim(true);
}
}
if (lexer.identifierEquals(FnvHash.Constants.MISSING)) {
lexer.nextToken();
acceptIdentifier("FIELD");
accept(Token.VALUES);
acceptIdentifier("ARE");
accept(Token.NULL);
recordFormat.setMissingFieldValuesAreNull(true);
}
if (lexer.token() == Token.REJECT) {
lexer.nextToken();
acceptIdentifier("ROWS");
accept(Token.WITH);
accept(Token.ALL);
accept(Token.NULL);
acceptIdentifier("FIELDS");
recordFormat.setRejectRowsWithAllNullFields(true);
}
organization.setExternalDirectoryRecordFormat(recordFormat);
accept(Token.RPAREN);
} else if (lexer.token() == Token.USING) {
lexer.nextToken();
acceptIdentifier("CLOB");
throw new ParserException("TODO " + lexer.info());
}
}
acceptIdentifier("LOCATION");
accept(Token.LPAREN);
this.exprParser.exprList(organization.getExternalDirectoryLocation(), organization);
accept(Token.RPAREN);
accept(Token.RPAREN);
if (lexer.token() == Token.REJECT) {
lexer.nextToken();
accept(Token.LIMIT);
organization.setExternalRejectLimit(this.exprParser.primary());
}
//
} else {
throw new ParserException("TODO " + lexer.info());
}
stmt.setOrganization(organization);
}
use of com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr in project druid by alibaba.
the class OracleRowNumToLimit method isRowNum.
public boolean isRowNum(SQLExpr x) {
if (x instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identifierExpr = (SQLIdentifierExpr) x;
long nameHashCode64 = identifierExpr.nameHashCode64();
if (nameHashCode64 == FnvHash.Constants.ROWNUM) {
return true;
}
if (context != null && context.queryBlock != null && context.queryBlock.getFrom() instanceof SQLSubqueryTableSource && ((SQLSubqueryTableSource) context.queryBlock.getFrom()).getSelect().getQuery() instanceof SQLSelectQueryBlock) {
SQLSelectQueryBlock subQueryBlock = ((SQLSubqueryTableSource) context.queryBlock.getFrom()).getSelect().getQueryBlock();
SQLSelectItem selectItem = subQueryBlock.findSelectItem(nameHashCode64);
this.context = new Context(this.context);
this.context.queryBlock = subQueryBlock;
try {
if (selectItem != null && isRowNum(selectItem.getExpr())) {
return true;
}
} finally {
this.context = this.context.parent;
}
}
}
return false;
}
use of com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr in project druid by alibaba.
the class OracleSelectJoin method setRight.
public void setRight(String tableName) {
SQLExprTableSource tableSource;
if (tableName == null || tableName.length() == 0) {
tableSource = null;
} else {
tableSource = new OracleSelectTableReference(new SQLIdentifierExpr(tableName));
}
this.setRight(tableSource);
}
Aggregations