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:
+90
-7
@@ -23,6 +23,8 @@ import com.alibaba.druid.sql.dialect.oracle.ast.OracleDataTypeIntervalYear;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.clause.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.expr.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleFunctionDataType;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleProcedureDataType;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGBoxExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
|
||||
@@ -2000,20 +2002,101 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
||||
print0(ucase ? "CREATE TYPE " : "create type ");
|
||||
}
|
||||
|
||||
if (x.isBody()) {
|
||||
print0(ucase ? "BODY " : "body ");
|
||||
}
|
||||
|
||||
x.getName().accept(this);
|
||||
|
||||
SQLName under = x.getUnder();
|
||||
if (under != null) {
|
||||
print0(ucase ? " UNDER " : " under ");
|
||||
under.accept(this);
|
||||
}
|
||||
|
||||
SQLName authId = x.getAuthId();
|
||||
if (authId != null) {
|
||||
print0(ucase ? " AUTHID " : " authid ");
|
||||
authId.accept(this);
|
||||
}
|
||||
|
||||
if (x.isForce()) {
|
||||
print0(ucase ? "FORCE " : "force ");
|
||||
}
|
||||
|
||||
print0(" AS OBJECT (");
|
||||
indentCount++;
|
||||
println();
|
||||
printlnAndAccept(x.getParameters(), ", ");
|
||||
List<SQLParameter> parameters = x.getParameters();
|
||||
SQLDataType tableOf = x.getTableOf();
|
||||
|
||||
if (x.isObject()) {
|
||||
print0(" AS OBJECT");
|
||||
}
|
||||
|
||||
if (parameters.size() > 0) {
|
||||
if (x.isParen()) {
|
||||
print(" (");
|
||||
} else {
|
||||
print0(ucase ? " IS" : " is");
|
||||
}
|
||||
indentCount++;
|
||||
println();
|
||||
|
||||
for (int i = 0; i < parameters.size(); ++i) {
|
||||
SQLParameter param = parameters.get(i);
|
||||
param.accept(this);
|
||||
|
||||
SQLDataType dataType = param.getDataType();
|
||||
|
||||
if (i < parameters.size() - 1) {
|
||||
if (dataType instanceof OracleFunctionDataType
|
||||
&& ((OracleFunctionDataType) dataType).getBlock() != null) {
|
||||
// skip
|
||||
println();
|
||||
} else if (dataType instanceof OracleProcedureDataType
|
||||
&& ((OracleProcedureDataType) dataType).getBlock() != null) {
|
||||
// skip
|
||||
println();
|
||||
} else {
|
||||
println(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indentCount--;
|
||||
println();
|
||||
|
||||
if (x.isParen()) {
|
||||
print0(")");
|
||||
} else {
|
||||
print0("END");
|
||||
}
|
||||
} else if (tableOf != null) {
|
||||
print0(ucase ? " AS TABLE OF " : " as table of ");
|
||||
tableOf.accept(this);
|
||||
} else if (x.getVarraySizeLimit() != null) {
|
||||
print0(ucase ? " VARRAY (" : " varray (");
|
||||
x.getVarraySizeLimit().accept(this);
|
||||
print0(ucase ? ") OF " : ") of ");
|
||||
x.getVarrayDataType().accept(this);
|
||||
}
|
||||
|
||||
Boolean isFinal = x.getFinal();
|
||||
if (isFinal != null) {
|
||||
if (isFinal.booleanValue()) {
|
||||
print0(ucase ? " FINAL" : " final");
|
||||
} else {
|
||||
print0(ucase ? " NOT FINAL" : " not final");
|
||||
}
|
||||
}
|
||||
|
||||
Boolean instantiable = x.getInstantiable();
|
||||
if (instantiable != null) {
|
||||
if (instantiable.booleanValue()) {
|
||||
print0(ucase ? " INSTANTIABLE" : " instantiable");
|
||||
} else {
|
||||
print0(ucase ? " NOT INSTANTIABLE" : " not instantiable");
|
||||
}
|
||||
}
|
||||
|
||||
indentCount--;
|
||||
println();
|
||||
print0(")");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user