mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support EnterpriseDB.
This commit is contained in:
@@ -23,6 +23,7 @@ import com.alibaba.druid.sql.ast.statement.SQLDescribeStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLObjectType;
|
||||
import com.alibaba.druid.sql.dialect.odps.visitor.OdpsASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class OdpsDescStmt extends SQLDescribeStatement {
|
||||
|
||||
@@ -30,6 +31,10 @@ public class OdpsDescStmt extends SQLDescribeStatement {
|
||||
|
||||
private List<SQLExpr> partition = new ArrayList<SQLExpr>();
|
||||
|
||||
public OdpsDescStmt() {
|
||||
this.setDbType(JdbcConstants.ODPS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((OdpsASTVisitor) visitor);
|
||||
|
||||
@@ -53,7 +53,8 @@ public class SQLParserUtils {
|
||||
return new MySqlStatementParser(sql);
|
||||
}
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGSQLStatementParser(sql);
|
||||
}
|
||||
|
||||
@@ -91,7 +92,8 @@ public class SQLParserUtils {
|
||||
return new MySqlExprParser(sql);
|
||||
}
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGExprParser(sql);
|
||||
}
|
||||
|
||||
@@ -125,7 +127,8 @@ public class SQLParserUtils {
|
||||
return new MySqlLexer(sql);
|
||||
}
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGLexer(sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,12 @@ public final class ExportParameterVisitorUtils {
|
||||
if (JdbcUtils.H2.equals(dbType)) {
|
||||
return new MySqlExportParameterVisitor(out);
|
||||
}
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGExportParameterVisitor(out);
|
||||
}
|
||||
|
||||
if (JdbcUtils.SQL_SERVER.equals(dbType) || JdbcUtils.JTDS.equals(dbType)) {
|
||||
return new MSSQLServerExportParameterVisitor(out);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ public class ParameterizedOutputVisitorUtils {
|
||||
return new MySqlOutputVisitor(out, true);
|
||||
}
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGOutputVisitor(out, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ import com.alibaba.druid.sql.visitor.functions.Trim;
|
||||
import com.alibaba.druid.sql.visitor.functions.Ucase;
|
||||
import com.alibaba.druid.sql.visitor.functions.Unhex;
|
||||
import com.alibaba.druid.util.HexBin;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils;
|
||||
@@ -167,7 +168,8 @@ public class SQLEvalVisitorUtils {
|
||||
return new OracleEvalVisitor();
|
||||
}
|
||||
|
||||
if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
if (JdbcConstants.POSTGRESQL.equals(dbType)
|
||||
|| JdbcConstants.ENTERPRISE_DB.equals(dbType)) {
|
||||
return new PGEvalVisitor();
|
||||
}
|
||||
|
||||
|
||||
@@ -88,4 +88,7 @@ public interface JdbcConstants {
|
||||
|
||||
public static final String PHOENIX = "phoenix";
|
||||
public static final String PHOENIX_DRIVER = "org.apache.phoenix.jdbc.PhoenixDriver";
|
||||
|
||||
public static final String ENTERPRISE_DB = "edb";
|
||||
public static final String ENTERPRISE_DB_DRIVER = "com.edb.Driver";
|
||||
}
|
||||
|
||||
@@ -396,6 +396,8 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
return "com.alibaba.druid.mock.MockDriver";
|
||||
} else if (rawUrl.startsWith("jdbc:postgresql:")) {
|
||||
return POSTGRESQL_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:edb:")) {
|
||||
return ENTERPRISE_DB_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:odps:")) {
|
||||
return ODPS_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:hsqldb:")) {
|
||||
@@ -479,6 +481,8 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
return MOCK;
|
||||
} else if (rawUrl.startsWith("jdbc:postgresql:") || rawUrl.startsWith("jdbc:log4jdbc:postgresql:")) {
|
||||
return POSTGRESQL;
|
||||
} else if (rawUrl.startsWith("jdbc:edb:")) {
|
||||
return ENTERPRISE_DB;
|
||||
} else if (rawUrl.startsWith("jdbc:hsqldb:") || rawUrl.startsWith("jdbc:log4jdbc:hsqldb:")) {
|
||||
return HSQL;
|
||||
} else if (rawUrl.startsWith("jdbc:odps:")) {
|
||||
|
||||
@@ -144,7 +144,8 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
||||
}
|
||||
|
||||
provider = new SQLServerWallProvider(config);
|
||||
} else if (JdbcUtils.POSTGRESQL.equals(dbType)) {
|
||||
} else if (JdbcUtils.POSTGRESQL.equals(dbType)
|
||||
|| JdbcUtils.ENTERPRISE_DB.equals(dbType)) {
|
||||
if (config == null) {
|
||||
config = new WallConfig(PGWallProvider.DEFAULT_CONFIG_DIR);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class OdpsDescTest extends TestCase {
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toOdpsString(stmt);
|
||||
stmt.toString();
|
||||
System.out.println(output);
|
||||
Assert.assertEquals("DESC coupon_dataset_4_feature", output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user