mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql parser support mysql 5.7 & oceanbase 1.0
This commit is contained in:
@@ -18,17 +18,28 @@ package com.alibaba.druid.sql.ast.statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLAlterTableAddPartition extends SQLObjectImpl implements SQLAlterTableItem {
|
||||
|
||||
private boolean ifNotExists = false;
|
||||
private boolean ifNotExists = false;
|
||||
|
||||
private final List<SQLAssignItem> partition = new ArrayList<SQLAssignItem>(4);
|
||||
private final List<SQLObject> partitions = new ArrayList<SQLObject>(4);
|
||||
|
||||
public List<SQLAssignItem> getPartition() {
|
||||
return partition;
|
||||
private SQLExpr partitionCount;
|
||||
|
||||
public List<SQLObject> getPartitions() {
|
||||
return partitions;
|
||||
}
|
||||
|
||||
public void addPartition(SQLObject partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
this.partitions.add(partition);
|
||||
}
|
||||
|
||||
public boolean isIfNotExists() {
|
||||
@@ -39,10 +50,21 @@ public class SQLAlterTableAddPartition extends SQLObjectImpl implements SQLAlter
|
||||
this.ifNotExists = ifNotExists;
|
||||
}
|
||||
|
||||
public SQLExpr getPartitionCount() {
|
||||
return partitionCount;
|
||||
}
|
||||
|
||||
public void setPartitionCount(SQLExpr partitionCount) {
|
||||
if (partitionCount != null) {
|
||||
partitionCount.setParent(this);
|
||||
}
|
||||
this.partitionCount = partitionCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, partition);
|
||||
acceptChild(visitor, partitions);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLAlterTableCoalescePartition extends SQLObjectImpl implements SQLAlterTableItem {
|
||||
|
||||
private SQLExpr count;
|
||||
|
||||
public SQLExpr getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(SQLExpr count) {
|
||||
if (count != null) {
|
||||
count.setParent(this);
|
||||
}
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, count);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.alibaba.druid.sql.ast.statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@@ -27,10 +28,17 @@ public class SQLAlterTableDropPartition extends SQLObjectImpl implements SQLAlte
|
||||
|
||||
private boolean purge;
|
||||
|
||||
private final List<SQLAssignItem> partition = new ArrayList<SQLAssignItem>(4);
|
||||
private final List<SQLObject> partitions = new ArrayList<SQLObject>(4);
|
||||
|
||||
public List<SQLAssignItem> getPartition() {
|
||||
return partition;
|
||||
public List<SQLObject> getPartitions() {
|
||||
return partitions;
|
||||
}
|
||||
|
||||
public void addPartition(SQLObject partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
this.partitions.add(partition);
|
||||
}
|
||||
|
||||
public boolean isIfNotExists() {
|
||||
@@ -52,7 +60,7 @@ public class SQLAlterTableDropPartition extends SQLObjectImpl implements SQLAlte
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, partition);
|
||||
acceptChild(visitor, partitions);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
+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.ast.statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLAlterTableReOrganizePartition extends SQLObjectImpl implements SQLAlterTableItem {
|
||||
|
||||
private final List<SQLName> names = new ArrayList<SQLName>();
|
||||
|
||||
private final List<SQLObject> partitions = new ArrayList<SQLObject>(4);
|
||||
|
||||
public List<SQLObject> getPartitions() {
|
||||
return partitions;
|
||||
}
|
||||
|
||||
public void addPartition(SQLObject partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
this.partitions.add(partition);
|
||||
}
|
||||
|
||||
public List<SQLName> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, partitions);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,19 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
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.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
|
||||
protected SQLExpr expr;
|
||||
|
||||
private List<SQLName> partitions;
|
||||
|
||||
public SQLExprTableSource(){
|
||||
|
||||
}
|
||||
@@ -29,7 +35,7 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
public SQLExprTableSource(SQLExpr expr){
|
||||
this(expr, null);
|
||||
}
|
||||
|
||||
|
||||
public SQLExprTableSource(SQLExpr expr, String alias){
|
||||
this.setExpr(expr);
|
||||
this.setAlias(alias);
|
||||
@@ -46,6 +52,32 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
public List<SQLName> getPartitions() {
|
||||
if (this.partitions == null) {
|
||||
this.partitions = new ArrayList<SQLName>(2);
|
||||
}
|
||||
|
||||
return partitions;
|
||||
}
|
||||
|
||||
public int getPartitionSize() {
|
||||
if (this.partitions == null) {
|
||||
return 0;
|
||||
}
|
||||
return this.partitions.size();
|
||||
}
|
||||
|
||||
public void addPartition(SQLName partition) {
|
||||
if (partition != null) {
|
||||
partition.setParent(this);
|
||||
}
|
||||
|
||||
if (this.partitions == null) {
|
||||
this.partitions = new ArrayList<SQLName>(2);
|
||||
}
|
||||
this.partitions.add(partition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
|
||||
Reference in New Issue
Block a user