mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -170,6 +170,15 @@ public class DB2CreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
SQLName validproc = this.exprParser.name();
|
||||
createTable.setValidproc(validproc);
|
||||
continue;
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.COMPRESS)) {
|
||||
lexer.nextToken();
|
||||
createTable.setCompress(true);
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.YES)) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,16 @@ public class DB2OutputVisitor extends SQLASTOutputVisitor implements DB2ASTVisit
|
||||
partitionBy.accept(this);
|
||||
}
|
||||
|
||||
Boolean compress = x.getCompress();
|
||||
if (compress != null) {
|
||||
println();
|
||||
if (compress.booleanValue()) {
|
||||
print0(ucase ? "COMPRESS YES" : "compress yes");
|
||||
} else {
|
||||
print0(ucase ? "COMPRESS NO" : "compress no");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -116,10 +116,15 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
stmt.setSelect(query);
|
||||
} else {
|
||||
for (;;) {
|
||||
SQLColumnDefinition column = null;
|
||||
if (lexer.token() == Token.IDENTIFIER //
|
||||
|| lexer.token() == Token.LITERAL_CHARS) {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
column = this.exprParser.parseColumn();
|
||||
stmt.getTableElementList().add(column);
|
||||
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
} else if (lexer.token() == Token.CONSTRAINT //
|
||||
|| lexer.token() == Token.PRIMARY //
|
||||
|| lexer.token() == Token.UNIQUE) {
|
||||
@@ -175,14 +180,17 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
SQLCheck check = this.exprParser.parseCheck();
|
||||
stmt.getTableElementList().add(check);
|
||||
} else {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
column = this.exprParser.parseColumn();
|
||||
stmt.getTableElementList().add(column);
|
||||
}
|
||||
|
||||
if (!(lexer.token() == (Token.COMMA))) {
|
||||
if (lexer.token() != Token.COMMA) {
|
||||
break;
|
||||
} else {
|
||||
lexer.nextToken();
|
||||
if (lexer.isKeepComments() && lexer.hasComment() && column != null) {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
|
||||
if (!(lexer.token() == (Token.COMMA))) {
|
||||
if (lexer.token() != Token.COMMA) {
|
||||
break;
|
||||
} else {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -1523,7 +1523,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
lexer.nextToken();
|
||||
attributes.setCompress(Boolean.FALSE);
|
||||
continue;
|
||||
} else if (lexer.identifierEquals("COMPRESS")) {
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.COMPRESS)) {
|
||||
lexer.nextToken();
|
||||
attributes.setCompress(Boolean.TRUE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user