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:
+4
-6
@@ -67,12 +67,10 @@ public class MySqlDeclareHandlerStatement extends MySqlStatementImpl{
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
// TODO Auto-generated method stub
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, spStatement);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, spStatement);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-5
@@ -16,10 +16,7 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.clause;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLBlockStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLIfStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLLoopStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.*;
|
||||
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.MySqlUpdateStatement;
|
||||
@@ -38,7 +35,7 @@ public enum MySqlStatementType {
|
||||
//delete statement
|
||||
DELETE(MySqlDeleteStatement.class.getName()),
|
||||
//while statement
|
||||
WHILE(MySqlWhileStatement.class.getName()),
|
||||
WHILE(SQLWhileStatement.class.getName()),
|
||||
//begin-end
|
||||
IF(SQLIfStatement.class.getName()),
|
||||
//begin-end
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2017 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.sql.dialect.mysql.ast.clause;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zz [455910092@qq.com]
|
||||
*/
|
||||
public class MySqlWhileStatement extends MySqlStatementImpl {
|
||||
|
||||
//while expr
|
||||
private SQLExpr condition;
|
||||
private List<SQLStatement> statements = new ArrayList<SQLStatement>();
|
||||
//while label name
|
||||
private String labelName;
|
||||
|
||||
|
||||
public String getLabelName() {
|
||||
return labelName;
|
||||
}
|
||||
|
||||
public void setLabelName(String labelName) {
|
||||
this.labelName = labelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, condition);
|
||||
acceptChild(visitor, statements);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLStatement> getStatements() {
|
||||
return statements;
|
||||
}
|
||||
|
||||
public void setStatements(List<SQLStatement> statements) {
|
||||
this.statements = statements;
|
||||
}
|
||||
public SQLExpr getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(SQLExpr condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
}
|
||||
+38
-30
@@ -93,14 +93,12 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCursorDeclareStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareConditionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareHandlerStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlExplainType;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlFormatName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlHandlerType;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlIterateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlLeaveStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlWhileStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.CobarShowStatus;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableAlterColumn;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableChangeColumn;
|
||||
@@ -3450,26 +3448,8 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
// declare statement
|
||||
if (lexer.token() == Token.DECLARE) {
|
||||
char markChar = lexer.current();
|
||||
int markBp = lexer.bp();
|
||||
lexer.nextToken();
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.CURSOR)// cursor declare statement
|
||||
{
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
statementList.add(this.parseCursorDeclare());
|
||||
} else if (identifierEquals("HANDLER")) {
|
||||
//DECLARE异常处理程序 [add by zhujun 2016-04-16]
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
statementList.add(this.parseDeclareHandler());
|
||||
} else if (lexer.token() == Token.CONDITION) {
|
||||
//DECLARE异常 [add by zhujun 2016-04-17]
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
statementList.add(this.parseDeclareCondition());
|
||||
} else {
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
statementList.add(this.parseDeclare());
|
||||
}
|
||||
SQLStatement stmt = this.parseDeclare();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3590,9 +3570,9 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
*
|
||||
* @return MySqlWhileStatement
|
||||
*/
|
||||
public MySqlWhileStatement parseWhile() {
|
||||
public SQLWhileStatement parseWhile() {
|
||||
accept(Token.WHILE);
|
||||
MySqlWhileStatement stmt = new MySqlWhileStatement();
|
||||
SQLWhileStatement stmt = new SQLWhileStatement();
|
||||
|
||||
stmt.setCondition(this.exprParser.expr());
|
||||
|
||||
@@ -3615,10 +3595,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
*
|
||||
* @return MySqlWhileStatement
|
||||
*/
|
||||
public MySqlWhileStatement parseWhile(String label) {
|
||||
public SQLWhileStatement parseWhile(String label) {
|
||||
accept(Token.WHILE);
|
||||
|
||||
MySqlWhileStatement stmt = new MySqlWhileStatement();
|
||||
SQLWhileStatement stmt = new SQLWhileStatement();
|
||||
|
||||
stmt.setLabelName(label);
|
||||
|
||||
@@ -3706,7 +3686,33 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
/**
|
||||
* parse declare statement
|
||||
*/
|
||||
public MySqlDeclareStatement parseDeclare() {
|
||||
public SQLStatement parseDeclare() {
|
||||
char markChar = lexer.current();
|
||||
int markBp = lexer.bp();
|
||||
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.CONTINUE) {
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
return this.parseDeclareHandler();
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.CURSOR) {
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
return this.parseCursorDeclare();
|
||||
} else if (identifierEquals("HANDLER")) {
|
||||
//DECLARE异常处理程序 [add by zhujun 2016-04-16]
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
return this.parseDeclareHandler();
|
||||
} else if (lexer.token() == Token.CONDITION) {
|
||||
//DECLARE异常 [add by zhujun 2016-04-17]
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
return this.parseDeclareCondition();
|
||||
} else {
|
||||
lexer.reset(markBp, markChar, Token.DECLARE);
|
||||
}
|
||||
|
||||
MySqlDeclareStatement stmt = new MySqlDeclareStatement();
|
||||
accept(Token.DECLARE);
|
||||
// lexer.nextToken();
|
||||
@@ -3777,7 +3783,9 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
parseProcedureStatementList(loopStmt.getStatements());
|
||||
accept(Token.END);
|
||||
accept(Token.LOOP);
|
||||
acceptIdentifier(label);
|
||||
if (lexer.token() != Token.SEMI) {
|
||||
acceptIdentifier(label);
|
||||
}
|
||||
accept(Token.SEMI);
|
||||
return loopStmt;
|
||||
}
|
||||
@@ -3967,7 +3975,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (tokenName.equalsIgnoreCase("NOT")) {//for 'NOT FOUND'
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("HANDLE");
|
||||
acceptIdentifier("FOUND");
|
||||
condition.setType(ConditionType.SYSTEM);
|
||||
condition.setValue("NOT FOUND");
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlIterateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlLeaveStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
@@ -525,13 +524,6 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
|
||||
void endVisit(MySqlOrderingExpr x);
|
||||
|
||||
/**
|
||||
* support procedure
|
||||
*/
|
||||
boolean visit(MySqlWhileStatement x);
|
||||
|
||||
void endVisit(MySqlWhileStatement x);
|
||||
|
||||
boolean visit(MySqlCaseStatement x);
|
||||
|
||||
void endVisit(MySqlCaseStatement x);
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlIterateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlLeaveStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
@@ -1138,16 +1137,6 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.alibaba.druid.sql.ast.SQLOrderBy;
|
||||
import com.alibaba.druid.sql.ast.SQLParameter;
|
||||
import com.alibaba.druid.sql.ast.SQLSetQuantifier;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.SQLSubPartitionBy;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
|
||||
@@ -44,12 +43,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCursorDeclareStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareConditionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareHandlerStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlExplainType;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlIterateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlLeaveStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
@@ -690,21 +687,21 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isGlobal()) {
|
||||
print0("@@global.");
|
||||
} else {
|
||||
if ((!varName.startsWith("@")) // /
|
||||
&& (!varName.equals("?")) //
|
||||
&& (!varName.startsWith("#")) //
|
||||
&& (!varName.startsWith("$")) //
|
||||
&& (!varName.startsWith(":"))) {
|
||||
|
||||
boolean subPartitionOption = false;
|
||||
if (x.getParent() != null) {
|
||||
subPartitionOption = x.getParent().getParent() instanceof SQLSubPartitionBy;
|
||||
}
|
||||
|
||||
if (!subPartitionOption) {
|
||||
print0("@@");
|
||||
}
|
||||
}
|
||||
// if ((!varName.startsWith("@")) // /
|
||||
// && (!varName.equals("?")) //
|
||||
// && (!varName.startsWith("#")) //
|
||||
// && (!varName.startsWith("$")) //
|
||||
// && (!varName.startsWith(":"))) {
|
||||
//
|
||||
// boolean subPartitionOption = false;
|
||||
// if (x.getParent() != null) {
|
||||
// subPartitionOption = x.getParent().getParent() instanceof SQLSubPartitionBy;
|
||||
// }
|
||||
//
|
||||
// if (!subPartitionOption) {
|
||||
// print0("@@");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
for (int i = 0; i < x.getName().length(); ++i) {
|
||||
@@ -3154,6 +3151,28 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(x.getLabelName());
|
||||
print0(": ");
|
||||
}
|
||||
if (x.getParameters().size() != 0) {
|
||||
incrementIndent();
|
||||
if (x.getParent() instanceof SQLCreateProcedureStatement) {
|
||||
printIndent();
|
||||
}
|
||||
if (!(x.getParent() instanceof SQLCreateProcedureStatement)) {
|
||||
print0(ucase ? "DECLARE" : "declare");
|
||||
println();
|
||||
}
|
||||
|
||||
for (int i = 0, size = x.getParameters().size(); i < size; ++i) {
|
||||
if (i != 0) {
|
||||
println();
|
||||
}
|
||||
SQLParameter param = x.getParameters().get(i);
|
||||
param.accept(this);
|
||||
print(';');
|
||||
}
|
||||
|
||||
decrementIndent();
|
||||
println();
|
||||
}
|
||||
print0(ucase ? "BEGIN" : "begin");
|
||||
incrementIndent();
|
||||
println();
|
||||
@@ -3215,41 +3234,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
print0(x.getLabelName());
|
||||
print0(": ");
|
||||
}
|
||||
print0(ucase ? "WHILE " : "while ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " DO" : " do");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
if (i != size - 1) {
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
print0(ucase ? "END WHILE" : "end while");
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) print(' ');
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement x) {
|
||||
print0(ucase ? "IF " : "if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
incrementIndent();
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
@@ -3259,6 +3249,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
decrementIndent();
|
||||
println();
|
||||
for (SQLIfStatement.ElseIf iterable_element : x.getElseIfList()) {
|
||||
iterable_element.accept(this);
|
||||
@@ -3275,6 +3266,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(ucase ? "ELSE IF " : "else if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
incrementIndent();
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
@@ -3284,6 +3276,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
decrementIndent();
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
@@ -3379,6 +3372,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
|
||||
print0(ucase ? "LOOP " : "loop ");
|
||||
incrementIndent();
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
@@ -3388,6 +3382,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
decrementIndent();
|
||||
println();
|
||||
print0(ucase ? "END LOOP" : "end loop");
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
@@ -3463,8 +3458,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public boolean visit(MySqlCursorDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
print0(x.getCursorName());
|
||||
print0(ucase ? " CURSOR FOR " : " cursor for ");
|
||||
print0(ucase ? " CURSOR FOR" : " cursor for");
|
||||
incrementIndent();
|
||||
println();
|
||||
x.getSelect().accept(this);
|
||||
decrementIndent();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3563,9 +3561,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareHandlerStatement x) {
|
||||
String handleType = x.getHandleType().name();
|
||||
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
print0(ucase ? x.getHandleType().toString().toUpperCase() : x.getHandleType().toString().toLowerCase());
|
||||
print0(ucase ? handleType : handleType.toLowerCase());
|
||||
print0(ucase ? " HANDLER FOR " : " handler for ");
|
||||
for (int i = 0; i < x.getConditionValues().size(); i++) {
|
||||
ConditionValue cv = x.getConditionValues().get(i);
|
||||
@@ -3585,8 +3584,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
|
||||
}
|
||||
incrementIndent();
|
||||
println();
|
||||
return true;
|
||||
x.getSpStatement().accept(this);
|
||||
decrementIndent();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlIterateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlLeaveStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
@@ -1310,20 +1309,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* support procedure
|
||||
*/
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
accept(x.getStatements());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
accept(x.getWhenList());
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.stmt;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 23/05/2017.
|
||||
*/
|
||||
public class OracleCreatePackageStatement extends OracleStatementImpl {
|
||||
private boolean orReplace;
|
||||
private SQLName name;
|
||||
|
||||
private boolean body;
|
||||
|
||||
private final List<SQLStatement> statements = new ArrayList<SQLStatement>();
|
||||
|
||||
public OracleCreatePackageStatement() {
|
||||
super.setDbType(JdbcConstants.ORACLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept0(OracleASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
acceptChild(visitor, statements);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public boolean isOrReplace() {
|
||||
return orReplace;
|
||||
}
|
||||
|
||||
public void setOrReplace(boolean orReplace) {
|
||||
this.orReplace = orReplace;
|
||||
}
|
||||
|
||||
public boolean isBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(boolean body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public SQLName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLName name) {
|
||||
if (name != null) {
|
||||
name.setParent(this);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<SQLStatement> getStatements() {
|
||||
return statements;
|
||||
}
|
||||
}
|
||||
+292
-45
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import com.alibaba.druid.sql.ast.*;
|
||||
import com.alibaba.druid.sql.ast.expr.*;
|
||||
import com.alibaba.druid.sql.ast.statement.*;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLWhileStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleReturningClause;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleAlterTableSplitPartition.NestedTablePartitionSpec;
|
||||
@@ -86,39 +87,53 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.SELECT)) {
|
||||
SQLSelectStatement stmt = new SQLSelectStatement(new OracleSelectParser(this.exprParser).select(), JdbcConstants.ORACLE);
|
||||
SQLStatement stmt = new SQLSelectStatement(new OracleSelectParser(this.exprParser).select(), JdbcConstants.ORACLE);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.UPDATE)) {
|
||||
statementList.add(parseUpdateStatement());
|
||||
SQLStatement stmt = parseUpdateStatement();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.CREATE)) {
|
||||
statementList.add(parseCreate());
|
||||
SQLStatement stmt = parseCreate();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.INSERT) {
|
||||
statementList.add(parseInsert());
|
||||
SQLStatement stmt = parseInsert();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.DELETE)) {
|
||||
statementList.add(parseDeleteStatement());
|
||||
SQLStatement stmt = parseDeleteStatement();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.SLASH)) {
|
||||
lexer.nextToken();
|
||||
statementList.add(new OraclePLSQLCommitStatement());
|
||||
|
||||
SQLStatement stmt = new OraclePLSQLCommitStatement();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.ALTER) {
|
||||
statementList.add(parserAlter());
|
||||
SQLStatement stmt = parserAlter();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -128,32 +143,38 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LBRACE || identifierEquals("CALL")) {
|
||||
statementList.add(this.parseCall());
|
||||
SQLStatement stmt = parseCall();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.MERGE) {
|
||||
statementList.add(this.parseMerge());
|
||||
SQLStatement stmt = parseMerge();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.BEGIN) {
|
||||
statementList.add(this.parseBlock());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.DECLARE) {
|
||||
statementList.add(this.parseBlock());
|
||||
if (lexer.token() == Token.BEGIN
|
||||
|| lexer.token() == Token.DECLARE) {
|
||||
SQLStatement stmt = parseBlock();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LOCK) {
|
||||
statementList.add(this.parseLock());
|
||||
SQLStatement stmt = parseLock();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.TRUNCATE) {
|
||||
statementList.add(this.parseTruncate());
|
||||
SQLStatement stmt = parseTruncate();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -163,6 +184,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
SQLBinaryOpExpr binaryOpExpr = (SQLBinaryOpExpr) variant;
|
||||
if (binaryOpExpr.getOperator() == SQLBinaryOperator.Assignment) {
|
||||
SQLSetStatement stmt = new SQLSetStatement(binaryOpExpr.getLeft(), binaryOpExpr.getRight(), getDbType());
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -171,12 +193,14 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
SQLExpr value = this.exprParser.expr();
|
||||
|
||||
SQLSetStatement stmt = new SQLSetStatement(variant, value, getDbType());
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.EXCEPTION) {
|
||||
OracleExceptionStatement stmt = this.parseException();
|
||||
stmt.setParent(parent);
|
||||
if (parent instanceof SQLBlockStatement) {
|
||||
((SQLBlockStatement) parent).setException(stmt);
|
||||
} else {
|
||||
@@ -192,6 +216,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
stmt.setWhen(this.exprParser.expr());
|
||||
}
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -208,12 +233,14 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
stmt.setWhen(this.exprParser.expr());
|
||||
}
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.FETCH || identifierEquals("FETCH")) {
|
||||
SQLStatement stmt = parseFetch();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -259,7 +286,10 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
|
||||
if (lexer.token() == Token.SELECT) {
|
||||
lexer.reset(bp, ch, Token.LPAREN);
|
||||
statementList.add(this.parseSelect());
|
||||
|
||||
SQLStatement stmt = parseSelect();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
} else {
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
@@ -267,7 +297,9 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SET) {
|
||||
statementList.add(this.parseSet());
|
||||
SQLStatement stmt = parseSet();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -287,6 +319,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
if (lexer.token() == Token.FOR) {
|
||||
OracleForStatement forStatement = this.parseFor();
|
||||
forStatement.setParent(parent);
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
String strVal = lexer.stringVal();
|
||||
int stmtListSize = statementList.size();
|
||||
@@ -304,11 +337,15 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
continue;
|
||||
}
|
||||
if (lexer.token() == Token.LOOP) {
|
||||
statementList.add(this.parseLoop());
|
||||
SQLStatement stmt = parseLoop();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
if (lexer.token() == Token.IF) {
|
||||
statementList.add(this.parseIf());
|
||||
SQLStatement stmt = parseIf();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -316,6 +353,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
SQLName label = this.exprParser.name();
|
||||
OracleGotoStatement stmt = new OracleGotoStatement(label);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -327,6 +365,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
}
|
||||
OracleCommitStatement stmt = new OracleCommitStatement();
|
||||
stmt.setParent(parent);
|
||||
|
||||
if (identifierEquals("WRITE")) {
|
||||
stmt.setWrite(true);
|
||||
@@ -363,6 +402,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
|
||||
OracleSavePointStatement stmt = new OracleSavePointStatement();
|
||||
stmt.setParent(parent);
|
||||
|
||||
if (lexer.token() == Token.TO) {
|
||||
lexer.nextToken();
|
||||
@@ -378,6 +418,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
SQLName label = this.exprParser.name();
|
||||
OracleLabelStatement stmt = new OracleLabelStatement(label);
|
||||
accept(Token.GTGT);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -387,6 +428,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
|
||||
if (lexer.token() == Token.TABLE) {
|
||||
SQLDropTableStatement stmt = parseDropTable(false);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -417,36 +459,42 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
|
||||
if (lexer.token() == Token.INDEX) {
|
||||
SQLStatement stmt = parseDropIndex();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.VIEW) {
|
||||
SQLStatement stmt = parseDropView(false);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SEQUENCE) {
|
||||
SQLDropSequenceStatement stmt = parseDropSequece(false);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.TRIGGER) {
|
||||
SQLDropTriggerStatement stmt = parseDropTrigger(false);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.USER) {
|
||||
SQLDropUserStatement stmt = parseDropUser();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.PROCEDURE) {
|
||||
SQLDropProcedureStatement stmt = parseDropProcedure(false);
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -457,30 +505,35 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
if (lexer.token() == Token.NULL) {
|
||||
lexer.nextToken();
|
||||
OracleExprStatement stmt = new OracleExprStatement(new SQLNullExpr());
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.OPEN) {
|
||||
SQLStatement stmt = this.parseOpen();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.CLOSE) {
|
||||
SQLStatement stmt = this.parseClose();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.CASE) {
|
||||
SQLStatement stmt = this.parseCase();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.PROCEDURE) {
|
||||
SQLStatement stmt = this.parseCreateProcedure();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
@@ -495,10 +548,126 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
break;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.FUNCTION) {
|
||||
SQLStatement stmt = this.parseFunction();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.WHILE) {
|
||||
SQLStatement stmt = this.parseWhile();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
}
|
||||
|
||||
public SQLStatement parseWhile() {
|
||||
accept(Token.WHILE);
|
||||
|
||||
SQLWhileStatement stmt = new SQLWhileStatement();
|
||||
stmt.setDbType(dbType);
|
||||
|
||||
stmt.setCondition(this.exprParser.expr());
|
||||
|
||||
accept(Token.LOOP);
|
||||
|
||||
this.parseStatementList(stmt.getStatements(), -1, stmt);
|
||||
accept(Token.END);
|
||||
accept(Token.LOOP);
|
||||
accept(Token.SEMI);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseFunction() {
|
||||
SQLCreateFunctionStatement stmt = new SQLCreateFunctionStatement();
|
||||
stmt.setDbType(dbType);
|
||||
|
||||
if (lexer.token() == Token.CREATE) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.OR) {
|
||||
lexer.nextToken();
|
||||
accept(Token.REPLACE);
|
||||
stmt.setOrReplace(true);
|
||||
}
|
||||
} else {
|
||||
stmt.setCreate(false);
|
||||
}
|
||||
|
||||
accept(Token.FUNCTION);
|
||||
|
||||
SQLName procedureName = this.exprParser.name();
|
||||
stmt.setName(procedureName);
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
parserParameters(stmt.getParameters(), stmt);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
acceptIdentifier("RETURN");
|
||||
SQLDataType returnDataType = this.exprParser.parseDataType();
|
||||
stmt.setReturnDataType(returnDataType);
|
||||
|
||||
if (identifierEquals("AUTHID")) {
|
||||
lexer.nextToken();
|
||||
String strVal = lexer.stringVal();
|
||||
if (identifierEquals("CURRENT_USER")) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
acceptIdentifier("DEFINER");
|
||||
}
|
||||
SQLName authid = new SQLIdentifierExpr(strVal);
|
||||
stmt.setAuthid(authid);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SEMI) {
|
||||
lexer.nextToken();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.IS) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
accept(Token.AS);
|
||||
}
|
||||
|
||||
if (identifierEquals("LANGUAGE")) {
|
||||
lexer.nextToken();
|
||||
if (identifierEquals("JAVA")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("NAME");
|
||||
String javaCallSpec = lexer.stringVal();
|
||||
accept(Token.LITERAL_CHARS);
|
||||
stmt.setJavaCallSpec(javaCallSpec);
|
||||
} else {
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
SQLBlockStatement block = this.parseBlock();
|
||||
|
||||
stmt.setBlock(block);
|
||||
|
||||
if (identifierEquals(procedureName.getSimpleName())) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
// return stmt;
|
||||
|
||||
if (identifierEquals(procedureName.getSimpleName())) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseRaise() {
|
||||
lexer.nextToken();
|
||||
OracleRaiseStatement stmt = new OracleRaiseStatement();
|
||||
@@ -551,6 +720,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
accept(Token.IF);
|
||||
|
||||
SQLIfStatement stmt = new SQLIfStatement();
|
||||
stmt.setDbType(dbType);
|
||||
|
||||
stmt.setCondition(this.exprParser.expr());
|
||||
|
||||
@@ -571,30 +741,20 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
stmt.getElseIfList().add(elseIf);
|
||||
}
|
||||
|
||||
while (lexer.token() == Token.ELSE) {
|
||||
if (lexer.token() == Token.ELSE) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IF) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLIfStatement.ElseIf elseIf = new SQLIfStatement.ElseIf();
|
||||
|
||||
elseIf.setCondition(this.exprParser.expr());
|
||||
|
||||
accept(Token.THEN);
|
||||
this.parseStatementList(elseIf.getStatements());
|
||||
|
||||
stmt.getElseIfList().add(elseIf);
|
||||
} else {
|
||||
SQLIfStatement.Else elseItem = new SQLIfStatement.Else();
|
||||
this.parseStatementList(elseItem.getStatements());
|
||||
stmt.setElseItem(elseItem);
|
||||
break;
|
||||
}
|
||||
SQLIfStatement.Else elseItem = new SQLIfStatement.Else();
|
||||
this.parseStatementList(elseItem.getStatements(), -1, elseItem);
|
||||
stmt.setElseItem(elseItem);
|
||||
}
|
||||
|
||||
accept(Token.END);
|
||||
accept(Token.IF);
|
||||
// if (lexer.token() == Token.SEMI) {
|
||||
// lexer.nextToken();
|
||||
// }
|
||||
accept(Token.SEMI);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -1156,15 +1316,21 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
if (lexer.token() == Token.CURSOR) {
|
||||
lexer.nextToken();
|
||||
|
||||
name = this.exprParser.name();
|
||||
|
||||
accept(Token.IS);
|
||||
SQLSelect select = this.createSQLSelectParser().select();
|
||||
|
||||
dataType = new SQLDataTypeImpl();
|
||||
dataType.setName("CURSOR");
|
||||
|
||||
name = this.exprParser.name();
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
this.parserParameters(parameter.getCursorParameters(), parameter);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
accept(Token.IS);
|
||||
SQLSelect select = this.createSQLSelectParser().select();
|
||||
parameter.setDefaultValue(new SQLQueryExpr(select));
|
||||
|
||||
} else if (lexer.token() == Token.PROCEDURE) {
|
||||
break;
|
||||
} else if (identifierEquals("TYPE")) {
|
||||
@@ -1731,6 +1897,11 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
stmt.setAuthid(authid);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SEMI) {
|
||||
lexer.nextToken();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.IS) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
@@ -1765,4 +1936,80 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
return new OracleUpdateParser(this.lexer).parseUpdateStatement();
|
||||
}
|
||||
|
||||
public SQLStatement parseCreatePackage() {
|
||||
accept(Token.CREATE);
|
||||
|
||||
boolean repalce = false;
|
||||
if (lexer.token() == Token.OR) {
|
||||
lexer.nextToken();
|
||||
accept(Token.REPLACE);
|
||||
repalce = true;
|
||||
}
|
||||
|
||||
acceptIdentifier("PACKAGE");
|
||||
|
||||
OracleCreatePackageStatement stmt = new OracleCreatePackageStatement();
|
||||
stmt.setOrReplace(repalce);
|
||||
|
||||
if (identifierEquals("BODY")) {
|
||||
lexer.nextToken();
|
||||
stmt.setBody(true);
|
||||
}
|
||||
|
||||
SQLName pkgName = this.exprParser.name();
|
||||
stmt.setName(pkgName);
|
||||
|
||||
if (lexer.token() == Token.IS) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
accept(Token.AS);
|
||||
}
|
||||
|
||||
// this.parseStatementList(stmt.getStatements(), -1, stmt);
|
||||
for (;;) {
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
|
||||
SQLDeclareStatement varDecl = new SQLDeclareStatement();
|
||||
varDecl.setDbType(dbType);
|
||||
varDecl.setParent(stmt);
|
||||
|
||||
SQLDeclareItem varItem = new SQLDeclareItem();
|
||||
|
||||
SQLName name = this.exprParser.name();
|
||||
varItem.setName(name);
|
||||
|
||||
varItem.setDataType(this.exprParser.parseDataType());
|
||||
varItem.setParent(varDecl);
|
||||
|
||||
varDecl.getItems().add(varItem);
|
||||
|
||||
stmt.getStatements().add(varDecl);
|
||||
accept(Token.SEMI);
|
||||
} else if (lexer.token() == Token.FUNCTION) {
|
||||
SQLStatement function = this.parseFunction();
|
||||
function.setParent(stmt);
|
||||
stmt.getStatements().add(function);
|
||||
accept(Token.SEMI);
|
||||
} else if (lexer.token() == Token.PROCEDURE) {
|
||||
SQLStatement proc = this.parseCreateProcedure();
|
||||
proc.setParent(stmt);
|
||||
stmt.getStatements().add(proc);
|
||||
accept(Token.SEMI);
|
||||
} else if (lexer.token() == Token.END) {
|
||||
break;
|
||||
} else {
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
}
|
||||
|
||||
accept(Token.END);
|
||||
|
||||
if (identifierEquals(pkgName.getSimpleName())) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
accept(Token.SEMI);
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,4 +460,8 @@ public interface OracleASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(OracleCreateTableStatement.OIDIndex x);
|
||||
|
||||
void endVisit(OracleCreateTableStatement.OIDIndex x);
|
||||
|
||||
boolean visit(OracleCreatePackageStatement x);
|
||||
|
||||
void endVisit(OracleCreatePackageStatement x);
|
||||
}
|
||||
|
||||
+10
@@ -1109,4 +1109,14 @@ public class OracleASTVisitorAdapter extends SQLASTVisitorAdapter implements Ora
|
||||
public void endVisit(OracleCreateTableStatement.OIDIndex x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OracleCreatePackageStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OracleCreatePackageStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+127
-4
@@ -116,14 +116,16 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
if (x instanceof OraclePLSQLCommitStatement
|
||||
|| x instanceof OracleLabelStatement
|
||||
|| x instanceof OracleExceptionStatement.Item
|
||||
|| x instanceof OracleExceptionStatement) {
|
||||
|| x instanceof OracleExceptionStatement
|
||||
|| x instanceof OracleCreatePackageStatement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (parent instanceof SQLCreateProcedureStatement
|
||||
|| parent instanceof OracleExceptionStatement.Item
|
||||
|| parent instanceof OracleForStatement) {
|
||||
|| parent instanceof OracleForStatement
|
||||
|| parent instanceof SQLCreateFunctionStatement) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1358,9 +1360,14 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
if (x.getParameters().size() != 0) {
|
||||
incrementIndent();
|
||||
if (x.getParent() instanceof SQLCreateProcedureStatement) {
|
||||
printIndent();
|
||||
SQLCreateProcedureStatement procedureStatement = (SQLCreateProcedureStatement) x.getParent();
|
||||
if (procedureStatement.isCreate()) {
|
||||
printIndent();
|
||||
}
|
||||
}
|
||||
if (!(x.getParent() instanceof SQLCreateProcedureStatement)) {
|
||||
if (!(x.getParent() instanceof SQLCreateProcedureStatement
|
||||
|| x.getParent() instanceof SQLCreateFunctionStatement)
|
||||
) {
|
||||
print0(ucase ? "DECLARE" : "declare");
|
||||
println();
|
||||
}
|
||||
@@ -2590,6 +2597,77 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
|
||||
SQLStatement block = x.getBlock();
|
||||
|
||||
if (!create) {
|
||||
println();
|
||||
print("IS");
|
||||
println();
|
||||
} else {
|
||||
println();
|
||||
if (block instanceof SQLBlockStatement) {
|
||||
SQLBlockStatement blockStatement = (SQLBlockStatement) block;
|
||||
if (blockStatement.getParameters().size() > 0 || authid != null) {
|
||||
println(ucase ? "AS" : "as");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String javaCallSpec = x.getJavaCallSpec();
|
||||
if (javaCallSpec != null) {
|
||||
print0(ucase ? "LANGUAGE JAVA NAME '" : "language java name '");
|
||||
print0(javaCallSpec);
|
||||
print('\'');
|
||||
return false;
|
||||
}
|
||||
|
||||
block.accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLCreateFunctionStatement x) {
|
||||
boolean create = x.isCreate();
|
||||
if (!create) {
|
||||
print0(ucase ? "FUNCTION " : "function ");
|
||||
} else if (x.isOrReplace()) {
|
||||
print0(ucase ? "CREATE OR REPLACE FUNCTION " : "create or replace function ");
|
||||
} else {
|
||||
print0(ucase ? "CREATE FUNCTION " : "create function ");
|
||||
}
|
||||
x.getName().accept(this);
|
||||
|
||||
int paramSize = x.getParameters().size();
|
||||
|
||||
if (paramSize > 0) {
|
||||
print0(" (");
|
||||
incrementIndent();
|
||||
println();
|
||||
|
||||
for (int i = 0; i < paramSize; ++i) {
|
||||
if (i != 0) {
|
||||
print0(", ");
|
||||
println();
|
||||
}
|
||||
SQLParameter param = x.getParameters().get(i);
|
||||
param.accept(this);
|
||||
}
|
||||
|
||||
decrementIndent();
|
||||
println();
|
||||
print(')');
|
||||
}
|
||||
|
||||
println();
|
||||
print(ucase ? "RETURN " : "return ");
|
||||
x.getReturnDataType().accept(this);
|
||||
|
||||
SQLName authid = x.getAuthid();
|
||||
if (authid != null) {
|
||||
print(ucase ? " AUTHID " : " authid ");
|
||||
authid.accept(this);
|
||||
}
|
||||
|
||||
SQLStatement block = x.getBlock();
|
||||
|
||||
if (!create) {
|
||||
println();
|
||||
println("IS");
|
||||
@@ -3125,4 +3203,49 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
public void endVisit(OracleCreateTableStatement.OIDIndex x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OracleCreatePackageStatement x) {
|
||||
if (x.isOrReplace()) {
|
||||
print0(ucase ? "CREATE OR REPLACE PACKAGE " : "create or replace procedure ");
|
||||
} else {
|
||||
print0(ucase ? "CREATE PACKAGE " : "create procedure ");
|
||||
}
|
||||
|
||||
if (x.isBody()) {
|
||||
print0(ucase ? "BODY " : "body ");
|
||||
}
|
||||
|
||||
x.getName().accept(this);
|
||||
|
||||
if (x.isBody()) {
|
||||
println();
|
||||
print0(ucase ? "BEGIN" : "begin");
|
||||
}
|
||||
|
||||
incrementIndent();
|
||||
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
println();
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
|
||||
decrementIndent();
|
||||
|
||||
if (x.isBody()) {
|
||||
println();
|
||||
print0(ucase ? "END " : "end ");
|
||||
x.getName().accept(this);
|
||||
print(';');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OracleCreatePackageStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -1447,4 +1447,14 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
public void endVisit(OracleCreateTableStatement.OIDIndex x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OracleCreatePackageStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OracleCreatePackageStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2017 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.sql.dialect.sqlserver.ast.stmt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDeclareItem;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
|
||||
|
||||
public class SQLServerDeclareStatement extends SQLServerObjectImpl implements SQLServerStatement {
|
||||
|
||||
protected List<SQLDeclareItem> items = new ArrayList<SQLDeclareItem>();
|
||||
|
||||
private String dbType;
|
||||
|
||||
@Override
|
||||
public void accept0(SQLServerASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
this.acceptChild(visitor, items);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLDeclareItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void addItem(SQLDeclareItem item) {
|
||||
if (item != null) {
|
||||
item.setParent(this);
|
||||
}
|
||||
this.items.add(item);
|
||||
}
|
||||
|
||||
public String getDbType() {
|
||||
return dbType;
|
||||
}
|
||||
|
||||
public void setDbType(String dbType) {
|
||||
this.dbType = dbType;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -29,7 +29,7 @@ import com.alibaba.druid.sql.ast.statement.*;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerDeclareStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -155,7 +155,7 @@ public class SQLServerStatementParser extends SQLStatementParser {
|
||||
public SQLStatement parseDeclare() {
|
||||
this.accept(Token.DECLARE);
|
||||
|
||||
SQLServerDeclareStatement declareStatement = new SQLServerDeclareStatement();
|
||||
SQLDeclareStatement declareStatement = new SQLDeclareStatement();
|
||||
|
||||
for (;;) {
|
||||
SQLDeclareItem item = new SQLDeclareItem();
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -70,10 +69,6 @@ public interface SQLServerASTVisitor extends SQLASTVisitor {
|
||||
|
||||
void endVisit(SQLServerOutput x);
|
||||
|
||||
boolean visit(SQLServerDeclareStatement x);
|
||||
|
||||
void endVisit(SQLServerDeclareStatement x);
|
||||
|
||||
boolean visit(SQLServerSelect x);
|
||||
|
||||
void endVisit(SQLServerSelect x);
|
||||
|
||||
+8
-21
@@ -21,7 +21,6 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -124,16 +123,6 @@ public class SQLServerASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerDeclareStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerDeclareStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerSelect x) {
|
||||
return true;
|
||||
@@ -174,16 +163,14 @@ public class SQLServerASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(SQLServerParameter x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(SQLServerParameter x) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-13
@@ -25,7 +25,6 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -385,18 +384,6 @@ public class SQLServerOutputVisitor extends SQLASTOutputVisitor implements SQLSe
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
this.printAndAccept(x.getItems(), ", ");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerDeclareStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLBlockStatement x) {
|
||||
print0(ucase ? "BEGIN" : "begin");
|
||||
|
||||
-19
@@ -17,8 +17,6 @@ package com.alibaba.druid.sql.dialect.sqlserver.visitor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDeclareItem;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput;
|
||||
@@ -27,7 +25,6 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerDeclareStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -153,22 +150,6 @@ public class SQLServerSchemaStatVisitor extends SchemaStatVisitor implements SQL
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerDeclareStatement x) {
|
||||
for (SQLDeclareItem item : x.getItems()) {
|
||||
item.setParent(x);
|
||||
|
||||
SQLExpr name = item.getName();
|
||||
this.variants.put(name.toString(), name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerDeclareStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerSelect x) {
|
||||
return super.visit(x);
|
||||
|
||||
Reference in New Issue
Block a user