mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser support subpartition syntax
This commit is contained in:
+12
@@ -44,6 +44,8 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
|
||||
private List<SQLCommentHint> optionHints = new ArrayList<SQLCommentHint>();
|
||||
|
||||
private SQLExprTableSource like;
|
||||
|
||||
private SQLName tableGroup;
|
||||
|
||||
public MySqlCreateTableStatement(){
|
||||
super (JdbcConstants.MYSQL);
|
||||
@@ -157,4 +159,14 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
|
||||
public void setOptionHints(List<SQLCommentHint> optionHints) {
|
||||
this.optionHints = optionHints;
|
||||
}
|
||||
|
||||
|
||||
public SQLName getTableGroup() {
|
||||
return tableGroup;
|
||||
}
|
||||
|
||||
|
||||
public void setTableGroup(SQLName tableGroup) {
|
||||
this.tableGroup = tableGroup;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-9
@@ -22,14 +22,16 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitioningClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
|
||||
public abstract class MySqlPartitioningClause extends MySqlObjectImpl implements SQLPartitioningClause {
|
||||
public abstract class MySqlPartitionByClause extends MySqlObjectImpl implements SQLPartitioningClause {
|
||||
|
||||
private List<MySqlPartitioningDef> partitions = new ArrayList<MySqlPartitioningDef>();
|
||||
private List<MySqlPartitioningDef> partitions = new ArrayList<MySqlPartitioningDef>();
|
||||
|
||||
protected SQLExpr partitionCount;
|
||||
protected SQLExpr partitionsCount;
|
||||
|
||||
protected boolean linear;
|
||||
|
||||
protected MySqlSubPartitionByClause subPartitionBy;
|
||||
|
||||
protected boolean linear;
|
||||
|
||||
public List<MySqlPartitioningDef> getPartitions() {
|
||||
return partitions;
|
||||
}
|
||||
@@ -38,12 +40,12 @@ public abstract class MySqlPartitioningClause extends MySqlObjectImpl implements
|
||||
this.partitions = partitions;
|
||||
}
|
||||
|
||||
public SQLExpr getPartitionCount() {
|
||||
return partitionCount;
|
||||
public SQLExpr getPartitionsCount() {
|
||||
return partitionsCount;
|
||||
}
|
||||
|
||||
public void setPartitionCount(SQLExpr partitionCount) {
|
||||
this.partitionCount = partitionCount;
|
||||
public void setPartitionsCount(SQLExpr partitionsCount) {
|
||||
this.partitionsCount = partitionsCount;
|
||||
}
|
||||
|
||||
public boolean isLinear() {
|
||||
@@ -53,4 +55,13 @@ public abstract class MySqlPartitioningClause extends MySqlObjectImpl implements
|
||||
public void setLinear(boolean linear) {
|
||||
this.linear = linear;
|
||||
}
|
||||
|
||||
public MySqlSubPartitionByClause getSubPartitionBy() {
|
||||
return subPartitionBy;
|
||||
}
|
||||
|
||||
public void setSubPartitionBy(MySqlSubPartitionByClause subPartitionBy) {
|
||||
this.subPartitionBy = subPartitionBy;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -18,7 +18,7 @@ package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlPartitionByHash extends MySqlPartitioningClause {
|
||||
public class MySqlPartitionByHash extends MySqlPartitionByClause {
|
||||
|
||||
private SQLExpr expr;
|
||||
|
||||
@@ -29,8 +29,9 @@ public class MySqlPartitionByHash extends MySqlPartitioningClause {
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
acceptChild(visitor, partitionCount);
|
||||
acceptChild(visitor, partitionsCount);
|
||||
acceptChild(visitor, getPartitions());
|
||||
acceptChild(visitor, subPartitionBy);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
+3
-2
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlPartitionByKey extends MySqlPartitioningClause {
|
||||
public class MySqlPartitionByKey extends MySqlPartitionByClause {
|
||||
|
||||
private List<SQLName> columns = new ArrayList<SQLName>();
|
||||
|
||||
@@ -29,8 +29,9 @@ public class MySqlPartitionByKey extends MySqlPartitioningClause {
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, columns);
|
||||
acceptChild(visitor, partitionCount);
|
||||
acceptChild(visitor, partitionsCount);
|
||||
acceptChild(visitor, getPartitions());
|
||||
acceptChild(visitor, subPartitionBy);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
+3
-2
@@ -22,7 +22,7 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlPartitionByList extends MySqlPartitioningClause {
|
||||
public class MySqlPartitionByList extends MySqlPartitionByClause {
|
||||
|
||||
private SQLExpr expr;
|
||||
|
||||
@@ -33,8 +33,9 @@ public class MySqlPartitionByList extends MySqlPartitioningClause {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
acceptChild(visitor, columns);
|
||||
acceptChild(visitor, partitionCount);
|
||||
acceptChild(visitor, partitionsCount);
|
||||
acceptChild(visitor, getPartitions());
|
||||
acceptChild(visitor, subPartitionBy);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
+3
-10
@@ -22,7 +22,7 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlPartitionByRange extends MySqlPartitioningClause {
|
||||
public class MySqlPartitionByRange extends MySqlPartitionByClause {
|
||||
|
||||
private SQLExpr expr;
|
||||
|
||||
@@ -33,8 +33,9 @@ public class MySqlPartitionByRange extends MySqlPartitioningClause {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
acceptChild(visitor, columns);
|
||||
acceptChild(visitor, partitionCount);
|
||||
acceptChild(visitor, partitionsCount);
|
||||
acceptChild(visitor, getPartitions());
|
||||
acceptChild(visitor, subPartitionBy);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
@@ -50,14 +51,6 @@ public class MySqlPartitionByRange extends MySqlPartitioningClause {
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
public SQLExpr getPartitionCount() {
|
||||
return partitionCount;
|
||||
}
|
||||
|
||||
public void setPartitionCount(SQLExpr partitionCount) {
|
||||
this.partitionCount = partitionCount;
|
||||
}
|
||||
|
||||
public List<SQLName> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitioningClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
|
||||
public abstract class MySqlSubPartitionByClause extends MySqlObjectImpl implements SQLPartitioningClause {
|
||||
|
||||
protected SQLExpr subPartitionsCount;
|
||||
|
||||
protected boolean linear;
|
||||
|
||||
protected List<SQLAssignItem> options = new ArrayList<SQLAssignItem>();
|
||||
|
||||
public SQLExpr getSubPartitionsCount() {
|
||||
return subPartitionsCount;
|
||||
}
|
||||
|
||||
public void setSubPartitionsCount(SQLExpr subPartitionsCount) {
|
||||
this.subPartitionsCount = subPartitionsCount;
|
||||
}
|
||||
|
||||
public boolean isLinear() {
|
||||
return linear;
|
||||
}
|
||||
|
||||
public void setLinear(boolean linear) {
|
||||
this.linear = linear;
|
||||
}
|
||||
|
||||
public List<SQLAssignItem> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlSubPartitionByHash extends MySqlSubPartitionByClause {
|
||||
|
||||
private SQLExpr expr;
|
||||
|
||||
// for aliyun ads
|
||||
private boolean key;
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
acceptChild(visitor, subPartitionsCount);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
return expr;
|
||||
}
|
||||
|
||||
public void setExpr(SQLExpr expr) {
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
public boolean isKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(boolean key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlSubPartitionByKey extends MySqlSubPartitionByClause {
|
||||
|
||||
private List<SQLName> columns = new ArrayList<SQLName>();
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, columns);
|
||||
acceptChild(visitor, subPartitionsCount);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLName> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(List<SQLName> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlSubPartitionByList extends MySqlSubPartitionByClause {
|
||||
|
||||
private SQLExpr expr;
|
||||
|
||||
private List<SQLColumnDefinition> columns = new ArrayList<SQLColumnDefinition>();
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, expr);
|
||||
acceptChild(visitor, columns);
|
||||
acceptChild(visitor, subPartitionsCount);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
return expr;
|
||||
}
|
||||
|
||||
public void setExpr(SQLExpr expr) {
|
||||
if (expr != null) {
|
||||
expr.setParent(this);
|
||||
}
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
public List<SQLColumnDefinition> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(List<SQLColumnDefinition> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
}
|
||||
+142
-4
@@ -15,9 +15,12 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDataTypeImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLOrderingSpecification;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCheck;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
@@ -32,12 +35,16 @@ import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement.TableSpaceOption;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByList;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByRange;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitioningClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitioningDef;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLCreateTableParser;
|
||||
@@ -380,6 +387,14 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
stmt.getTableOptions().put("TABLESPACE", option);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("TABLEGROUP")) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLName tableGroup = this.exprParser.name();
|
||||
stmt.setTableGroup(tableGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("TYPE")) {
|
||||
lexer.nextToken();
|
||||
@@ -393,7 +408,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
|
||||
MySqlPartitioningClause partitionClause;
|
||||
MySqlPartitionByClause partitionClause;
|
||||
|
||||
boolean linera = false;
|
||||
if (identifierEquals("LINEAR")) {
|
||||
@@ -561,6 +576,8 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
stmt.setPartitioning(partitionClause);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -585,10 +602,131 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
protected void partitionClauseRest(MySqlPartitioningClause clause) {
|
||||
protected void partitionClauseRest(MySqlPartitionByClause clause) {
|
||||
if (identifierEquals("PARTITIONS")) {
|
||||
lexer.nextToken();
|
||||
clause.setPartitionCount(this.exprParser.expr());
|
||||
clause.setPartitionsCount(this.exprParser.expr());
|
||||
}
|
||||
|
||||
if (identifierEquals("PARTITION")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("NUM")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
clause.setPartitionsCount(this.exprParser.expr());
|
||||
|
||||
clause.putAttribute("ads.partition", Boolean.TRUE);
|
||||
}
|
||||
|
||||
if (identifierEquals("SUBPARTITION")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
|
||||
MySqlSubPartitionByClause subPartitionByClause = null;
|
||||
|
||||
boolean linear = false;
|
||||
if (identifierEquals("LINEAR")) {
|
||||
lexer.nextToken();
|
||||
linear = true;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.KEY) {
|
||||
MySqlSubPartitionByKey subPartitionKey = new MySqlSubPartitionByKey();
|
||||
lexer.nextToken();
|
||||
|
||||
if (linear) {
|
||||
clause.setLinear(true);
|
||||
}
|
||||
|
||||
accept(Token.LPAREN);
|
||||
for (;;) {
|
||||
subPartitionKey.getColumns().add(this.exprParser.name());
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
|
||||
subPartitionByClause = subPartitionKey;
|
||||
|
||||
} else if (identifierEquals("HASH")) {
|
||||
lexer.nextToken();
|
||||
MySqlSubPartitionByHash subPartitionHash = new MySqlSubPartitionByHash();
|
||||
|
||||
if (linear) {
|
||||
clause.setLinear(true);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.KEY) {
|
||||
lexer.nextToken();
|
||||
subPartitionHash.setKey(true);
|
||||
}
|
||||
|
||||
accept(Token.LPAREN);
|
||||
subPartitionHash.setExpr(this.exprParser.expr());
|
||||
accept(Token.RPAREN);
|
||||
subPartitionByClause = subPartitionHash;
|
||||
|
||||
} else if (identifierEquals("LIST")) {
|
||||
lexer.nextToken();
|
||||
MySqlSubPartitionByList subPartitionList = new MySqlSubPartitionByList();
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
SQLExpr expr = this.exprParser.expr();
|
||||
|
||||
if (expr instanceof SQLIdentifierExpr && (identifierEquals("bigint") || identifierEquals("long"))) {
|
||||
String dataType = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
|
||||
SQLColumnDefinition column = this.exprParser.createColumnDefinition();
|
||||
column.setName((SQLIdentifierExpr)expr);
|
||||
column.setDataType(new SQLDataTypeImpl(dataType));
|
||||
subPartitionList.getColumns().add(column);
|
||||
|
||||
subPartitionList.putAttribute("ads.subPartitionList", Boolean.TRUE);
|
||||
} else {
|
||||
subPartitionList.setExpr(expr);
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
} else {
|
||||
acceptIdentifier("COLUMNS");
|
||||
accept(Token.LPAREN);
|
||||
for (;;) {
|
||||
subPartitionList.getColumns().add(this.exprParser.parseColumn());
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
subPartitionByClause = subPartitionList;
|
||||
}
|
||||
|
||||
if (identifierEquals("SUBPARTITION")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("OPTIONS");
|
||||
accept(Token.LPAREN);
|
||||
|
||||
SQLAssignItem option = this.exprParser.parseAssignItem();
|
||||
accept(Token.RPAREN);
|
||||
|
||||
option.setParent(subPartitionByClause);
|
||||
|
||||
subPartitionByClause.getOptions().add(option);
|
||||
}
|
||||
|
||||
if (subPartitionByClause != null) {
|
||||
subPartitionByClause.setLinear(linear);
|
||||
|
||||
clause.setSubPartitionBy(subPartitionByClause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ 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.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.CobarShowStatus;
|
||||
@@ -122,6 +122,9 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTriggersStatem
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowVariantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStartTransactionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
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;
|
||||
@@ -604,5 +607,17 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(MySqlAlterTableAlterColumn x);
|
||||
|
||||
void endVisit(MySqlAlterTableAlterColumn x);
|
||||
|
||||
boolean visit(MySqlSubPartitionByHash x);
|
||||
|
||||
void endVisit(MySqlSubPartitionByHash x);
|
||||
|
||||
boolean visit(MySqlSubPartitionByKey x);
|
||||
|
||||
void endVisit(MySqlSubPartitionByKey x);
|
||||
|
||||
boolean visit(MySqlSubPartitionByList x);
|
||||
|
||||
void endVisit(MySqlSubPartitionByList x);
|
||||
|
||||
} //
|
||||
|
||||
+111
-79
@@ -33,9 +33,9 @@ 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.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.CobarShowStatus;
|
||||
@@ -127,6 +127,9 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTriggersStatem
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowVariantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStartTransactionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
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;
|
||||
@@ -135,6 +138,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateTableSource;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;
|
||||
|
||||
public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySqlASTVisitor {
|
||||
|
||||
@Override
|
||||
public boolean visit(Limit x) {
|
||||
return true;
|
||||
@@ -1209,9 +1213,9 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlHintStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlOrderingExpr x) {
|
||||
return true;
|
||||
@@ -1222,98 +1226,98 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlCaseStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareStatement x) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlCaseStatement x) {
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlDeclareStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSelectIntoStatement x) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSelectIntoStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlDeclareStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhenStatement x) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhenStatement x) {
|
||||
|
||||
}
|
||||
//add:end
|
||||
@Override
|
||||
public boolean visit(MySqlSelectIntoStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlLeaveStatement x) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlSelectIntoStatement x) {
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlLeaveStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIterateStatement x) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlWhenStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIterateStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlWhenStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRepeatStatement x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// add:end
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRepeatStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlLeaveStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCursorDeclareStatement x) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlLeaveStatement x) {
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlCursorDeclareStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIterateStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIterateStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRepeatStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRepeatStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCursorDeclareStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlCursorDeclareStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateTableSource x) {
|
||||
return true;
|
||||
}
|
||||
@@ -1330,7 +1334,35 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlAlterTableAlterColumn x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByKey x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByKey x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByHash x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByHash x) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByList x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByList x) {
|
||||
}
|
||||
|
||||
} //
|
||||
|
||||
+337
-230
@@ -63,9 +63,9 @@ 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.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.CobarShowStatus;
|
||||
@@ -96,6 +96,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadDataInFileStat
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadXmlStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlOptimizeStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByList;
|
||||
@@ -158,6 +159,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTriggersStatem
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowVariantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStartTransactionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
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;
|
||||
@@ -167,6 +172,7 @@ import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTVisitor {
|
||||
|
||||
{
|
||||
this.dbType = JdbcConstants.MYSQL;
|
||||
}
|
||||
@@ -371,12 +377,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (Boolean.TRUE == x.getAttribute("UNSIGNED")) {
|
||||
print0(ucase ? " UNSIGNED" : " unsigned");
|
||||
}
|
||||
|
||||
|
||||
if (Boolean.TRUE == x.getAttribute("ZEROFILL")) {
|
||||
print0(ucase ? " ZEROFILL" : " zerofill");
|
||||
}
|
||||
|
||||
|
||||
if (x instanceof SQLCharacterDataType) {
|
||||
SQLCharacterDataType charType = (SQLCharacterDataType) x;
|
||||
if (charType.getCharSetName() != null) {
|
||||
@@ -403,7 +408,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isHasBinary()) {
|
||||
print0(ucase ? " BINARY " : " binary ");
|
||||
}
|
||||
|
||||
|
||||
if (x.getCharSetName() != null) {
|
||||
print0(ucase ? " CHARACTER SET " : " character set ");
|
||||
print0(x.getCharSetName());
|
||||
@@ -411,11 +416,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(ucase ? " COLLATE " : " collate ");
|
||||
print0(x.getCollate());
|
||||
}
|
||||
}else if (x.getCollate() != null) {
|
||||
} else if (x.getCollate() != null) {
|
||||
print0(ucase ? " COLLATE " : " collate ");
|
||||
print0(x.getCollate());
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -522,6 +527,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
x.getPartitioning().accept(this);
|
||||
}
|
||||
|
||||
if (x.getTableGroup() != null) {
|
||||
println();
|
||||
print0(ucase ? "TABLEGROUP " : "tablegroup ");
|
||||
x.getTableGroup().accept(this);
|
||||
}
|
||||
|
||||
if (x.getSelect() != null) {
|
||||
incrementIndent();
|
||||
@@ -598,7 +609,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(ucase ? "PRIMARY KEY" : "primary key");
|
||||
|
||||
if (x.getIndexType() != null) {
|
||||
print0(ucase ? " USING " : " using ");;
|
||||
print0(ucase ? " USING " : " using ");
|
||||
;
|
||||
print0(x.getIndexType());
|
||||
}
|
||||
|
||||
@@ -649,7 +661,15 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
&& (!varName.startsWith("#")) //
|
||||
&& (!varName.startsWith("$")) //
|
||||
&& (!varName.startsWith(":"))) {
|
||||
print0("@@");
|
||||
|
||||
boolean subPartitionOption = false;
|
||||
if (x.getParent() != null) {
|
||||
subPartitionOption = x.getParent().getParent() instanceof MySqlSubPartitionByClause;
|
||||
}
|
||||
|
||||
if (!subPartitionOption) {
|
||||
print0("@@");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +751,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return false;
|
||||
}
|
||||
|
||||
if (("CONVERT".equalsIgnoreCase(x.getMethodName()))||"CHAR".equalsIgnoreCase(x.getMethodName())) {
|
||||
if (("CONVERT".equalsIgnoreCase(x.getMethodName())) || "CHAR".equalsIgnoreCase(x.getMethodName())) {
|
||||
if (x.getOwner() != null) {
|
||||
x.getOwner().accept(this);
|
||||
print('.');
|
||||
@@ -742,7 +762,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
String charset = (String) x.getAttribute("USING");
|
||||
if (charset != null) {
|
||||
print0(ucase ? " USING " : " using ");;
|
||||
print0(ucase ? " USING " : " using ");
|
||||
;
|
||||
print0(charset);
|
||||
}
|
||||
print(')');
|
||||
@@ -826,7 +847,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(ucase ? "EXECUTE " : "execute ");
|
||||
x.getStatementName().accept(this);
|
||||
if (x.getParameters().size() > 0) {
|
||||
print0(ucase ? " USING " : " using ");;
|
||||
print0(ucase ? " USING " : " using ");
|
||||
;
|
||||
printAndAccept(x.getParameters(), ", ");
|
||||
}
|
||||
return false;
|
||||
@@ -1050,8 +1072,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
x.getLinesTerminatedBy().accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(x.getIgnoreLinesNumber() != null) {
|
||||
|
||||
if (x.getIgnoreLinesNumber() != null) {
|
||||
print0(ucase ? " IGNORE " : " ignore ");
|
||||
x.getIgnoreLinesNumber().accept(this);
|
||||
print0(ucase ? " LINES" : " lines");
|
||||
@@ -1062,7 +1084,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(')');
|
||||
}
|
||||
|
||||
|
||||
if (x.getSetList().size() != 0) {
|
||||
print0(ucase ? " SET " : " set ");
|
||||
printAndAccept(x.getSetList(), ", ");
|
||||
@@ -1137,7 +1159,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isConsistentSnapshot()) {
|
||||
print0(ucase ? " WITH CONSISTENT SNAPSHOT" : " with consistent snapshot");
|
||||
}
|
||||
|
||||
|
||||
if (x.getHints() != null && x.getHints().size() > 0) {
|
||||
print(' ');
|
||||
printAndAccept(x.getHints(), " ");
|
||||
@@ -1227,9 +1249,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
@Override
|
||||
public boolean visit(MySqlShowColumnsStatement x) {
|
||||
if (x.isFull()) {
|
||||
print0(ucase ? "SHOW FULL COLUMNS" : "show full columns");
|
||||
print0(ucase ? "SHOW FULL COLUMNS" : "show full columns");
|
||||
} else {
|
||||
print0(ucase ? "SHOW COLUMNS": "show columns");
|
||||
print0(ucase ? "SHOW COLUMNS" : "show columns");
|
||||
}
|
||||
|
||||
if (x.getTable() != null) {
|
||||
@@ -1519,10 +1541,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(')');
|
||||
|
||||
if (x.getPartitionCount() != null) {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
x.getPartitionCount().accept(this);
|
||||
}
|
||||
printPartitionsCountAndSubPartitions(x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1544,10 +1563,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(')');
|
||||
}
|
||||
|
||||
if (x.getPartitionCount() != null) {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
x.getPartitionCount().accept(this);
|
||||
}
|
||||
printPartitionsCountAndSubPartitions(x);
|
||||
|
||||
List<MySqlPartitioningDef> partitions = x.getPartitions();
|
||||
int partitionsSize = partitions.size();
|
||||
@@ -1586,10 +1602,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(") ");
|
||||
}
|
||||
|
||||
if (x.getPartitionCount() != null) {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
x.getPartitionCount().accept(this);
|
||||
}
|
||||
printPartitionsCountAndSubPartitions(x);
|
||||
|
||||
List<MySqlPartitioningDef> partitions = x.getPartitions();
|
||||
int partitionsSize = partitions.size();
|
||||
@@ -1624,23 +1637,38 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
} else {
|
||||
print0(ucase ? "PARTITION BY HASH " : "partition by hash ");
|
||||
}
|
||||
|
||||
|
||||
if (x.isKey()) {
|
||||
print0(ucase ? "KEY" : "key");
|
||||
}
|
||||
|
||||
|
||||
print('(');
|
||||
x.getExpr().accept(this);
|
||||
print(')');
|
||||
|
||||
if (x.getPartitionCount() != null) {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
x.getPartitionCount().accept(this);
|
||||
}
|
||||
printPartitionsCountAndSubPartitions(x);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void printPartitionsCountAndSubPartitions(MySqlPartitionByClause x) {
|
||||
if (x.getPartitionsCount() != null) {
|
||||
|
||||
if (Boolean.TRUE.equals(x.getAttribute("ads.partition"))) {
|
||||
print0(ucase ? " PARTITION NUM " : " partition num ");
|
||||
} else {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
}
|
||||
|
||||
x.getPartitionsCount().accept(this);
|
||||
}
|
||||
|
||||
if (x.getSubPartitionBy() != null) {
|
||||
println();
|
||||
x.getSubPartitionBy().accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSelectQueryBlock x) {
|
||||
|
||||
@@ -1788,7 +1816,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSetTransactionStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2169,7 +2197,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
x.getTable().accept(this);
|
||||
}
|
||||
|
||||
|
||||
if (x.getHints() != null && x.getHints().size() > 0) {
|
||||
print(' ');
|
||||
printAndAccept(x.getHints(), " ");
|
||||
@@ -2515,7 +2543,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
@Override
|
||||
public boolean visit(SQLAlterTableAddColumn x) {
|
||||
print0(ucase ? "ADD COLUMN " : "add column ");
|
||||
|
||||
|
||||
if (x.getColumns().size() > 1) {
|
||||
print('(');
|
||||
}
|
||||
@@ -2529,7 +2557,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
} else if (x.isFirst()) {
|
||||
print0(ucase ? " FIRST" : " first");
|
||||
}
|
||||
|
||||
|
||||
if (x.getColumns().size() > 1) {
|
||||
print(')');
|
||||
}
|
||||
@@ -2682,7 +2710,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
print0(x.getLockType().name);
|
||||
}
|
||||
|
||||
|
||||
if (x.getHints() != null && x.getHints().size() > 0) {
|
||||
print(' ');
|
||||
printAndAccept(x.getHints(), " ");
|
||||
@@ -2848,7 +2876,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
|
||||
if (x.getIndexType() != null) {
|
||||
print0(ucase ? " USING " : " using ");;
|
||||
print0(ucase ? " USING " : " using ");
|
||||
;
|
||||
print0(x.getIndexType());
|
||||
}
|
||||
|
||||
@@ -2886,17 +2915,17 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print0(" (");
|
||||
printAndAccept(x.getReferencedColumns(), ", ");
|
||||
print(')');
|
||||
|
||||
if(x.getReferenceMatch() != null) {
|
||||
|
||||
if (x.getReferenceMatch() != null) {
|
||||
print0(ucase ? " MATCH " : " match ");
|
||||
print0(x.getReferenceMatch().name());
|
||||
}
|
||||
|
||||
if(x.getReferenceOn()!= null) {
|
||||
|
||||
if (x.getReferenceOn() != null) {
|
||||
print0(ucase ? " ON " : " on ");
|
||||
print0(x.getReferenceOn().name());
|
||||
print(' ');
|
||||
if(x.getReferenceOption() != null) {
|
||||
if (x.getReferenceOption() != null) {
|
||||
print0(x.getReferenceOption().getText());
|
||||
}
|
||||
}
|
||||
@@ -3126,9 +3155,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlHintStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlOrderingExpr x) {
|
||||
x.getExpr().accept(this);
|
||||
@@ -3173,13 +3202,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* visit procedure create node
|
||||
*/
|
||||
@Override
|
||||
public boolean visit(SQLCreateProcedureStatement x) {
|
||||
if (x.isOrReplace()) {
|
||||
@Override
|
||||
public boolean visit(SQLCreateProcedureStatement x) {
|
||||
if (x.isOrReplace()) {
|
||||
print0(ucase ? "CREATE OR REPLACE PROCEDURE " : "create or replace procedure ");
|
||||
} else {
|
||||
print0(ucase ? "CREATE PROCEDURE " : "create procedure ");
|
||||
@@ -3211,19 +3239,19 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
x.getBlock().setParent(x);
|
||||
x.getBlock().accept(this);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhileStatement x) {
|
||||
@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) {
|
||||
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);
|
||||
@@ -3231,26 +3259,25 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
println();
|
||||
print0(ucase ? "END WHILE" : "end while");
|
||||
if(x.getLabelName()!=null&&!x.getLabelName().equals(""))
|
||||
print(' ');
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) print(' ');
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlWhileStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement x) {
|
||||
print0(ucase ? "IF " : "if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement x) {
|
||||
print0(ucase ? "IF " : "if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
@@ -3258,25 +3285,24 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
for (SQLIfStatement.ElseIf iterable_element : x.getElseIfList()) {
|
||||
iterable_element.accept(this);
|
||||
}
|
||||
|
||||
if(x.getElseItem()!=null)
|
||||
x.getElseItem().accept(this);
|
||||
|
||||
print0(ucase ? "END IF" : "end if");
|
||||
return false;
|
||||
}
|
||||
println();
|
||||
for (SQLIfStatement.ElseIf iterable_element : x.getElseIfList()) {
|
||||
iterable_element.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement.ElseIf x) {
|
||||
print0(ucase ? "ELSE IF " : "else if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
if (x.getElseItem() != null) x.getElseItem().accept(this);
|
||||
|
||||
print0(ucase ? "END IF" : "end if");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement.ElseIf x) {
|
||||
print0(ucase ? "ELSE IF " : "else if ");
|
||||
x.getCondition().accept(this);
|
||||
print0(ucase ? " THEN" : " then");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
@@ -3284,15 +3310,15 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement.Else x) {
|
||||
print0(ucase ? "ELSE " : "else ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
@Override
|
||||
public boolean visit(SQLIfStatement.Else x) {
|
||||
print0(ucase ? "ELSE " : "else ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
@@ -3300,89 +3326,87 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
print0(ucase ? "CASE " : "case ");
|
||||
x.getCondition().accept(this);
|
||||
println();
|
||||
for (int i = 0; i < x.getWhenList().size(); i++) {
|
||||
x.getWhenList().get(i).accept(this);
|
||||
}
|
||||
if(x.getElseItem()!=null)
|
||||
x.getElseItem().accept(this);
|
||||
print0(ucase ? "END CASE" : "end case");
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlCaseStatement x) {
|
||||
print0(ucase ? "CASE " : "case ");
|
||||
x.getCondition().accept(this);
|
||||
println();
|
||||
for (int i = 0; i < x.getWhenList().size(); i++) {
|
||||
x.getWhenList().get(i).accept(this);
|
||||
}
|
||||
if (x.getElseItem() != null) x.getElseItem().accept(this);
|
||||
print0(ucase ? "END CASE" : "end case");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlCaseStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlCaseStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
printAndAccept(x.getVarList(), ", ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlDeclareStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
printAndAccept(x.getVarList(), ", ");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSelectIntoStatement x) {
|
||||
x.getSelect().accept(this);
|
||||
print0(ucase ? " INTO " : " into ");
|
||||
for (int i = 0; i < x.getVarList().size(); i++) {
|
||||
x.getVarList().get(i).accept(this);
|
||||
if(i!=x.getVarList().size()-1)
|
||||
print0(", ");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlDeclareStatement x) {
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSelectIntoStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhenStatement x) {
|
||||
print0(ucase ? "WHEN " : "when ");
|
||||
x.getCondition().accept(this);
|
||||
print0(" THEN");
|
||||
println();
|
||||
for (int i = 0; i < x.getStatements().size(); i++) {
|
||||
x.getStatements().get(i).accept(this);
|
||||
if (i != x.getStatements().size() - 1) {
|
||||
@Override
|
||||
public boolean visit(MySqlSelectIntoStatement x) {
|
||||
x.getSelect().accept(this);
|
||||
print0(ucase ? " INTO " : " into ");
|
||||
for (int i = 0; i < x.getVarList().size(); i++) {
|
||||
x.getVarList().get(i).accept(this);
|
||||
if (i != x.getVarList().size() - 1) print0(", ");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSelectIntoStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlWhenStatement x) {
|
||||
print0(ucase ? "WHEN " : "when ");
|
||||
x.getCondition().accept(this);
|
||||
print0(" THEN");
|
||||
println();
|
||||
for (int i = 0; i < x.getStatements().size(); i++) {
|
||||
x.getStatements().get(i).accept(this);
|
||||
if (i != x.getStatements().size() - 1) {
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
println();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlWhenStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlWhenStatement x) {
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLLoopStatement x) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLLoopStatement x) {
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
print0(x.getLabelName());
|
||||
print0(": ");
|
||||
}
|
||||
|
||||
print0(ucase ? "LOOP " : "loop ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
|
||||
print0(ucase ? "LOOP " : "loop ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
@@ -3390,52 +3414,52 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
print0(ucase ? "END LOOP" : "end loop");
|
||||
println();
|
||||
print0(ucase ? "END LOOP" : "end loop");
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
print0(" ");
|
||||
print0(x.getLabelName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlLeaveStatement x) {
|
||||
print0(ucase ? "LEAVE " : "leave ");
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlLeaveStatement x) {
|
||||
print0(ucase ? "LEAVE " : "leave ");
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlLeaveStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlLeaveStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIterateStatement x) {
|
||||
print0(ucase ? "ITERATE " : "iterate ");
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIterateStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlIterateStatement x) {
|
||||
print0(ucase ? "ITERATE " : "iterate ");
|
||||
print0(x.getLabelName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRepeatStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
@Override
|
||||
public void endVisit(MySqlIterateStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRepeatStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
print0(x.getLabelName());
|
||||
print0(": ");
|
||||
}
|
||||
|
||||
print0(ucase ? "REPEAT " : "repeat ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
|
||||
print0(ucase ? "REPEAT " : "repeat ");
|
||||
println();
|
||||
for (int i = 0, size = x.getStatements().size(); i < size; ++i) {
|
||||
SQLStatement item = x.getStatements().get(i);
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
@@ -3443,40 +3467,40 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
println();
|
||||
}
|
||||
}
|
||||
println();
|
||||
print0(ucase ? "UNTIL " : "until ");
|
||||
x.getCondition().accept(this);
|
||||
println();
|
||||
print0(ucase ? "END REPEAT" : "end repeat");
|
||||
println();
|
||||
print0(ucase ? "UNTIL " : "until ");
|
||||
x.getCondition().accept(this);
|
||||
println();
|
||||
print0(ucase ? "END REPEAT" : "end repeat");
|
||||
if (x.getLabelName() != null && !x.getLabelName().equals("")) {
|
||||
print(' ');
|
||||
print0(x.getLabelName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRepeatStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlRepeatStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlCursorDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
print0(x.getCursorName());
|
||||
print0(ucase ? " CURSOR FOR " : " cursor for ");
|
||||
x.getSelect().accept(this);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlCursorDeclareStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlCursorDeclareStatement x) {
|
||||
print0(ucase ? "DECLARE " : "declare ");
|
||||
print0(x.getCursorName());
|
||||
print0(ucase ? " CURSOR FOR " : " cursor for ");
|
||||
x.getSelect().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void endVisit(MySqlCursorDeclareStatement x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateTableSource x) {
|
||||
MySqlUpdateStatement update = x.getUpdate();
|
||||
if (update != null) {
|
||||
@@ -3505,6 +3529,89 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlAlterTableAlterColumn x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByHash x) {
|
||||
if (x.isLinear()) {
|
||||
print0(ucase ? "SUBPARTITION BY LINEAR HASH " : "subpartition by linear hash ");
|
||||
} else {
|
||||
print0(ucase ? "SUBPARTITION BY HASH " : "subpartition by hash ");
|
||||
}
|
||||
|
||||
if (x.isKey()) {
|
||||
print0(ucase ? "KEY" : "key");
|
||||
}
|
||||
|
||||
print('(');
|
||||
x.getExpr().accept(this);
|
||||
print(')');
|
||||
|
||||
if (x.getSubPartitionsCount() != null) {
|
||||
print0(ucase ? " PARTITIONS " : " partitions ");
|
||||
x.getSubPartitionsCount().accept(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByHash x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByKey x) {
|
||||
if (x.isLinear()) {
|
||||
print0(ucase ? "SUBPARTITION BY LINEAR KEY (" : "subpartition by linear key (");
|
||||
} else {
|
||||
print0(ucase ? "SUBPARTITION BY KEY (" : "subpartition by key (");
|
||||
}
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(')');
|
||||
|
||||
if (x.getSubPartitionsCount() != null) {
|
||||
print0(ucase ? " SUBPARTITIONS " : " subpartitions ");
|
||||
x.getSubPartitionsCount().accept(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByKey x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByList x) {
|
||||
print0(ucase ? "SUBPARTITION BY LIST " : "subpartition by list ");
|
||||
if (x.getExpr() != null) {
|
||||
print('(');
|
||||
x.getExpr().accept(this);
|
||||
print0(") ");
|
||||
} else {
|
||||
if (x.getColumns().size() == 1 && Boolean.TRUE.equals(x.getAttribute("ads.subPartitionList"))) {
|
||||
print('(');
|
||||
} else {
|
||||
print0(ucase ? "COLUMNS (" : "columns (");
|
||||
}
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(")");
|
||||
}
|
||||
|
||||
if (x.getOptions().size() != 0) {
|
||||
println();
|
||||
print0(ucase ? "SUBPARTITION OPTIONS (" : "subpartition options (");
|
||||
printAndAccept(x.getOptions(), ", ");
|
||||
print(')');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByList x) {
|
||||
|
||||
}
|
||||
} //
|
||||
|
||||
+32
-1
@@ -47,9 +47,9 @@ 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.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.CobarShowStatus;
|
||||
@@ -141,6 +141,9 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTriggersStatem
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowVariantsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStartTransactionStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByHash;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
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;
|
||||
@@ -1449,5 +1452,33 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByHash x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByHash x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByKey x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByKey x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlSubPartitionByList x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlSubPartitionByList x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
return new SQLSelectItem(expr, alias);
|
||||
}
|
||||
|
||||
protected SQLColumnDefinition createColumnDefinition() {
|
||||
public SQLColumnDefinition createColumnDefinition() {
|
||||
SQLColumnDefinition column = new SQLServerColumnDefinition();
|
||||
return column;
|
||||
}
|
||||
|
||||
@@ -1595,7 +1595,7 @@ public class SQLExprParser extends SQLParser {
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
protected SQLColumnDefinition createColumnDefinition() {
|
||||
public SQLColumnDefinition createColumnDefinition() {
|
||||
SQLColumnDefinition column = new SQLColumnDefinition();
|
||||
return column;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user