mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -44,7 +44,6 @@ public class SchemaRepository {
|
||||
protected String dbType;
|
||||
protected SQLASTVisitor consoleVisitor;
|
||||
|
||||
|
||||
public SchemaRepository() {
|
||||
|
||||
}
|
||||
|
||||
@@ -630,6 +630,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLFetchStatement x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -1685,6 +1690,36 @@ class SchemaResolveVisitorFactory {
|
||||
SQLUtils.replaceInParent(x, propertyExpr);
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getResolvedColumn() == null
|
||||
&& x.getResolvedTableSource() == null) {
|
||||
for (SchemaResolveVisitor.Context parentCtx = ctx;
|
||||
parentCtx != null;
|
||||
parentCtx = parentCtx.parent)
|
||||
{
|
||||
SQLDeclareItem declareItem = parentCtx.findDeclare(hash);
|
||||
if (declareItem != null) {
|
||||
x.setResolvedDeclareItem(declareItem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentCtx.object instanceof SQLBlockStatement) {
|
||||
SQLBlockStatement block = (SQLBlockStatement) parentCtx.object;
|
||||
SQLParameter parameter = block.findParameter(hash);
|
||||
if (parameter != null) {
|
||||
x.setResolvedParameter(parameter);
|
||||
return;
|
||||
}
|
||||
} else if (parentCtx.object instanceof SQLCreateProcedureStatement) {
|
||||
SQLCreateProcedureStatement createProc = (SQLCreateProcedureStatement) parentCtx.object;
|
||||
SQLParameter parameter = createProc.findParameter(hash);
|
||||
if (parameter != null) {
|
||||
x.setResolvedParameter(parameter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLPropertyExpr x) {
|
||||
@@ -2464,6 +2499,13 @@ class SchemaResolveVisitorFactory {
|
||||
visitor.popContext();
|
||||
}
|
||||
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLFetchStatement x) {
|
||||
resolveExpr(visitor, x.getCursorName());
|
||||
for (SQLExpr expr : x.getInto()) {
|
||||
resolveExpr(visitor, expr);
|
||||
}
|
||||
}
|
||||
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLForeignKeyConstraint x) {
|
||||
SchemaRepository repository = visitor.getRepository();
|
||||
SQLObject parent = x.getParent();
|
||||
|
||||
Reference in New Issue
Block a user