Skip to content

Commit

Permalink
优化适配 适配gaussdb alibaba#5845
Browse files Browse the repository at this point in the history
优化适配 适配gaussdb alibaba#5845
  • Loading branch information
lizongbo committed Apr 16, 2024
1 parent c0f62d2 commit 4916f86
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public static SQLStatementParser createSQLStatementParser(String sql, DbType dbT
case mysql:
case tidb:
case mariadb:
case goldendb:
case oceanbase:
case drds: {
return new MySqlStatementParser(sql, features);
}
Expand All @@ -130,6 +132,7 @@ public static SQLStatementParser createSQLStatementParser(String sql, DbType dbT
case postgresql:
case greenplum:
case edb:
case gaussdb:
return new PGSQLStatementParser(sql, features);
case sqlserver:
case jtds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,17 @@ public static ParameterizedVisitor createParameterizedOutputVisitor(StringBuilde
case mysql:
case tidb:
case mariadb:
case goldendb:
case oceanbase:
case drds:
case elastic_search:
return new MySqlOutputVisitor(out, true);
case h2:
return new H2OutputVisitor(out, true);
case postgresql:
case greenplum:
case edb:
case gaussdb:
return new PGOutputVisitor(out, true);
case sqlserver:
case jtds:
Expand Down
50 changes: 50 additions & 0 deletions core/src/test/java/com/alibaba/druid/bvt/bug/Issue5845.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.alibaba.druid.bvt.bug;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;

import junit.framework.TestCase;

/**
*
*/
public class Issue5845 extends TestCase {

public void test_for_issue() throws Exception {
String sql = "delete from table01 t where t.id=1";
List<DbType> dbTypes = new ArrayList<>();
for (DbType dbType : DbType.values()) {
try {
String mergeSql = ParameterizedOutputVisitorUtils.parameterize(sql, dbType);
System.out.println(dbType + "==" + mergeSql);
dbTypes.add(dbType);
} catch (Exception e) {
System.out.println(dbType + "==" + e.getMessage());
}
}
for (DbType dbT : dbTypes) {
System.out.println("DbType." + dbT + ",");
}
for (DbType dbType : new DbType[]{DbType.db2,
DbType.postgresql,
DbType.oracle,
DbType.mysql,
DbType.mariadb,
DbType.oceanbase,
DbType.edb,
DbType.elastic_search,
DbType.drds,
DbType.oceanbase_oracle,
DbType.greenplum,
DbType.gaussdb,
DbType.tidb,
DbType.goldendb,}) {
String mergeSql = ParameterizedOutputVisitorUtils.parameterize(sql, dbType);
System.out.println(dbType + "==" + mergeSql);
dbTypes.add(dbType);
}
}
}

0 comments on commit 4916f86

Please sign in to comment.