use of com.alibaba.druid.wall.spi.PGWallProvider in project druid by alibaba.
the class WallStatTest_delete method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getDeleteCount());
}
use of com.alibaba.druid.wall.spi.PGWallProvider in project druid by alibaba.
the class PGShowTest method test_0.
public void test_0() throws Exception {
String sql = "SHOW max_identifier_length";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
{
WallProvider provider = new PGWallProvider();
Assert.assertTrue(provider.checkValid(sql));
}
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("reviews")));
//Assert.assertTrue(visitor.getTables().get(new TableStat.Name("reviews")).getAlterCount() == 1);
//Assert.assertTrue(visitor.getColumns().size() == 1);
}
use of com.alibaba.druid.wall.spi.PGWallProvider in project druid by alibaba.
the class WallFilter method init.
@Override
public synchronized void init(DataSourceProxy dataSource) {
if (null == dataSource) {
LOG.error("dataSource should not be null");
return;
}
if (this.dbType == null || this.dbType.trim().length() == 0) {
if (dataSource.getDbType() != null) {
this.dbType = dataSource.getDbType();
} else {
this.dbType = JdbcUtils.getDbType(dataSource.getRawJdbcUrl(), "");
}
}
if (dbType == null) {
dbType = JdbcUtils.getDbType(dataSource.getUrl(), null);
}
if (//
JdbcUtils.MYSQL.equals(dbType) || //
JdbcUtils.MARIADB.equals(dbType) || JdbcUtils.H2.equals(dbType)) {
if (config == null) {
config = new WallConfig(MySqlWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new MySqlWallProvider(config);
} else if (JdbcUtils.ORACLE.equals(dbType) || JdbcUtils.ALI_ORACLE.equals(dbType)) {
if (config == null) {
config = new WallConfig(OracleWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new OracleWallProvider(config);
} else if (JdbcUtils.SQL_SERVER.equals(dbType) || JdbcUtils.JTDS.equals(dbType)) {
if (config == null) {
config = new WallConfig(SQLServerWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new SQLServerWallProvider(config);
} else if (JdbcUtils.POSTGRESQL.equals(dbType) || JdbcUtils.ENTERPRISEDB.equals(dbType)) {
if (config == null) {
config = new WallConfig(PGWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new PGWallProvider(config);
} else if (JdbcUtils.DB2.equals(dbType)) {
if (config == null) {
config = new WallConfig(DB2WallProvider.DEFAULT_CONFIG_DIR);
}
provider = new DB2WallProvider(config);
} else {
throw new IllegalStateException("dbType not support : " + dbType + ", url " + dataSource.getUrl());
}
provider.setName(dataSource.getName());
this.inited = true;
}
use of com.alibaba.druid.wall.spi.PGWallProvider in project druid by alibaba.
the class WallStatTest_update method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getUpdateCount());
}
use of com.alibaba.druid.wall.spi.PGWallProvider in project druid by alibaba.
the class WallStatTest_select method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getSelectCount());
}
Aggregations