mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -19,7 +19,7 @@ public final class VERSION {
|
||||
|
||||
public final static int MajorVersion = 1;
|
||||
public final static int MinorVersion = 0;
|
||||
public final static int RevisionVersion = 16;
|
||||
public final static int RevisionVersion = 17;
|
||||
|
||||
public static String getVersionNumber() {
|
||||
return VERSION.MajorVersion + "." + VERSION.MinorVersion + "." + VERSION.RevisionVersion;
|
||||
|
||||
@@ -32,8 +32,17 @@ public class MySqlParameter extends MySqlObjectImpl {
|
||||
private SQLExpr name;
|
||||
private SQLDataType dataType;
|
||||
private SQLExpr defaultValue;
|
||||
private ParameterType paramType;
|
||||
|
||||
public SQLExpr getDefaultValue() {
|
||||
public ParameterType getParamType() {
|
||||
return paramType;
|
||||
}
|
||||
|
||||
public void setParamType(ParameterType paramType) {
|
||||
this.paramType = paramType;
|
||||
}
|
||||
|
||||
public SQLExpr getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -66,5 +75,15 @@ public class MySqlParameter extends MySqlObjectImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
/**
|
||||
* mysql procedure parameter type
|
||||
*/
|
||||
public static enum ParameterType
|
||||
{
|
||||
DEFAULT,
|
||||
IN,//in
|
||||
OUT,//out
|
||||
INOUT//inout
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 1999-2101 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.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSourceImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
// just for alibaba mysql
|
||||
public class MySqlUpdateTableSource extends SQLTableSourceImpl {
|
||||
|
||||
private MySqlUpdateStatement update;
|
||||
|
||||
public MySqlUpdateTableSource(MySqlUpdateStatement update){
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor instanceof MySqlASTVisitor) {
|
||||
accept0((MySqlASTVisitor) visitor);
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, update);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public MySqlUpdateStatement getUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public void setUpdate(MySqlUpdateStatement update) {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,11 +19,16 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLSetQuantifier;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelect;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQuery;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUnionQuery;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUnionQueryTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlForceIndexHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlIndexHint;
|
||||
@@ -32,8 +37,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectGroupBy;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
@@ -166,6 +173,94 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
public SQLTableSource parseTableSource() {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
SQLTableSource tableSource;
|
||||
if (lexer.token() == Token.SELECT || lexer.token() == Token.WITH) {
|
||||
SQLSelect select = select();
|
||||
accept(Token.RPAREN);
|
||||
SQLSelectQuery query = queryRest(select.getQuery());
|
||||
if (query instanceof SQLUnionQuery) {
|
||||
tableSource = new SQLUnionQueryTableSource((SQLUnionQuery) query);
|
||||
} else {
|
||||
tableSource = new SQLSubqueryTableSource(select);
|
||||
}
|
||||
} else if (lexer.token() == Token.LPAREN) {
|
||||
tableSource = parseTableSource();
|
||||
accept(Token.RPAREN);
|
||||
} else {
|
||||
tableSource = parseTableSource();
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
return parseTableSourceRest(tableSource);
|
||||
}
|
||||
|
||||
if(lexer.token() == Token.UPDATE) {
|
||||
SQLTableSource tableSource = new MySqlUpdateTableSource(parseUpdateStatment());
|
||||
return parseTableSourceRest(tableSource);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SELECT) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
|
||||
SQLExprTableSource tableReference = new SQLExprTableSource();
|
||||
|
||||
parseTableSourceQueryTableExpr(tableReference);
|
||||
|
||||
SQLTableSource tableSrc = parseTableSourceRest(tableReference);
|
||||
|
||||
if (lexer.hasComment() && lexer.isKeepComments()) {
|
||||
tableSrc.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
|
||||
return tableSrc;
|
||||
}
|
||||
|
||||
private MySqlUpdateStatement parseUpdateStatment() {
|
||||
MySqlUpdateStatement update = new MySqlUpdateStatement();
|
||||
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("LOW_PRIORITY")) {
|
||||
lexer.nextToken();
|
||||
update.setLowPriority(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
update.setIgnore(true);
|
||||
}
|
||||
|
||||
SQLTableSource updateTableSource = this.exprParser.createSelectParser().parseTableSource();
|
||||
update.setTableSource(updateTableSource);
|
||||
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
SQLUpdateSetItem item = this.exprParser.parseUpdateSetItem();
|
||||
update.addItem(item);
|
||||
|
||||
if (lexer.token() != Token.COMMA) {
|
||||
break;
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.WHERE)) {
|
||||
lexer.nextToken();
|
||||
update.setWhere(this.exprParser.expr());
|
||||
}
|
||||
|
||||
update.setOrderBy(this.exprParser.parseOrderBy());
|
||||
update.setLimit(parseLimit());
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
protected void parseInto(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() == (Token.INTO)) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -73,6 +73,7 @@ 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.MySqlLoopStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlParameter;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlParameter.ParameterType;
|
||||
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;
|
||||
@@ -2785,7 +2786,28 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
parameter.setDataType(dataType);
|
||||
|
||||
parameter.setDefaultValue(new SQLQueryExpr(select));
|
||||
|
||||
} else if (lexer.token() == Token.IN || lexer.token() == Token.OUT || lexer.token() == Token.INOUT) {
|
||||
|
||||
if(lexer.token()==Token.IN)
|
||||
{
|
||||
parameter.setParamType(ParameterType.IN);
|
||||
}
|
||||
else if(lexer.token()==Token.OUT)
|
||||
{
|
||||
parameter.setParamType(ParameterType.OUT);
|
||||
}
|
||||
else if(lexer.token()==Token.INOUT)
|
||||
{
|
||||
parameter.setParamType(ParameterType.INOUT);
|
||||
}
|
||||
lexer.nextToken();
|
||||
|
||||
parameter.setName(this.exprParser.name());
|
||||
|
||||
parameter.setDataType(this.exprParser.parseDataType());
|
||||
} else {
|
||||
parameter.setParamType(ParameterType.DEFAULT);//default parameter type is in
|
||||
parameter.setName(this.exprParser.name());
|
||||
parameter.setDataType(this.exprParser.parseDataType());
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnlockTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
@@ -650,5 +651,9 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(MySqlCursorDeclareStatement x);
|
||||
|
||||
void endVisit(MySqlCursorDeclareStatement x);
|
||||
|
||||
boolean visit(MySqlUpdateTableSource x);
|
||||
|
||||
void endVisit(MySqlUpdateTableSource x);
|
||||
|
||||
} //
|
||||
|
||||
@@ -141,6 +141,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnlockTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;
|
||||
|
||||
public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySqlASTVisitor {
|
||||
@@ -1466,5 +1467,15 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateTableSource x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlUpdateTableSource x) {
|
||||
|
||||
}
|
||||
|
||||
} //
|
||||
|
||||
@@ -59,6 +59,7 @@ 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.MySqlLoopStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlParameter;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlParameter.ParameterType;
|
||||
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;
|
||||
@@ -167,6 +168,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnlockTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
|
||||
|
||||
public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTVisitor {
|
||||
@@ -3277,6 +3279,19 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
decrementIndent();
|
||||
|
||||
} else {
|
||||
|
||||
if(x.getParamType()==ParameterType.IN)
|
||||
{
|
||||
print("IN ");
|
||||
}
|
||||
else if(x.getParamType()==ParameterType.OUT)
|
||||
{
|
||||
print("OUT ");
|
||||
}
|
||||
else if(x.getParamType()==ParameterType.INOUT)
|
||||
{
|
||||
print("INOUT ");
|
||||
}
|
||||
x.getName().accept(this);
|
||||
print(" ");
|
||||
|
||||
@@ -3571,4 +3586,17 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateTableSource x) {
|
||||
MySqlUpdateStatement update = x.getUpdate();
|
||||
if (update != null) {
|
||||
update.accept0(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlUpdateTableSource x) {
|
||||
|
||||
}
|
||||
} //
|
||||
|
||||
@@ -156,6 +156,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnionQuery;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUnlockTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
|
||||
import com.alibaba.druid.stat.TableStat;
|
||||
import com.alibaba.druid.stat.TableStat.Mode;
|
||||
@@ -1570,5 +1571,18 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateTableSource x) {
|
||||
if (x.getUpdate() != null) {
|
||||
return this.visit(x.getUpdate());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlUpdateTableSource x) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 1999-2101 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.odps.ast;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.odps.visitor.OdpsASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class OdpsListStmt extends SQLStatementImpl implements SQLStatement {
|
||||
|
||||
private SQLExpr object;
|
||||
|
||||
public OdpsListStmt(){
|
||||
super(JdbcConstants.ODPS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((OdpsASTVisitor) visitor);
|
||||
}
|
||||
|
||||
protected void accept0(OdpsASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, object);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void setObject(SQLExpr object) {
|
||||
if (object != null) {
|
||||
object.setParent(this);
|
||||
}
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 1999-2101 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.odps.ast;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.odps.visitor.OdpsASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class OdpsShowGrantsStmt extends SQLStatementImpl implements SQLStatement {
|
||||
|
||||
private SQLExpr user;
|
||||
|
||||
private SQLExpr objectType;
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((OdpsASTVisitor) visitor);
|
||||
}
|
||||
|
||||
public void accept0(OdpsASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, user);
|
||||
acceptChild(visitor, objectType);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(SQLExpr user) {
|
||||
if (user != null) {
|
||||
user.setParent(this);
|
||||
}
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public SQLExpr getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public void setObjectType(SQLExpr objectType) {
|
||||
if (objectType != null) {
|
||||
objectType.setParent(this);
|
||||
}
|
||||
this.objectType = objectType;
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,11 @@ import com.alibaba.druid.sql.dialect.odps.ast.OdpsAddStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsListStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsReadStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsStatisticClause;
|
||||
@@ -158,6 +160,18 @@ public class OdpsStatementParser extends SQLStatementParser {
|
||||
statementList.add(stmt);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(identifierEquals("LIST")) {
|
||||
OdpsListStmt stmt = new OdpsListStmt();
|
||||
|
||||
lexer.nextToken();
|
||||
stmt.setObject(this.exprParser.expr());
|
||||
|
||||
statementList.add(stmt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -318,6 +332,24 @@ public class OdpsStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("GRANTS")) {
|
||||
lexer.nextToken();
|
||||
OdpsShowGrantsStmt stmt = new OdpsShowGrantsStmt();
|
||||
|
||||
if (lexer.token() == Token.FOR) {
|
||||
lexer.nextToken();
|
||||
stmt.setUser(this.exprParser.expr());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.ON) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("type");
|
||||
stmt.setObjectType(this.exprParser.expr());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
|
||||
@@ -371,6 +403,5 @@ public class OdpsStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsListStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsReadStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsStatisticClause;
|
||||
@@ -103,4 +105,12 @@ public interface OdpsASTVisitor extends SQLASTVisitor {
|
||||
void endVisit(OdpsReadStatement x);
|
||||
|
||||
boolean visit(OdpsReadStatement x);
|
||||
|
||||
void endVisit(OdpsShowGrantsStmt x);
|
||||
|
||||
boolean visit(OdpsShowGrantsStmt x);
|
||||
|
||||
void endVisit(OdpsListStmt x);
|
||||
|
||||
boolean visit(OdpsListStmt x);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsListStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsReadStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsStatisticClause;
|
||||
@@ -213,4 +215,24 @@ public class OdpsASTVisitorAdapter extends SQLASTVisitorAdapter implements OdpsA
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsShowGrantsStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsShowGrantsStmt x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsListStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsListStmt x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsListStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsReadStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsStatisticClause;
|
||||
@@ -753,4 +755,38 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
print(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsShowGrantsStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsShowGrantsStmt x) {
|
||||
print("SHOW GRANTS");
|
||||
if (x.getUser() != null) {
|
||||
print(" FOR ");
|
||||
x.getUser().accept(this);
|
||||
}
|
||||
|
||||
if (x.getObjectType() != null) {
|
||||
print(" ON TYPE ");
|
||||
x.getObjectType().accept(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsListStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsListStmt x) {
|
||||
print("LIST ");
|
||||
if (x.getObject() != null) {
|
||||
x.getObject().accept(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsListStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsReadStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsStatisticClause;
|
||||
@@ -216,4 +218,24 @@ public class OdpsSchemaStatVisitor extends SchemaStatVisitor implements OdpsASTV
|
||||
public boolean visit(OdpsReadStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsShowGrantsStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsShowGrantsStmt x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(OdpsListStmt x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsListStmt x) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+40
-7
@@ -1,8 +1,3 @@
|
||||
package com.alibaba.druid.sql.dialect.sqlserver.ast.stmt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Copyright 1999-2101 Alibaba Group Holding Ltd.
|
||||
*
|
||||
@@ -18,6 +13,11 @@ import java.util.List;
|
||||
* 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.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerObjectImpl;
|
||||
@@ -28,7 +28,7 @@ public class SQLServerExecStatement extends SQLServerObjectImpl implements SQLSe
|
||||
|
||||
private SQLName returnStatus;
|
||||
private SQLName moduleName;
|
||||
private List<SQLExpr> parameters = new ArrayList<SQLExpr>();
|
||||
private List<SQLServerParameter> parameters = new ArrayList<SQLServerParameter>();
|
||||
private String dbType;
|
||||
|
||||
public SQLName getModuleName() {
|
||||
@@ -39,7 +39,7 @@ public class SQLServerExecStatement extends SQLServerObjectImpl implements SQLSe
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public List<SQLExpr> getParameters() {
|
||||
public List<SQLServerParameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@@ -67,4 +67,37 @@ public class SQLServerExecStatement extends SQLServerObjectImpl implements SQLSe
|
||||
public void setDbType(String dbType) {
|
||||
this.dbType = dbType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description: SQLServer execute Parameter statement
|
||||
* @author zz email:455910092@qq.com
|
||||
* @date 2015-9-20
|
||||
* @version V1.0
|
||||
*/
|
||||
public static class SQLServerParameter extends SQLServerObjectImpl
|
||||
{
|
||||
private SQLExpr expr;
|
||||
private boolean type;//sql server 支持参数只有input 和 output 两种
|
||||
public SQLExpr getExpr() {
|
||||
return expr;
|
||||
}
|
||||
public void setExpr(SQLExpr expr) {
|
||||
this.expr = expr;
|
||||
}
|
||||
public boolean getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(boolean type) {
|
||||
this.type = type;
|
||||
}
|
||||
@Override
|
||||
public void accept0(SQLServerASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+45
-3
@@ -15,9 +15,12 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.sqlserver.parser;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
@@ -43,6 +46,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerSetTransactionIsolationLevelStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerWaitForStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerExecStatement.SQLServerParameter;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
@@ -76,7 +80,7 @@ public class SQLServerStatementParser extends SQLStatementParser {
|
||||
SQLServerExecStatement execStmt = new SQLServerExecStatement();
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
this.exprParser.exprList(execStmt.getParameters(), execStmt);
|
||||
this.parseExecParameter(execStmt.getParameters(), execStmt);
|
||||
accept(Token.RPAREN);
|
||||
} else {
|
||||
SQLName sqlNameName = this.exprParser.name();
|
||||
@@ -88,8 +92,8 @@ public class SQLServerStatementParser extends SQLStatementParser {
|
||||
} else {
|
||||
execStmt.setModuleName(sqlNameName);
|
||||
}
|
||||
|
||||
this.exprParser.exprList(execStmt.getParameters(), execStmt);
|
||||
|
||||
this.parseExecParameter(execStmt.getParameters(), execStmt);
|
||||
}
|
||||
statementList.add(execStmt);
|
||||
return true;
|
||||
@@ -122,6 +126,44 @@ public class SQLServerStatementParser extends SQLStatementParser {
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* SQLServer parse Parameter statement support out type
|
||||
* @author zz email:455910092@qq.com
|
||||
* @date 2015-9-20
|
||||
*/
|
||||
public void parseExecParameter(Collection<SQLServerParameter> exprCol, SQLObject parent)
|
||||
{
|
||||
if (lexer.token() == Token.RPAREN || lexer.token() == Token.RBRACKET) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.EOF) {
|
||||
return;
|
||||
}
|
||||
SQLServerParameter param=new SQLServerParameter();
|
||||
SQLExpr expr=this.exprParser.expr();
|
||||
expr.setParent(parent);
|
||||
param.setExpr(expr);
|
||||
if(lexer.token()==Token.OUT)
|
||||
{
|
||||
param.setType(true);
|
||||
accept(Token.OUT);
|
||||
}
|
||||
exprCol.add(param);
|
||||
while (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
param=new SQLServerParameter();
|
||||
expr=this.exprParser.expr();
|
||||
expr.setParent(parent);
|
||||
param.setExpr(expr);
|
||||
if(lexer.token()==Token.OUT)
|
||||
{
|
||||
param.setType(true);
|
||||
accept(Token.OUT);
|
||||
}
|
||||
exprCol.add(param);
|
||||
}
|
||||
}
|
||||
|
||||
public SQLStatement parseDeclare() {
|
||||
this.accept(Token.DECLARE);
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerBlockStatement;
|
||||
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.SQLServerIfStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerIfStatement.Else;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -117,5 +118,9 @@ public interface SQLServerASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(SQLServerWaitForStatement x);
|
||||
|
||||
void endVisit(SQLServerWaitForStatement x);
|
||||
|
||||
boolean visit(SQLServerParameter x);
|
||||
|
||||
void endVisit(SQLServerParameter x);
|
||||
|
||||
}
|
||||
|
||||
+13
@@ -26,6 +26,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerBlockStatement;
|
||||
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.SQLServerIfStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerIfStatement.Else;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -238,4 +239,16 @@ public class SQLServerASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
@@ -35,6 +35,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerBlockStatement;
|
||||
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.SQLServerIfStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerIfStatement.Else;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -690,4 +691,21 @@ public class SQLServerOutputVisitor extends SQLASTOutputVisitor implements SQLSe
|
||||
public void endVisit(SQLServerWaitForStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
x.getExpr().accept(this);
|
||||
if(x.getType())
|
||||
{
|
||||
print(" OUT");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -33,6 +33,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerBlockStatement;
|
||||
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.SQLServerIfStatement;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerIfStatement.Else;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement;
|
||||
@@ -274,4 +275,16 @@ public class SQLServerSchemaStatVisitor extends SchemaStatVisitor implements SQL
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLServerParameter x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class Keywords {
|
||||
map.put("GRANT", Token.GRANT);
|
||||
map.put("REVOKE", Token.REVOKE);
|
||||
|
||||
// MySql procedure by:zz
|
||||
// MySql procedure: add by zz
|
||||
map.put("WHILE", Token.WHILE);
|
||||
map.put("DO", Token.DO);
|
||||
map.put("DECLARE", Token.DECLARE);
|
||||
@@ -148,6 +148,8 @@ public class Keywords {
|
||||
map.put("CLOSE", Token.CLOSE);
|
||||
map.put("CURSOR", Token.CURSOR);
|
||||
map.put("FETCH", Token.FETCH);
|
||||
map.put("OUT", Token.OUT);
|
||||
map.put("INOUT", Token.INOUT);
|
||||
|
||||
DEFAULT_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
@@ -330,6 +330,7 @@ public class SQLExprParser extends SQLParser {
|
||||
case TYPE:
|
||||
case OPEN:
|
||||
case REPEAT:
|
||||
case TABLE:
|
||||
sqlExpr = new SQLIdentifierExpr(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
break;
|
||||
|
||||
@@ -355,7 +355,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return tableSrc;
|
||||
}
|
||||
|
||||
private void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) {
|
||||
protected void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) {
|
||||
if (lexer.token() == Token.LITERAL_ALIAS || lexer.token() == Token.IDENTIFIED
|
||||
|| lexer.token() == Token.LITERAL_CHARS) {
|
||||
tableReference.setExpr(this.exprParser.name());
|
||||
|
||||
@@ -128,7 +128,7 @@ public enum Token {
|
||||
SHOW("SHOW"),
|
||||
REPLACE("REPLACE"),
|
||||
|
||||
// MySql procedure by:zz
|
||||
// MySql procedure add by zz
|
||||
WHILE("WHILE"),
|
||||
DO("DO"),
|
||||
LEAVE("LEAVE"),
|
||||
@@ -137,6 +137,8 @@ public enum Token {
|
||||
UNTIL("UNTIL"),
|
||||
OPEN("OPEN"),
|
||||
CLOSE("CLOSE"),
|
||||
OUT("OUT"),
|
||||
INOUT("INOUT"),
|
||||
|
||||
//postgresql
|
||||
WINDOW("WINDOW"),
|
||||
|
||||
@@ -1049,6 +1049,20 @@ public class SQLEvalVisitorUtils {
|
||||
x.putAttribute(EVAL_VALUE, result);
|
||||
break;
|
||||
}
|
||||
case BooleanAnd:
|
||||
{
|
||||
boolean first = eq(leftValue, true);
|
||||
boolean second = eq(rightValue, true);
|
||||
x.putAttribute(EVAL_VALUE, first&&second);
|
||||
break;
|
||||
}
|
||||
case BooleanOr:
|
||||
{
|
||||
boolean first = eq(leftValue, true);
|
||||
boolean second = eq(rightValue, true);
|
||||
x.putAttribute(EVAL_VALUE, first||second);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user