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:
+11
-10
@@ -58,8 +58,9 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
|
||||
private Boolean compress;
|
||||
private Integer compressLevel;
|
||||
private boolean compressForOltp;
|
||||
private boolean onCommit;
|
||||
private boolean preserveRows;
|
||||
|
||||
private boolean onCommitPreserveRows;
|
||||
private boolean onCommitDeleteRows;
|
||||
|
||||
private Boolean cache;
|
||||
|
||||
@@ -114,20 +115,20 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public boolean isOnCommit() {
|
||||
return onCommit;
|
||||
public boolean isOnCommitPreserveRows() {
|
||||
return onCommitPreserveRows;
|
||||
}
|
||||
|
||||
public void setOnCommit(boolean onCommit) {
|
||||
this.onCommit = onCommit;
|
||||
public void setOnCommitPreserveRows(boolean onCommitPreserveRows) {
|
||||
this.onCommitPreserveRows = onCommitPreserveRows;
|
||||
}
|
||||
|
||||
public boolean isPreserveRows() {
|
||||
return preserveRows;
|
||||
public boolean isOnCommitDeleteRows() {
|
||||
return onCommitDeleteRows;
|
||||
}
|
||||
|
||||
public void setPreserveRows(boolean preserveRows) {
|
||||
this.preserveRows = preserveRows;
|
||||
public void setOnCommitDeleteRows(boolean onCommitDeleteRows) {
|
||||
this.onCommitDeleteRows = onCommitDeleteRows;
|
||||
}
|
||||
|
||||
public Boolean getLogging() {
|
||||
|
||||
+8
@@ -24,6 +24,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
|
||||
public class OracleSetTransactionStatement extends OracleStatementImpl implements OracleStatement {
|
||||
|
||||
private boolean readOnly = false;
|
||||
private boolean write = false;
|
||||
|
||||
private SQLExpr name;
|
||||
|
||||
@@ -51,4 +52,11 @@ public class OracleSetTransactionStatement extends OracleStatementImpl implement
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
public boolean isWrite() {
|
||||
return write;
|
||||
}
|
||||
|
||||
public void setWrite(boolean write) {
|
||||
this.write = write;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -124,12 +124,16 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
|
||||
} else if (lexer.token() == Token.ON) {
|
||||
lexer.nextToken();
|
||||
accept(Token.COMMIT);
|
||||
stmt.setOnCommit(true);
|
||||
continue;
|
||||
} else if (identifierEquals("PRESERVE")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("ROWS");
|
||||
stmt.setPreserveRows(true);
|
||||
|
||||
if (identifierEquals("PRESERVE")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("ROWS");
|
||||
stmt.setOnCommitPreserveRows(true);
|
||||
} else {
|
||||
accept(Token.DELETE);
|
||||
acceptIdentifier("ROWS");
|
||||
stmt.setOnCommitDeleteRows(true);
|
||||
}
|
||||
continue;
|
||||
} else if (identifierEquals("STORAGE")) {
|
||||
OracleStorageClause storage = ((OracleExprParser) this.exprParser).parseStorage();
|
||||
|
||||
+13
-4
@@ -995,13 +995,22 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
|
||||
if (identifierEquals("READ")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("ONLY");
|
||||
stmt.setReadOnly(true);
|
||||
|
||||
if (identifierEquals("ONLY")) {
|
||||
lexer.nextToken();
|
||||
stmt.setReadOnly(true);
|
||||
} else {
|
||||
acceptIdentifier("WRITE");
|
||||
stmt.setWrite(true);
|
||||
}
|
||||
}
|
||||
|
||||
acceptIdentifier("NAME");
|
||||
if (identifierEquals("NAME")) {
|
||||
lexer.nextToken();
|
||||
|
||||
stmt.setName(this.exprParser.expr());
|
||||
}
|
||||
|
||||
stmt.setName(this.exprParser.expr());
|
||||
return stmt;
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -1503,11 +1503,16 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
@Override
|
||||
public boolean visit(OracleSetTransactionStatement x) {
|
||||
if (x.isReadOnly()) {
|
||||
print0(ucase ? "SET TRANSACTION READ ONLY NAME " : "set transaction read only name ");
|
||||
print0(ucase ? "SET TRANSACTION READ ONLY" : "set transaction read only");
|
||||
} else {
|
||||
print0(ucase ? "SET TRANSACTION NAME " : "set transaction name ");
|
||||
print0(ucase ? "SET TRANSACTION" : "set transaction");
|
||||
}
|
||||
|
||||
SQLExpr name = x.getName();
|
||||
if (name != null) {
|
||||
print0(ucase ? " NAME " : " name ");
|
||||
name.accept(this);
|
||||
}
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2127,14 +2132,12 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
x.getLobStorage().accept(this);
|
||||
}
|
||||
|
||||
if (x.isOnCommit()) {
|
||||
if (x.isOnCommitPreserveRows()) {
|
||||
println();
|
||||
print0(ucase ? "ON COMMIT" : "on commit");
|
||||
}
|
||||
|
||||
if (x.isPreserveRows()) {
|
||||
print0(ucase ? "ON COMMIT PRESERVE ROWS" : "on commit preserve rows");
|
||||
} else if (x.isOnCommitDeleteRows()) {
|
||||
println();
|
||||
print0(ucase ? "PRESERVE ROWS" : "preserve rows");
|
||||
print0(ucase ? "ON COMMIT DELETE ROWS" : "on commit delete rows");
|
||||
}
|
||||
|
||||
if (x.isMonitoring()) {
|
||||
|
||||
Reference in New Issue
Block a user