mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add
This commit is contained in:
@@ -340,6 +340,10 @@ public class Schema {
|
||||
return this.objects.values();
|
||||
}
|
||||
|
||||
public boolean removeObject(Long nameHashCode64) {
|
||||
return this.objects.remove(nameHashCode64) != null;
|
||||
}
|
||||
|
||||
public int getViewCount() {
|
||||
int count = 0;
|
||||
for (SchemaObject object : this.objects.values()) {
|
||||
|
||||
@@ -348,6 +348,12 @@ public class SchemaRepository {
|
||||
return getDefaultSchema().getTables(x);
|
||||
}
|
||||
|
||||
public boolean removeTable(SQLName name) {
|
||||
return getDefaultSchema()
|
||||
.removeObject(
|
||||
name.nameHashCode64());
|
||||
}
|
||||
|
||||
public int getTableCount() {
|
||||
return getDefaultSchema().getTableCount();
|
||||
}
|
||||
|
||||
@@ -1006,9 +1006,9 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
SQLExpr original = expr;
|
||||
|
||||
for (int i = 0;;i++) {
|
||||
// if (i > 100) {
|
||||
// return null;
|
||||
// }
|
||||
if (i > 1000) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (expr instanceof SQLMethodInvokeExpr) {
|
||||
SQLMethodInvokeExpr methodInvokeExp = (SQLMethodInvokeExpr) expr;
|
||||
@@ -1924,12 +1924,6 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
if (isSimpleExprTableSource(x)) {
|
||||
TableStat stat = getTableStatWithUnwrap(expr);
|
||||
if (stat == null) {
|
||||
if (expr instanceof SQLIdentifierExpr
|
||||
&& ((SQLIdentifierExpr) expr).getResolvedOwnerObject() instanceof SQLCreateViewStatement) {
|
||||
SQLCreateViewStatement createView = (SQLCreateViewStatement) ((SQLIdentifierExpr) expr).getResolvedOwnerObject();
|
||||
createView.getSubQuery().accept(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1975,8 +1969,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
|
||||
SQLObject resolvedOwnerObject = identifierExpr.getResolvedOwnerObject();
|
||||
if (resolvedOwnerObject instanceof SQLSubqueryTableSource
|
||||
|| resolvedOwnerObject instanceof SQLWithSubqueryClause.Entry
|
||||
|| resolvedOwnerObject instanceof SQLCreateViewStatement) {
|
||||
|| resolvedOwnerObject instanceof SQLWithSubqueryClause.Entry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2191,6 +2184,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
|
||||
if (x.getSelect() != null) {
|
||||
x.getSelect().accept(this);
|
||||
stat.incrementInsertCount();
|
||||
}
|
||||
|
||||
SQLExprTableSource like = x.getLike();
|
||||
|
||||
@@ -40,6 +40,10 @@ public class TableStat {
|
||||
int dropIndexCount = 0;
|
||||
int referencedCount = 0;
|
||||
|
||||
public TableStat() {
|
||||
|
||||
}
|
||||
|
||||
public int getReferencedCount() {
|
||||
return referencedCount;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.druid.support.opds.udf;
|
||||
|
||||
import com.alibaba.druid.sql.parser.SQLParserFeature;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
@@ -27,7 +28,7 @@ public class SqlCodeStat extends UDF {
|
||||
DbType dbType = dbTypeName == null ? null : DbType.valueOf(dbTypeName);
|
||||
|
||||
try {
|
||||
List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, DbType.odps);
|
||||
List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, DbType.odps, SQLParserFeature.EnableMultiUnion);
|
||||
|
||||
CodeStatVisitor v = new CodeStatVisitor();
|
||||
for (SQLStatement stmt : stmtList) {
|
||||
|
||||
Reference in New Issue
Block a user