From 6243809d397a8d2ef8f2873ef88ebc1a36e9cc8e Mon Sep 17 00:00:00 2001 From: kiki Date: Wed, 28 Aug 2013 19:08:40 +0800 Subject: [PATCH 1/2] merge --- .../druid/wall/spi/MySqlWallVisitor.java | 510 +----------------- 1 file changed, 3 insertions(+), 507 deletions(-) diff --git a/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java b/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java index 6d0cb3e2bc..55573923a7 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java +++ b/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java @@ -1,507 +1,3 @@ -<<<<<<< HEAD -/* - * Copyright 1999-2011 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.alibaba.druid.wall.spi; - -import java.util.ArrayList; -import java.util.List; - -import com.alibaba.druid.sql.SQLUtils; -import com.alibaba.druid.sql.ast.SQLCommentHint; -import com.alibaba.druid.sql.ast.SQLName; -import com.alibaba.druid.sql.ast.SQLObject; -import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; -import com.alibaba.druid.sql.ast.expr.SQLInListExpr; -import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; -import com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr; -import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr; -import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr; -import com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement; -import com.alibaba.druid.sql.ast.statement.SQLAssignItem; -import com.alibaba.druid.sql.ast.statement.SQLCallStatement; -import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; -import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement; -import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; -import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement; -import com.alibaba.druid.sql.ast.statement.SQLExprTableSource; -import com.alibaba.druid.sql.ast.statement.SQLInsertStatement; -import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause; -import com.alibaba.druid.sql.ast.statement.SQLSelectItem; -import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock; -import com.alibaba.druid.sql.ast.statement.SQLSelectStatement; -import com.alibaba.druid.sql.ast.statement.SQLSetStatement; -import com.alibaba.druid.sql.ast.statement.SQLUnionQuery; -import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectGroupBy; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowCreateTableStatement; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery; -import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement; -import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor; -import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter; -import com.alibaba.druid.util.JdbcConstants; -import com.alibaba.druid.wall.Violation; -import com.alibaba.druid.wall.WallConfig; -import com.alibaba.druid.wall.WallContext; -import com.alibaba.druid.wall.WallProvider; -import com.alibaba.druid.wall.WallSqlTableStat; -import com.alibaba.druid.wall.WallVisitor; -import com.alibaba.druid.wall.violation.ErrorCode; -import com.alibaba.druid.wall.violation.IllegalSQLObjectViolation; - -public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisitor, MySqlASTVisitor { - - private final WallConfig config; - private final WallProvider provider; - private final List violations = new ArrayList(); - private boolean sqlModified = false; - - public MySqlWallVisitor(WallProvider provider){ - this.config = provider.getConfig(); - this.provider = provider; - } - - @Override - public String getDbType() { - return JdbcConstants.MYSQL; - } - - @Override - public boolean isSqlModified() { - return sqlModified; - } - - @Override - public void setSqlModified(boolean sqlModified) { - this.sqlModified = sqlModified; - } - - @Override - public WallProvider getProvider() { - return provider; - } - - @Override - public WallConfig getConfig() { - return config; - } - - @Override - public void addViolation(Violation violation) { - this.violations.add(violation); - } - - @Override - public List getViolations() { - return violations; - } - - public boolean visit(SQLInListExpr x) { - WallVisitorUtils.check(this, x); - return true; - } - - public boolean visit(SQLBinaryOpExpr x) { - WallVisitorUtils.check(this, x); - return true; - } - - @Override - public boolean visit(SQLSelectQueryBlock x) { - WallVisitorUtils.checkSelelct(this, x); - - return true; - } - - @Override - public boolean visit(MySqlSelectQueryBlock x) { - WallVisitorUtils.checkSelelct(this, x); - return true; - } - - public boolean visit(SQLSelectGroupByClause x) { - WallVisitorUtils.checkHaving(this, x.getHaving()); - return true; - } - - public boolean visit(MySqlSelectGroupBy x) { - WallVisitorUtils.checkHaving(this, x.getHaving()); - return true; - } - - @Override - public boolean visit(MySqlDeleteStatement x) { - WallVisitorUtils.checkReadOnly(this, x.getFrom()); - - return visit((SQLDeleteStatement) x); - } - - @Override - public boolean visit(SQLDeleteStatement x) { - WallVisitorUtils.checkDelete(this, x); - return true; - } - - @Override - public boolean visit(MySqlUpdateStatement x) { - return visit((SQLUpdateStatement) x); - } - - @Override - public boolean visit(SQLUpdateStatement x) { - WallVisitorUtils.initWallTopStatementContext(); - WallVisitorUtils.checkUpdate(this, x); - return true; - } - - @Override - public void endVisit(SQLUpdateStatement x) { - WallVisitorUtils.clearWallTopStatementContext(); - } - - @Override - public boolean visit(MySqlInsertStatement x) { - return visit((SQLInsertStatement) x); - } - - @Override - public boolean visit(SQLInsertStatement x) { - WallVisitorUtils.initWallTopStatementContext(); - WallVisitorUtils.checkInsert(this, x); - return true; - } - - @Override - public void endVisit(SQLInsertStatement x) { - WallVisitorUtils.clearWallTopStatementContext(); - } - - @Override - public boolean visit(SQLSelectStatement x) { - if (!config.isSelelctAllow()) { - this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.SELECT_NOT_ALLOW, "select not allow", - this.toSQL(x))); - return false; - } - - WallVisitorUtils.initWallTopStatementContext(); - return true; - } - - @Override - public void endVisit(SQLSelectStatement x) { - WallVisitorUtils.clearWallTopStatementContext(); - } - - @Override - public boolean visit(Limit x) { - if (x.getRowCount() instanceof SQLNumericLiteralExpr) { - WallContext context = WallContext.current(); - - int rowCount = ((SQLNumericLiteralExpr) x.getRowCount()).getNumber().intValue(); - if (rowCount == 0) { - if (context != null) { - context.incrementWarnnings(); - } - - if (!provider.getConfig().isLimitZeroAllow()) { - this.getViolations().add(new IllegalSQLObjectViolation(ErrorCode.LIMIT_ZERO, "limit row 0", - this.toSQL(x))); - } - } - } - return true; - } - - public boolean visit(SQLPropertyExpr x) { - if (x.getOwner() instanceof SQLVariantRefExpr) { - SQLVariantRefExpr varExpr = (SQLVariantRefExpr) x.getOwner(); - SQLObject parent = x.getParent(); - String varName = varExpr.getName(); - if (varName.equalsIgnoreCase("@@session") || varName.equalsIgnoreCase("@@global")) { - if (!(parent instanceof SQLSelectItem) && !(parent instanceof SQLAssignItem)) { - violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, - "variable in condition not allow", toSQL(x))); - return false; - } - - if (!checkVar(x.getParent(), x.getName())) { - boolean isTop = WallVisitorUtils.isTopNoneFromSelect(this, x); - if (!isTop) { - boolean allow = true; - if (WallVisitorUtils.isWhereOrHaving(x) && isDeny(varName)) { - allow = false; - } - - if (!allow) { - violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, - "variable not allow : " + x.getName(), - toSQL(x))); - } - } - } - return false; - } - } - - WallVisitorUtils.check(this, x); - return true; - } - - public boolean checkVar(SQLObject parent, String varName) { - if (varName == null) { - return false; - } - - if (varName.equals("?")) { - return true; - } - - if (!config.isVariantCheck()) { - return true; - } - - if (varName.startsWith("@@")) { - if (!(parent instanceof SQLSelectItem) && !(parent instanceof SQLAssignItem)) { - return false; - } - - varName = varName.substring(2); - } - - if (config.getPermitVariants().contains(varName)) { - return true; - } - - return false; - } - - public boolean isDeny(String varName) { - if (varName.startsWith("@@")) { - varName = varName.substring(2); - } - - varName = varName.toLowerCase(); - return config.getDenyVariants().contains(varName); - } - - public boolean visit(SQLVariantRefExpr x) { - String varName = x.getName(); - if (varName == null) { - return false; - } - - if (varName.startsWith("@@") && !checkVar(x.getParent(), x.getName())) { - boolean isTop = WallVisitorUtils.isTopNoneFromSelect(this, x); - if (!isTop) { - boolean allow = true; - if (WallVisitorUtils.isWhereOrHaving(x) && isDeny(varName)) { - allow = false; - } - - if (!allow) { - violations.add(new IllegalSQLObjectViolation(ErrorCode.VARIANT_DENY, "variable not allow : " - + x.getName(), toSQL(x))); - } - } - } - - return false; - } - - @Override - public boolean visit(SQLMethodInvokeExpr x) { - WallVisitorUtils.checkFunction(this, x); - - return true; - } - - public boolean visit(SQLExprTableSource x) { - WallVisitorUtils.check(this, x); - - if (x.getExpr() instanceof SQLName) { - return false; - } - - return true; - } - - @Override - public boolean visit(MySqlOutFileExpr x) { - if (!config.isSelectIntoOutfileAllow()) { - violations.add(new IllegalSQLObjectViolation(ErrorCode.INTO_OUTFILE, "into out file not allow", toSQL(x))); - } - - return true; - } - - @Override - public boolean visit(SQLUnionQuery x) { - WallVisitorUtils.checkUnion(this, x); - - return true; - } - - @Override - public boolean visit(MySqlUnionQuery x) { - WallVisitorUtils.checkUnion(this, x); - - return true; - } - - @Override - public String toSQL(SQLObject obj) { - return SQLUtils.toMySqlString(obj); - } - - @Override - public boolean isDenyTable(String name) { - if (!config.isTableCheck()) { - return false; - } - - return !this.provider.checkDenyTable(name); - } - - public void preVisit(SQLObject x) { - WallVisitorUtils.preVisitCheck(this, x); - } - - @Override - public boolean visit(SQLSelectItem x) { - WallVisitorUtils.check(this, x); - return true; - } - - @Override - public boolean visit(SQLCreateTableStatement x) { - WallVisitorUtils.check(this, x); - return true; - } - - @Override - public boolean visit(MySqlCreateTableStatement x) { - WallVisitorUtils.check(this, x); - return true; - } - - public boolean visit(SQLAlterTableStatement x) { - WallVisitorUtils.check(this, x); - return true; - } - - @Override - public boolean visit(MySqlAlterTableStatement x) { - WallVisitorUtils.check(this, x); - return true; - } - - public boolean visit(SQLDropTableStatement x) { - WallVisitorUtils.check(this, x); - return true; - } - - @Override - public boolean visit(SQLSetStatement x) { - return false; - } - - @Override - public boolean visit(MySqlReplaceStatement x) { - return true; - } - - @Override - public boolean visit(SQLCallStatement x) { - return false; - } - - @Override - public boolean visit(SQLCommentHint x) { - String text = x.getText(); - text = text.trim(); - if (text.startsWith("!")) { - text = text.substring(1); - } - - if (text.length() == 0) { - return true; - } - - if (Character.isDigit(text.charAt(0))) { - addViolation(new IllegalSQLObjectViolation(ErrorCode.EVIL_HINTS, "evil hints", SQLUtils.toMySqlString(x))); - } - - text = text.toLowerCase(); - - if (text.indexOf(';') != -1 // - || text.indexOf("or") != -1 // - || text.indexOf("and") != -1 // - || text.indexOf("union") != -1 // - - || text.indexOf("select") != -1 // - || text.indexOf("delete") != -1 // - || text.indexOf("insert") != -1 // - || text.indexOf("update") != -1 // - - || text.indexOf("create") != -1 // - || text.indexOf("drop") != -1 // - || text.indexOf("alter") != -1 // - || text.indexOf("truncate") != -1 // - - || text.indexOf("information_schema") != -1 // - || text.indexOf("mysql") != -1 // - || text.indexOf("performance_schema") != -1 // - - || text.indexOf("sleep") != -1 // - || text.indexOf("benchmark") != -1 // - || text.indexOf("load_file") != -1 // - ) { - addViolation(new IllegalSQLObjectViolation(ErrorCode.EVIL_HINTS, "evil hints", SQLUtils.toMySqlString(x))); - } - - return true; - } - - @Override - public boolean visit(MySqlShowCreateTableStatement x) { - String tableName = ((SQLName) x.getName()).getSimleName(); - WallContext context = WallContext.current(); - if (context != null) { - WallSqlTableStat tableStat = context.getTableStat(tableName); - if (tableStat != null) { - tableStat.incrementShowCount(); - } - } - return false; - } - - @Override - public boolean visit(SQLCreateTriggerStatement x) { - return false; - } -} -======= /* * Copyright 1999-2011 Alibaba Group Holding Ltd. * @@ -956,7 +452,7 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi } text = text.toLowerCase(); - + for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); switch (ch) { @@ -968,7 +464,8 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi case '|': case '^': case '\n': - addViolation(new IllegalSQLObjectViolation(ErrorCode.EVIL_HINTS, "evil hints", SQLUtils.toMySqlString(x))); + addViolation(new IllegalSQLObjectViolation(ErrorCode.EVIL_HINTS, "evil hints", + SQLUtils.toMySqlString(x))); default: break; } @@ -1021,4 +518,3 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi return false; } } ->>>>>>> upstream/master From aad2c221fbfad01bff75d520aa16b1b07d41b50a Mon Sep 17 00:00:00 2001 From: kiki Date: Tue, 3 Sep 2013 14:26:45 +0800 Subject: [PATCH 2/2] improve sql wall --- .../druid/wall/spi/WallVisitorUtils.java | 38 +++++++++++++++++-- .../bvt/filter/wall/MySqlWallTest91.java | 9 +++++ .../bvt/filter/wall/SQLServerWallTest_0.java | 9 +++-- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java index 6c93a2e95f..9c6182419e 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java +++ b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java @@ -189,7 +189,7 @@ public class WallVisitorUtils { SQLExpr expr = x.getExpr(); if (expr instanceof SQLVariantRefExpr) { - if ("@".equals(((SQLVariantRefExpr) expr).getName())) { + if (!isTopSelectStatement(expr) && "@".equals(((SQLVariantRefExpr) expr).getName())) { addViolation(visitor, ErrorCode.EVIL_NAME, "@ not allow", x); } } @@ -1057,7 +1057,7 @@ public class WallVisitorUtils { leftIsName = true; } } - + if ((!leftIsName) && caseExpr.getItems().size() > 0) { SQLCaseExpr.Item item = caseExpr.getItems().get(0); Object conditionVal = getValue(visitor, item.getConditionExpr()); @@ -1072,7 +1072,7 @@ public class WallVisitorUtils { return null; } - + public static Object eval(String dbType, SQLObject sqlObject, List parameters) { SQLEvalVisitor visitor = SQLEvalVisitorUtils.createEvalVisitor(dbType); visitor.setParameters(parameters); @@ -1455,6 +1455,38 @@ public class WallVisitorUtils { return false; } + private static boolean isTopSelectStatement(SQLObject x) { + + for (;;) { + if ((x.getParent() instanceof SQLExpr) || (x.getParent() instanceof Item)) { + x = x.getParent(); + } else { + break; + } + } + + if (!(x.getParent() instanceof SQLSelectItem)) { + return false; + } + SQLSelectItem item = (SQLSelectItem) x.getParent(); + if (!(item.getParent() instanceof SQLSelectQueryBlock)) { + return false; + } + + SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) item.getParent(); + if (!(queryBlock.getParent() instanceof SQLSelect)) { + return false; + } + + SQLSelect select = (SQLSelect) queryBlock.getParent(); + if (!(select.getParent() instanceof SQLSelectStatement)) { + return false; + } + + SQLSelectStatement stmt = (SQLSelectStatement) select.getParent(); + return stmt.getParent() == null; + } + public static boolean check(WallVisitor visitor, SQLExprTableSource x) { final WallTopStatementContext topStatementContext = wallTopStatementContextLocal.get(); diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest91.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest91.java index 939af92cc7..f6816afb9b 100644 --- a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest91.java +++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest91.java @@ -43,6 +43,7 @@ public class MySqlWallTest91 extends TestCase { provider.getConfig().setSchemaCheck(true); provider.getConfig().setLimitZeroAllow(true); provider.getConfig().setCommentAllow(true); + provider.getConfig().setConditionDoubleConstAllow(true); return provider; } @@ -151,6 +152,14 @@ public class MySqlWallTest91 extends TestCase { } } + public void test_true4() { + WallProvider provider = initWallProvider(); + { + String sql = "SELECT 10006,@"; + Assert.assertTrue(provider.checkValid(sql)); + } + } + public void test_true() throws Exception { WallProvider provider = initWallProvider(); { diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/SQLServerWallTest_0.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/SQLServerWallTest_0.java index 71456fc4e2..ba6a2707a3 100644 --- a/src/test/java/com/alibaba/druid/bvt/filter/wall/SQLServerWallTest_0.java +++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/SQLServerWallTest_0.java @@ -43,6 +43,7 @@ public class SQLServerWallTest_0 extends TestCase { provider.getConfig().setSchemaCheck(true); provider.getConfig().setLimitZeroAllow(true); provider.getConfig().setCommentAllow(true); + provider.getConfig().setConditionDoubleConstAllow(true); return provider; } @@ -119,10 +120,10 @@ public class SQLServerWallTest_0 extends TestCase { WallProvider provider = initWallProvider(); { String sql = "SELECT tableid, chnname "// - + "FROM r_temptable "// - + "INNER JOIN sys_func_pwr ss ON r_temptable.tableid = ss.mainid "// - + "INNER JOIN sys_func_pwr sys ON ss.parentid = sys.funcid " // - + "WHERE (ismaintable = 1) and 1=1 and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 550) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 551) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 391) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 552) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 393) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 396) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 4628) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 4836) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 394) AND (functype = 8) AND (Closed = 0))) and ss.funcid <> 4298 and ss.funcid <> 7441 AND (ss.funcid IN (SELECT DISTINCT funcid FROM sys_func_pwr WHERE (functype = 8) AND (Closed = 0) )) ORDER BY sys.sortflag ,ss.sortflag "; + + "FROM r_temptable "// + + "INNER JOIN sys_func_pwr ss ON r_temptable.tableid = ss.mainid "// + + "INNER JOIN sys_func_pwr sys ON ss.parentid = sys.funcid " // + + "WHERE (ismaintable = 1) and 1=1 and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 550) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 551) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 391) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 552) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 393) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 396) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 4628) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 4836) AND (functype = 8) AND (Closed = 0))) and (r_temptable.tableid NOT IN (SELECT DISTINCT mainid FROM sys_func_pwr WHERE (parentid = 394) AND (functype = 8) AND (Closed = 0))) and ss.funcid <> 4298 and ss.funcid <> 7441 AND (ss.funcid IN (SELECT DISTINCT funcid FROM sys_func_pwr WHERE (functype = 8) AND (Closed = 0) )) ORDER BY sys.sortflag ,ss.sortflag "; Assert.assertTrue(provider.checkValid(sql)); } }