From 846b9bb816e3c0971d18256445f2ff0e9c0d5ec9 Mon Sep 17 00:00:00 2001 From: wenshao Date: Mon, 30 May 2011 03:31:50 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8F=82=E6=95=B0=E4=B8=8D?= =?UTF-8?q?=E5=BD=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/druid/trunk@213 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../alibaba/druid/jconsole/DruidPanel.java | 76 +++++++++++++++++-- .../druid/pool/DruidAbstractDataSource.java | 3 + .../druid/pool/DruidDataSourceMBean.java | 2 + .../MySqlParameterizedOutputVisitor.java | 51 ++++++++++--- .../OracleParameterizedOutputVisitor.java | 50 +++++++++--- .../MySqlParameterizedOutputVisitorTest.java | 21 ++++- .../bvt/parser/MySqlParserResourceTest.java | 38 ++++++++-- src/test/resources/bvt/parser/mysql-10.txt | 10 +++ src/test/resources/bvt/parser/mysql-9.txt | 51 +++---------- 9 files changed, 222 insertions(+), 80 deletions(-) create mode 100644 src/test/resources/bvt/parser/mysql-10.txt diff --git a/src/main/java/com/alibaba/druid/jconsole/DruidPanel.java b/src/main/java/com/alibaba/druid/jconsole/DruidPanel.java index 8074dc37eb..78b8913f8f 100644 --- a/src/main/java/com/alibaba/druid/jconsole/DruidPanel.java +++ b/src/main/java/com/alibaba/druid/jconsole/DruidPanel.java @@ -2,7 +2,10 @@ package com.alibaba.druid.jconsole; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Dimension; +import java.lang.management.ManagementFactory; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -10,21 +13,27 @@ import java.util.Set; import javax.management.MBeanInfo; import javax.management.MBeanServerConnection; import javax.management.ObjectInstance; +import javax.management.ObjectName; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.stat.JdbcStatManager; import com.sun.tools.jconsole.JConsoleContext; public class DruidPanel extends JPanel { - protected JSplitPane mainSplit; - protected JTree tree; - protected JPanel sheet; + private static final long serialVersionUID = 1L; - private static final long serialVersionUID = 1L; + protected JSplitPane mainSplit; + protected JTree tree; + protected JPanel sheet; + protected DefaultMutableTreeNode rootNode; + protected DefaultMutableTreeNode dataSourcesNode; public DruidPanel(){ setLayout(new BorderLayout()); @@ -33,7 +42,12 @@ public class DruidPanel extends JPanel { mainSplit.setDividerLocation(160); mainSplit.setBorder(BorderFactory.createEmptyBorder()); - tree = new JTree(); + rootNode = new DefaultMutableTreeNode("root", true); + dataSourcesNode = new DefaultMutableTreeNode("DataSources", true); + rootNode.add(dataSourcesNode); + + tree = new JTree(rootNode); + tree.setRootVisible(false); JScrollPane theScrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel treePanel = new JPanel(new BorderLayout()); @@ -46,22 +60,51 @@ public class DruidPanel extends JPanel { add(mainSplit); this.setBackground(Color.BLUE); + + init(); } public void init() { + try { + ManagementFactory.getPlatformMBeanServer().registerMBean(JdbcStatManager.getInstance(), new ObjectName("com.alibaba.druid:type=JdbcStatManager")); + DruidDataSource dataSource = new DruidDataSource(); + + ManagementFactory.getPlatformMBeanServer().registerMBean(dataSource, new ObjectName("com.alibaba.druid:type=DataSource")); + + dataSource.setUrl("jdbc:mock:"); + dataSource.setFilters("stat,trace"); + + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT 1"); + while (rs.next()) { + + } + rs.close(); + stmt.close(); + conn.close(); + } catch (Exception ex) { + + } } protected Object doInBackground(JConsoleContext context) throws Exception { MBeanServerConnection conn = context.getMBeanServerConnection(); List stats = new ArrayList(); + List dataSourceInstances = new ArrayList(); Set instances = conn.queryMBeans(null, null); for (ObjectInstance instance : instances) { MBeanInfo info = conn.getMBeanInfo(instance.getObjectName()); if ("com.alibaba.druid.stat.JdbcStatManager".equals(info.getClassName())) { stats.add(instance); - break; + continue; + } + + if ("com.alibaba.druid.pool.DruidDataSource".equals(info.getClassName())) { + dataSourceInstances.add(instance); + continue; } } @@ -69,7 +112,24 @@ public class DruidPanel extends JPanel { } - this.setPreferredSize(new Dimension(400, 500)); + for (ObjectInstance dataSourceInstance : dataSourceInstances) { + String name = (String) conn.getAttribute(dataSourceInstance.getObjectName(), "Name"); + + DefaultMutableTreeNode dataSource = new DefaultMutableTreeNode(name, true); + + DefaultMutableTreeNode connections = new DefaultMutableTreeNode("Connections", true); + { + } + dataSource.add(connections); + + DefaultMutableTreeNode sqlListNode = new DefaultMutableTreeNode("SQL", true); + { + + } + dataSource.add(sqlListNode); + + dataSourcesNode.add(dataSource); + } return null; } diff --git a/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java b/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java index 67ce0638d7..4fc1556d16 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java @@ -385,6 +385,9 @@ public abstract class DruidAbstractDataSource implements DataSource, DataSourceP } public String getName() { + if (name == null) { + return "DataSource-" + System.identityHashCode(this); + } return name; } diff --git a/src/main/java/com/alibaba/druid/pool/DruidDataSourceMBean.java b/src/main/java/com/alibaba/druid/pool/DruidDataSourceMBean.java index f7cbc23189..2a6012fad1 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidDataSourceMBean.java +++ b/src/main/java/com/alibaba/druid/pool/DruidDataSourceMBean.java @@ -21,6 +21,8 @@ import java.util.List; * @author wenshao */ public interface DruidDataSourceMBean { + + String getName(); int getInitialSize(); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlParameterizedOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlParameterizedOutputVisitor.java index 9ab05add99..250464c7cf 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlParameterizedOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlParameterizedOutputVisitor.java @@ -9,11 +9,14 @@ import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr; import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr; import com.alibaba.druid.sql.ast.expr.SQLNCharExpr; import com.alibaba.druid.sql.ast.expr.SQLNumberExpr; +import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr; import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr; import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement; public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor { + private static final String ATTR_PARAMS_SKIP = "_params.skip_"; + public MySqlParameterizedOutputVisitor(Appendable appender){ super(appender); } @@ -26,30 +29,27 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor { x.getExpr().accept(this); if (x.isNot()) { - print(" NOT IN (##)"); + print(" NOT IN (?)"); } else { - print(" IN (##)"); + print(" IN (?)"); } return false; } public boolean visit(SQLBinaryOpExpr x) { - if (x.getLeft() instanceof SQLLiteralExpr && x.getRight() instanceof SQLLiteralExpr) { - print(x.getLeft().toString()); - print(' '); - print(x.getOperator().name); - print(' '); - print(x.getRight().toString()); - return false; - } - x = merge(x); return super.visit(x); } public SQLBinaryOpExpr merge(SQLBinaryOpExpr x) { + if (x.getLeft() instanceof SQLLiteralExpr && x.getRight() instanceof SQLLiteralExpr) { + x.getLeft().getAttributes().put(ATTR_PARAMS_SKIP, true); + x.getRight().getAttributes().put(ATTR_PARAMS_SKIP, true); + return x; + } + if (x.getRight() instanceof SQLLiteralExpr) { x = new SQLBinaryOpExpr(x.getLeft(), x.getOperator(), new SQLVariantRefExpr("?")); } @@ -63,7 +63,7 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor { } if (x.getLeft() instanceof SQLBinaryOpExpr) { - x = new SQLBinaryOpExpr((SQLBinaryOpExpr) x.getLeft(), x.getOperator(), x.getRight()); + x = new SQLBinaryOpExpr(merge((SQLBinaryOpExpr) x.getLeft()), x.getOperator(), x.getRight()); } // ID = ? OR ID = ? => ID = ? @@ -83,6 +83,17 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor { } } } + + if ((left.getLeft() instanceof SQLPropertyExpr) && (right.getLeft() instanceof SQLPropertyExpr)) { + String leftColumn = left.getLeft().toString(); + String rightColumn = right.getLeft().toString(); + + if (leftColumn.equals(rightColumn)) { + if ((left.getRight() instanceof SQLVariantRefExpr) && (right.getRight() instanceof SQLVariantRefExpr)) { + return left; // merge + } + } + } } } } @@ -91,21 +102,37 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor { } public boolean visit(SQLIntegerExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLNumberExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLCharExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLNCharExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/visitor/OracleParameterizedOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/visitor/OracleParameterizedOutputVisitor.java index a3b4df9e1a..c185269cf2 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/visitor/OracleParameterizedOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/visitor/OracleParameterizedOutputVisitor.java @@ -9,10 +9,12 @@ import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr; import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr; import com.alibaba.druid.sql.ast.expr.SQLNCharExpr; import com.alibaba.druid.sql.ast.expr.SQLNumberExpr; +import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr; import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr; public class OracleParameterizedOutputVisitor extends OracleOutputVisitor { - + private static final String ATTR_PARAMS_SKIP = "_params.skip_"; + public OracleParameterizedOutputVisitor(Appendable appender){ super(appender); } @@ -25,30 +27,27 @@ public class OracleParameterizedOutputVisitor extends OracleOutputVisitor { x.getExpr().accept(this); if (x.isNot()) { - print(" NOT IN (##)"); + print(" NOT IN (?)"); } else { - print(" IN (##)"); + print(" IN (?)"); } return false; } public boolean visit(SQLBinaryOpExpr x) { - if (x.getLeft() instanceof SQLLiteralExpr && x.getRight() instanceof SQLLiteralExpr) { - print(x.getLeft().toString()); - print(' '); - print(x.getOperator().name); - print(' '); - print(x.getRight().toString()); - return false; - } - x = merge(x); return super.visit(x); } public SQLBinaryOpExpr merge(SQLBinaryOpExpr x) { + if (x.getLeft() instanceof SQLLiteralExpr && x.getRight() instanceof SQLLiteralExpr) { + x.getLeft().getAttributes().put(ATTR_PARAMS_SKIP, true); + x.getRight().getAttributes().put(ATTR_PARAMS_SKIP, true); + return x; + } + if (x.getRight() instanceof SQLLiteralExpr) { x = new SQLBinaryOpExpr(x.getLeft(), x.getOperator(), new SQLVariantRefExpr("?")); } @@ -82,6 +81,17 @@ public class OracleParameterizedOutputVisitor extends OracleOutputVisitor { } } } + + if ((left.getLeft() instanceof SQLPropertyExpr) && (right.getLeft() instanceof SQLPropertyExpr)) { + String leftColumn = left.getLeft().toString(); + String rightColumn = right.getLeft().toString(); + + if (leftColumn.equals(rightColumn)) { + if ((left.getRight() instanceof SQLVariantRefExpr) && (right.getRight() instanceof SQLVariantRefExpr)) { + return left; // merge + } + } + } } } } @@ -90,21 +100,37 @@ public class OracleParameterizedOutputVisitor extends OracleOutputVisitor { } public boolean visit(SQLIntegerExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLNumberExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLCharExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } public boolean visit(SQLNCharExpr x) { + if (Boolean.TRUE.equals(x.getAttribute(ATTR_PARAMS_SKIP))) { + return super.visit(x); + } + print('?'); return false; } diff --git a/src/test/java/com/alibaba/druid/sql/mysql/bvt/MySqlParameterizedOutputVisitorTest.java b/src/test/java/com/alibaba/druid/sql/mysql/bvt/MySqlParameterizedOutputVisitorTest.java index a13600d656..5b7ba5a2f0 100644 --- a/src/test/java/com/alibaba/druid/sql/mysql/bvt/MySqlParameterizedOutputVisitorTest.java +++ b/src/test/java/com/alibaba/druid/sql/mysql/bvt/MySqlParameterizedOutputVisitorTest.java @@ -8,14 +8,18 @@ import junit.framework.TestCase; import com.alibaba.druid.sql.ast.SQLStatement; import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlParameterizedOutputVisitor; +import com.alibaba.druid.sql.dialect.oracle.ast.visitor.OracleParameterizedOutputVisitor; +import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser; public class MySqlParameterizedOutputVisitorTest extends TestCase { public void test_0() throws Exception { - validate("SELECT * FROM T WHERE ID IN (?, ?, ?)", "SELECT * FROM T WHERE ID IN (##)"); + validate("SELECT * FROM T WHERE ID IN (?, ?, ?)", "SELECT * FROM T WHERE ID IN (?)"); validate("SELECT * FROM T WHERE ID = 5", "SELECT * FROM T WHERE ID = ?"); validate("SELECT * FROM T WHERE 1 = 0 AND ID = 5", "SELECT * FROM T WHERE 1 = 0 AND ID = ?"); validate("SELECT * FROM T WHERE ID = ? OR ID = ?", "SELECT * FROM T WHERE ID = ?"); + validate("SELECT * FROM T WHERE A.ID = ? OR A.ID = ?", "SELECT * FROM T WHERE A.ID = ?"); + validateOracle("SELECT * FROM T WHERE A.ID = ? OR A.ID = ?", "SELECT * FROM T WHERE A.ID = ?; "); validate("INSERT INTO T (F1, F2) VALUES(?, ?), (?, ?), (?, ?)", "INSERT INTO T (F1, F2) VALUES (?, ?)"); } @@ -33,4 +37,19 @@ public class MySqlParameterizedOutputVisitorTest extends TestCase { Assert.assertEquals(expect, out.toString()); } + + void validateOracle(String sql, String expect) { + + OracleStatementParser parser = new OracleStatementParser(sql); + List statementList = parser.parseStatementList(); + SQLStatement statemen = statementList.get(0); + + Assert.assertEquals(1, statementList.size()); + + StringBuilder out = new StringBuilder(); + OracleParameterizedOutputVisitor visitor = new OracleParameterizedOutputVisitor(out); + statemen.accept(visitor); + + Assert.assertEquals(expect, out.toString()); + } } diff --git a/src/test/java/com/alibaba/druid/sql/mysql/bvt/parser/MySqlParserResourceTest.java b/src/test/java/com/alibaba/druid/sql/mysql/bvt/parser/MySqlParserResourceTest.java index 8435ef9720..963008edb8 100644 --- a/src/test/java/com/alibaba/druid/sql/mysql/bvt/parser/MySqlParserResourceTest.java +++ b/src/test/java/com/alibaba/druid/sql/mysql/bvt/parser/MySqlParserResourceTest.java @@ -11,6 +11,7 @@ import junit.framework.TestCase; import com.alibaba.druid.sql.ast.SQLStatement; import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; +import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlParameterizedOutputVisitor; import com.alibaba.druid.util.JdbcUtils; public class MySqlParserResourceTest extends TestCase { @@ -25,9 +26,10 @@ public class MySqlParserResourceTest extends TestCase { exec_test("bvt/parser/mysql-6.txt"); exec_test("bvt/parser/mysql-7.txt"); exec_test("bvt/parser/mysql-8.txt"); + exec_test("bvt/parser/mysql-9.txt"); + // exec_test("bvt/parser/mysql-10.txt"); } - - + public void exec_test(String resource) throws Exception { System.out.println(resource); InputStream is = null; @@ -39,17 +41,41 @@ public class MySqlParserResourceTest extends TestCase { String[] items = input.split("---------------------------"); String sql = items[0].trim(); String expect = items[1].trim(); - + MySqlStatementParser parser = new MySqlStatementParser(sql); List statementList = parser.parseStatementList(); - + Assert.assertEquals(1, statementList.size()); - + String text = output(statementList); System.out.println(text); System.out.println(); Assert.assertEquals(expect, text.trim()); - + + String mergeExpect = null; + if (items.length == 3) { + mergeExpect = items[2].trim(); + } + if (mergeExpect != null) { + mergValidate(sql, mergeExpect); + } + } + + void mergValidate(String sql, String expect) { + + MySqlStatementParser parser = new MySqlStatementParser(sql); + List statementList = parser.parseStatementList(); + SQLStatement statemen = statementList.get(0); + + Assert.assertEquals(1, statementList.size()); + + StringBuilder out = new StringBuilder(); + MySqlParameterizedOutputVisitor visitor = new MySqlParameterizedOutputVisitor(out); + statemen.accept(visitor); + + System.out.println(out.toString()); + + Assert.assertEquals(expect, out.toString()); } private String output(List stmtList) { diff --git a/src/test/resources/bvt/parser/mysql-10.txt b/src/test/resources/bvt/parser/mysql-10.txt new file mode 100644 index 0000000000..96f9fa22b9 --- /dev/null +++ b/src/test/resources/bvt/parser/mysql-10.txt @@ -0,0 +1,10 @@ +SELECT a.id AS "appId", a.name AS "appName", b.number AS "instanceNumber", b.hostname AS "hostname", c.name AS "monitorItemName" , d.id AS "alarmRuleStatusId", d.name AS "alarmRuleName", d.current_status AS "alarmRuleStatus", d.last_change_time AS "lastChangeTimeOfAlarmRule" FROM mi_alarm_rule_status d LEFT JOIN monitor_item_status c ON d.mi_status_id = c.id LEFT JOIN instance b ON b.number = c.inst_num AND b.app_num = c.app_num AND b.hostname = c.hostname LEFT JOIN app a ON a.number = b.app_num WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? +OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? ORDER BY lastChangeTimeOfAlarmRule DESC LIMIT ?, ? +--------------------------- +SELECT count(*) +FROM (SELECT a.activity_offer_id AS adResourceId, a.title AS adResourceName, a.b2boffer_url AS adResourceURL, a.custid, b.memberid + , c.position_name AS positionName, c.charge_setting AS feeRegulation, a.priority_weight AS priorityWeight, a.audit_state AS adResourceState, 0 AS adResourceType + , a.gmt_create, a.refuse_remark + FROM q_activity_offer_enroll a, q_custinfo b, q_activity_position c + WHERE a.custid = b.custid AND a.activity_position_id = c.activity_position_id AND c.activity_id = ? + ) a \ No newline at end of file diff --git a/src/test/resources/bvt/parser/mysql-9.txt b/src/test/resources/bvt/parser/mysql-9.txt index 6aaf8a103c..0efed3000a 100644 --- a/src/test/resources/bvt/parser/mysql-9.txt +++ b/src/test/resources/bvt/parser/mysql-9.txt @@ -1,42 +1,11 @@ -SELECT * -FROM - (SELECT - records.*, - rownum as row_num - FROM - ( SELECT - re.exchange_record_id as recordId, - re.GOODS_TITLE as goodsTitle, - re.GOODS_ATTRIBUTE as goodsAttribute, - re.GOODS_USAGE as goodsUsage, - re.goods_Id as goodsId, - re.EXPRESS_company as expressCompany, - re.EXPRESS_number as expressNumber, - re.cost_score as costScore, - re.exchange_Status as exchangeStatus, - re.remark as remark, - re.receiver_Name as receiverName, - re.receiver_Address as receiverAddress, - re.receiver_post_code as receiverPostCode, - re.receiver_mobile_phon as receiverMobilePhone, - re.receiver_phone_numer as receiverPhoneNumber, - re.change_date as createDate, accoun.memberid as memberId - FROM JF_EXCHANGE_RECORD re, Q_CUSTINFO accoun - WHERE re.custId = accoun.custId(+) - AND re.exchange_Status = ? - AND (re.goods_Attribute = ? ) - AND re.change_Date >= to_date(? || ' 00:00:00', 'yyyy-mm-dd hh24:mi:ss') - AND re.change_Date <= to_date(? || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') - ORDER BY re.exchange_record_id DESC )records - WHERE rownum < ? ) - WHERE row_num > ? - +SELECT a.id AS "appId", a.name AS "appName", b.number AS "instanceNumber", b.hostname AS "hostname", c.name AS "monitorItemName" , d.id AS "alarmRuleStatusId", d.name AS "alarmRuleName", d.current_status AS "alarmRuleStatus", d.last_change_time AS "lastChangeTimeOfAlarmRule" FROM mi_alarm_rule_status d LEFT JOIN monitor_item_status c ON d.mi_status_id = c.id LEFT JOIN instance b ON b.number = c.inst_num AND b.app_num = c.app_num AND b.hostname = c.hostname LEFT JOIN app a ON a.number = b.app_num WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? +OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? ORDER BY lastChangeTimeOfAlarmRule DESC LIMIT ?, ? --------------------------- -SELECT a.examine_id AS examineId, a.examine_name AS examineName, a.level_limit AS levelLimit -FROM c_examinepaper a , (SELECT examine_id - FROM c_examinepaper - WHERE level_limit = ? AND status = 1 - MINUS - SELECT DISTINCT examine_id - FROM course) -WHERE a.examine_id = b.examine_id +SELECT a.id AS "appId", a.name AS "appName", b.number AS "instanceNumber", b.hostname AS "hostname", c.name AS "monitorItemName" + , d.id AS "alarmRuleStatusId", d.name AS "alarmRuleName", d.current_status AS "alarmRuleStatus", d.last_change_time AS "lastChangeTimeOfAlarmRule" +FROM mi_alarm_rule_status d LEFT JOIN monitor_item_status c ON d.mi_status_id = c.id LEFT JOIN instance b ON b.number = c.inst_num AND b.app_num = c.app_num AND b.hostname = c.hostname LEFT JOIN app a ON a.number = b.app_num +WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? +ORDER BY lastChangeTimeOfAlarmRule DESC +LIMIT ?, ? +--------------------------- +SELECT a.id AS "appId", a.name AS "appName", b.number AS "instanceNumber", b.hostname AS "hostname", c.name AS "monitorItemName" , d.id AS "alarmRuleStatusId", d.name AS "alarmRuleName", d.current_status AS "alarmRuleStatus", d.last_change_time AS "lastChangeTimeOfAlarmRule" FROM mi_alarm_rule_status d LEFT JOIN monitor_item_status c ON d.mi_status_id = c.id LEFT JOIN instance b ON b.number = c.inst_num AND b.app_num = c.app_num AND b.hostname = c.hostname LEFT JOIN app a ON a.number = b.app_num WHERE ? = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ? ORDER BY lastChangeTimeOfAlarmRule DESC LIMIT ?, ? \ No newline at end of file