From 34b2d51fe7b49fa2f814fea05066e1b07be335ba Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 28 Feb 2013 22:03:33 +0800 Subject: [PATCH 1/8] first commit --- README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e69de29bb2 From 85b86128f98fa83000d878d1ee39bd68b07fd53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9=E9=AB=98=E9=93=81?= Date: Thu, 28 Feb 2013 22:05:11 +0800 Subject: [PATCH 2/8] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e69de29bb2..e0e971d22a 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +druid +======== + +Already moved to https://github.com/alibaba/druid ! From 3446805a1251d21285536d529dfdb81ab767a190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9=E9=AB=98=E9=93=81?= Date: Tue, 5 Mar 2013 03:36:27 +0800 Subject: [PATCH 3/8] Update README --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index b6bc847d20..0f4b8d59cd 100644 --- a/README +++ b/README @@ -4,3 +4,7 @@ Introduction * cd druid && mvn install * have fun. +Doucumentation +--- +中文 https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 +English https://github.com/alibaba/druid/wiki/FAQ From 93819d9df27d1f5a471bbea53a26e221cf91083d Mon Sep 17 00:00:00 2001 From: Zhanming Qi Date: Fri, 8 Mar 2013 13:41:54 +0800 Subject: [PATCH 4/8] bugfix http://www.oschina.net/question/2795_92396 --- src/main/resources/support/http/resources/datasource.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/support/http/resources/datasource.html b/src/main/resources/support/http/resources/datasource.html index 33d90dd858..cdbe47264a 100644 --- a/src/main/resources/support/http/resources/datasource.html +++ b/src/main/resources/support/http/resources/datasource.html @@ -35,8 +35,8 @@ ] var descs = ["Specify the username used when creating a new connection.", "The JDBC driver connection URL", "database type", "The fully qualifed name of the JDBC driver class", - "All the fully qualifed name of the filter classes", " Test or not when borrow a connection", "Test or not when return a connection", - "Test or not when a connection is idle for a while","The size of datasource connections to create when initial a datasource", + "All the fully qualifed name of the filter classes", " Test or not when borrow a connection", "Test or not when a connection is idle for a while", + "Test or not when return a connection","The size of datasource connections to create when initial a datasource", "The minimum number of connections a pool should hold. ", "The maximum number of connections for a pool", "", "", "", "", "", "", "", "", "Total times for wait to get a connection","Total millins for wait to get a connection", "The current waiting thread count", "The count of start transaction", "The histogram values of transaction time, [0-10 ms, 10-100 ms, 100-1 s, 1-10 s, 10-100 s, >100 s]", From 97c8b5f64392a89480590c2d79c8c4e33f3352df Mon Sep 17 00:00:00 2001 From: wenshao Date: Wed, 13 Mar 2013 00:30:27 +0800 Subject: [PATCH 5/8] bug fixed for mysql SchemaVisitor --- pom.xml | 2 +- .../druid/sql/visitor/SchemaStatVisitor.java | 26 +++++--- .../bvt/sql/mysql/MySqlUpdateTest_1.java | 60 +++++++++++++++++++ 3 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 src/test/java/com/alibaba/druid/bvt/sql/mysql/MySqlUpdateTest_1.java diff --git a/pom.xml b/pom.xml index d4bee6fefb..00df17afd8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.alibaba druid - 0.2.12-SNAPSHOT + 0.2.12 jar druid diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java index 0c77bcb481..90629b21de 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java @@ -58,6 +58,7 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock; import com.alibaba.druid.sql.ast.statement.SQLSelectStatement; import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource; import com.alibaba.druid.sql.ast.statement.SQLTableElement; +import com.alibaba.druid.sql.ast.statement.SQLTableSource; import com.alibaba.druid.sql.ast.statement.SQLTruncateStatement; import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement; import com.alibaba.druid.stat.TableStat; @@ -153,11 +154,11 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { if (flag0) { ident = ident.replaceAll("\"", ""); } - + if (flag1) { ident = ident.replaceAll("`", ""); } - + if (flag2) { ident = ident.replaceAll(" ", ""); } @@ -869,15 +870,22 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { public boolean visit(SQLUpdateStatement x) { setAliasMap(); + + setMode(x, Mode.Update); - String ident = x.getTableName().toString(); - setCurrentTable(ident); + SQLName identName = x.getTableName(); + if (identName != null) { + String ident = identName.toString(); + setCurrentTable(ident); - TableStat stat = getTableStat(ident); - stat.incrementUpdateCount(); + TableStat stat = getTableStat(ident); + stat.incrementUpdateCount(); - Map aliasMap = getAliasMap(); - aliasMap.put(ident, ident); + Map aliasMap = getAliasMap(); + aliasMap.put(ident, ident); + } else { + x.getTableSource().accept(this); + } accept(x.getItems()); accept(x.getWhere()); @@ -1004,7 +1012,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { public void endVisit(SQLAlterTableAddColumn x) { } - + @Override public boolean visit(SQLRollbackStatement x) { return false; diff --git a/src/test/java/com/alibaba/druid/bvt/sql/mysql/MySqlUpdateTest_1.java b/src/test/java/com/alibaba/druid/bvt/sql/mysql/MySqlUpdateTest_1.java new file mode 100644 index 0000000000..6e2669b862 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/sql/mysql/MySqlUpdateTest_1.java @@ -0,0 +1,60 @@ +/* + * 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.bvt.sql.mysql; + +import java.util.List; + +import junit.framework.Assert; + +import com.alibaba.druid.sql.MysqlTest; +import com.alibaba.druid.sql.ast.SQLStatement; +import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; +import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; +import com.alibaba.druid.stat.TableStat; +import com.alibaba.druid.stat.TableStat.Column; + +public class MySqlUpdateTest_1 extends MysqlTest { + + public void test_0() throws Exception { + String sql = "UPDATE t_price, t_basic_store s " + // + "SET purchasePrice = :purchasePrice, operaterId = :operaterId, " + // + " operaterRealName = :operaterRealName, operateDateline = :operateDateline " + // + "WHERE goodsId = :goodsId AND s.id = storeId AND s.areaId = :areaId"; + + MySqlStatementParser parser = new MySqlStatementParser(sql); + List statementList = parser.parseStatementList(); + SQLStatement statemen = statementList.get(0); + print(statementList); + + Assert.assertEquals(1, statementList.size()); + + MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); + statemen.accept(visitor); + + System.out.println("Tables : " + visitor.getTables()); + System.out.println("fields : " + visitor.getColumns()); + System.out.println("coditions : " + visitor.getConditions()); + System.out.println("orderBy : " + visitor.getOrderByColumns()); + + Assert.assertEquals(2, visitor.getTables().size()); + Assert.assertEquals(8, visitor.getColumns().size()); + Assert.assertEquals(4, visitor.getConditions().size()); + + Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t_price"))); + Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t_basic_store"))); + + } +} From 819d5bc00de6423fed540f167a9d6d0368dbef4c Mon Sep 17 00:00:00 2001 From: wenshao Date: Wed, 13 Mar 2013 01:04:44 +0800 Subject: [PATCH 6/8] 0.2.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00df17afd8..c18ad79e56 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.1.1.RELEASE 4.11 - true + false UTF-8 1.6 From 4e903786b60e19e7ac00ad357fe87c929759bbad Mon Sep 17 00:00:00 2001 From: wenshao Date: Wed, 13 Mar 2013 01:11:12 +0800 Subject: [PATCH 7/8] fixed README --- README | 4 ++++ README.md | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 README.md diff --git a/README b/README index b6bc847d20..6a7fc3c292 100644 --- a/README +++ b/README @@ -4,3 +4,7 @@ Introduction * cd druid && mvn install * have fun. +Doucumentation +--- +中文 https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 +English https://github.com/alibaba/druid/wiki/FAQ diff --git a/README.md b/README.md deleted file mode 100644 index e0e971d22a..0000000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -druid -======== - -Already moved to https://github.com/alibaba/druid ! From a6c5167d23a73a70d8de7221027949c77ee6dda7 Mon Sep 17 00:00:00 2001 From: wenshao Date: Wed, 13 Mar 2013 01:14:40 +0800 Subject: [PATCH 8/8] change README --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 34d96b5f67..6a7fc3c292 100644 --- a/README +++ b/README @@ -5,5 +5,6 @@ Introduction * have fun. Doucumentation +--- 中文 https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 English https://github.com/alibaba/druid/wiki/FAQ