improve sqlwall: 'hints' and 'start transaction'

This commit is contained in:
Yako
2014-09-03 16:31:37 +08:00
parent 3d8031552a
commit 9b58d41f69
11 changed files with 137 additions and 7 deletions
@@ -17,8 +17,11 @@ public class MySqlWallTest_hint extends TestCase {
}
public void test_false_1() throws Exception {
WallConfig config = new WallConfig();
config.setHintAllow(true);
config.setMultiStatementAllow(true);
String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
Assert.assertFalse(WallUtils.isValidateMySql(sql)); //
Assert.assertFalse(WallUtils.isValidateMySql(sql, config)); //
}
public void test_true() throws Exception {
@@ -77,4 +80,19 @@ public class MySqlWallTest_hint extends TestCase {
Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
}
public void test_true_6() throws Exception {
String sql = "START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */";
Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
}
public void test_true_7() throws Exception {
String sql = "LOCK TABLES `m_rpt_adgroupeffect` READ /*!32311 LOCAL */";
Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
}
public void test_true_8() throws Exception {
String sql = "SET SQL_QUOTE_SHOW_CREATE=1/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */";
Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
}
}