This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a256378  Fix flush statement (#12999)
a256378 is described below

commit a256378812f732927011d5c00449d3f2ec986c5c
Author: tuichenchuxin <[email protected]>
AuthorDate: Tue Oct 12 20:26:57 2021 +0800

    Fix flush statement (#12999)
    
    * fix flush statement.
    
    * support flush statement
    
    * support flush statement
    
    * support flush statement
---
 .../infra/binder/SQLStatementContextFactory.java   |  5 +++
 .../statement/dal/FlushStatementContext.java       | 47 ++++++++++++++++++++
 .../impl/MySQLDALStatementSQLVisitor.java          | 15 +++++++
 .../core/database/visitor/SQLVisitorRule.java      |  2 +
 .../statement/dal/FlushStatement.java}             | 10 ++---
 .../dialect/handler/dal/FlushStatementHandler.java | 49 +++++++++++++++++++++
 .../statement/mysql/dal/MySQLFlushStatement.java   | 18 ++++++--
 .../asserts/statement/dal/DALStatementAssert.java  |  5 +++
 .../statement/dal/impl/FlushStatementAssert.java   | 51 ++++++++++++++++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  5 +++
 .../statement/dal/FlushStatementTestCase.java      | 26 +++++++----
 .../src/main/resources/case/dal/flush.xml          | 26 +++++++++++
 .../src/main/resources/sql/supported/dal/flush.xml | 23 ++++++++++
 13 files changed, 264 insertions(+), 18 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
index 9dd2322..88ccfb2 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContex
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.AnalyzeTableStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ExplainStatementContext;
+import 
org.apache.shardingsphere.infra.binder.statement.dal.FlushStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ShowColumnsStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ShowCreateTableStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ShowIndexStatementContext;
@@ -54,6 +55,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.ExplainStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.FlushStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dcl.DCLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dcl.GrantStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dcl.RevokeStatement;
@@ -217,6 +219,9 @@ public final class SQLStatementContextFactory {
         if (sqlStatement instanceof AnalyzeTableStatement) {
             return new AnalyzeTableStatementContext((AnalyzeTableStatement) 
sqlStatement);
         }
+        if (sqlStatement instanceof FlushStatement) {
+            return new FlushStatementContext((FlushStatement) sqlStatement);
+        }
         return new CommonSQLStatementContext<>(sqlStatement);
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/FlushStatementContext.java
 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/FlushStatementContext.java
new file mode 100644
index 0000000..e1899db
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/FlushStatementContext.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.infra.binder.statement.dal;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
+import 
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.infra.binder.type.TableAvailable;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.FlushStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.handler.dal.FlushStatementHandler;
+
+import java.util.Collection;
+
+/**
+ * Flush statement context.
+ */
+@Getter
+public final class FlushStatementContext extends 
CommonSQLStatementContext<FlushStatement> implements TableAvailable {
+    
+    private final TablesContext tablesContext;
+    
+    public FlushStatementContext(final FlushStatement sqlStatement) {
+        super(sqlStatement);
+        tablesContext = new 
TablesContext(FlushStatementHandler.getSimpleTableSegment(sqlStatement));
+    }
+    
+    @Override
+    public Collection<SimpleTableSegment> getAllTables() {
+        return FlushStatementHandler.getSimpleTableSegment(getSqlStatement());
+    }
+}
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
index dcbc1e1..ecfe160 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
@@ -29,6 +29,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateL
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExplainContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExplainableStatementContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FlushContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TablesOptionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FromSchemaContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.FromTableContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.InstallComponentContext;
@@ -75,6 +76,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.Uninsta
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.UseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.UserVariableContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.VariableContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TableNameContext;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.FromSchemaSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.FromTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.ShowLikeSegment;
@@ -241,10 +243,23 @@ public final class MySQLDALStatementSQLVisitor extends 
MySQLStatementSQLVisitor
     
     @Override
     public ASTNode visitFlush(final FlushContext ctx) {
+        if (null != ctx.tablesOption()) {
+            return visit(ctx.tablesOption());
+        }
         return new MySQLFlushStatement();
     }
     
     @Override
+    public ASTNode visitTablesOption(final TablesOptionContext ctx) {
+        MySQLFlushStatement result = new MySQLFlushStatement();
+        result.setFlushTable(true);
+        for (TableNameContext each : ctx.tableName()) {
+            result.getTables().add((SimpleTableSegment) visit(each));
+        }
+        return result;
+    }
+    
+    @Override
     public ASTNode visitKill(final KillContext ctx) {
         return new MySQLKillStatement();
     }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
index 5bf806a..54510c0 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
@@ -264,6 +264,8 @@ public enum SQLVisitorRule {
     
     INSTALL("Install", SQLStatementType.DAL),
     
+    FLUSH("Flush", SQLStatementType.DAL),
+    
     CALL("Call", SQLStatementType.DML),
     
     CHANGE_MASTER("ChangeMaster", SQLStatementType.RL), 
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/FlushStatement.java
similarity index 68%
copy from 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
copy to 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/FlushStatement.java
index 33bd24f..c80b11f 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/FlushStatement.java
@@ -15,16 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal;
+package org.apache.shardingsphere.sql.parser.sql.common.statement.dal;
 
-import lombok.ToString;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 
 /**
- * MySQL flush statement.
+ * Flush statement.
  */
-@ToString
-public final class MySQLFlushStatement extends AbstractSQLStatement implements 
DALStatement, MySQLStatement {
+public abstract class FlushStatement extends AbstractSQLStatement implements 
DALStatement {
 }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dal/FlushStatementHandler.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dal/FlushStatementHandler.java
new file mode 100644
index 0000000..f28a11a
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dal/FlushStatementHandler.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sql.parser.sql.dialect.handler.dal;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.FlushStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLFlushStatement;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Flush statement handler for different dialect SQL statements.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class FlushStatementHandler implements SQLStatementHandler {
+    
+    /**
+     * Get simple table segments.
+     *
+     * @param flushStatement flush statement
+     * @return simple table segments
+     */
+    public static Collection<SimpleTableSegment> getSimpleTableSegment(final 
FlushStatement flushStatement) {
+        if (flushStatement instanceof MySQLStatement) {
+            return ((MySQLFlushStatement) flushStatement).getTables();
+        }
+        return Collections.emptyList();
+    }
+}
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
index 33bd24f..e173010 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
@@ -17,14 +17,26 @@
 
 package org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal;
 
+import lombok.Getter;
+import lombok.Setter;
 import lombok.ToString;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.FlushStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 
+import java.util.Collection;
+import java.util.LinkedList;
+
 /**
  * MySQL flush statement.
  */
+@Getter
+@Setter
 @ToString
-public final class MySQLFlushStatement extends AbstractSQLStatement implements 
DALStatement, MySQLStatement {
+public final class MySQLFlushStatement extends FlushStatement implements 
MySQLStatement {
+    
+    private final Collection<SimpleTableSegment> tables = new LinkedList<>();
+    
+    private boolean flushTable;
+    
 }
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/DALStatementAssert.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/DALStatementAssert.java
index af75f45..8696497 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/DALStatementAssert.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/DALStatementAssert.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatemen
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.ExplainStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLInstallComponentStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLFlushStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowColumnsStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowCreateTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowCreateTriggerStatement;
@@ -36,6 +37,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.ExplainStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.InstallComponentStatementAssert;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.FlushStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.MySQLUseStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.SetParameterStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.ShowColumnsStatementAssert;
@@ -61,6 +63,7 @@ import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ShowTableStatusStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ShowTablesStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.UseStatementTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.FlushStatementTestCase;
 
 /**
  * DAL statement assert.
@@ -102,6 +105,8 @@ public final class DALStatementAssert {
             SetParameterStatementAssert.assertIs(assertContext, (SetStatement) 
actual, (SetParameterStatementTestCase) expected);
         } else if (actual instanceof MySQLInstallComponentStatement) {
             InstallComponentStatementAssert.assertIs(assertContext, 
(MySQLInstallComponentStatement) actual, (InstallComponentStatementTestCase) 
expected);
+        } else if (actual instanceof MySQLFlushStatement) {
+            FlushStatementAssert.assertIs(assertContext, (MySQLFlushStatement) 
actual, (FlushStatementTestCase) expected);
         }
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/FlushStatementAssert.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/FlushStatementAssert.java
new file mode 100644
index 0000000..027ba26
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/FlushStatementAssert.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLFlushStatement;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.table.TableAssert;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.FlushStatementTestCase;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Flush statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class FlushStatementAssert {
+    
+    /**
+     * Assert flush statement is correct with expected parser result.
+     *
+     * @param assertContext assert context
+     * @param actual actual flush statement
+     * @param expected expected flush statement test case
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final MySQLFlushStatement actual, final FlushStatementTestCase expected) {
+        assertThat(assertContext.getText("Flush statement is flush table 
assert error: "), actual.isFlushTable(), is(expected.isFlushTable()));
+        assertTables(assertContext, actual, expected);
+    }
+    
+    private static void assertTables(final SQLCaseAssertContext assertContext, 
final MySQLFlushStatement actual, final FlushStatementTestCase expected) {
+        TableAssert.assertIs(assertContext, actual.getTables(), 
expected.getTables());
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index c40a660..ded50b2 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -44,6 +44,7 @@ import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.DropLoginStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.DropRoleStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.DropUserStatementTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.FlushStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.GrantStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.RenameUserStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dcl.RevokeStatementTestCase;
@@ -608,6 +609,9 @@ public final class SQLParserTestCases {
     @XmlElement(name = "install-component")
     private final List<InstallComponentStatementTestCase> 
installComponentTestCase = new LinkedList<>();
     
+    @XmlElement(name = "flush")
+    private final List<FlushStatementTestCase> flushStatementTestCase = new 
LinkedList<>();
+    
     /**
      * Get all SQL parser test cases.
      *
@@ -758,6 +762,7 @@ public final class SQLParserTestCases {
         putAll(alterSchemaTestCase, result);
         putAll(dropSchemaTestCase, result);
         putAll(installComponentTestCase, result);
+        putAll(flushStatementTestCase, result);
         return result;
     }
     
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/FlushStatementTestCase.java
similarity index 50%
copy from 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
copy to 
shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/FlushStatementTestCase.java
index 33bd24f..0640f9b 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLFlushStatement.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/FlushStatementTestCase.java
@@ -15,16 +15,26 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal;
+package 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal;
 
-import lombok.ToString;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import lombok.Getter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.table.ExpectedSimpleTable;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
- * MySQL flush statement.
+ * Flush statement test case.
  */
-@ToString
-public final class MySQLFlushStatement extends AbstractSQLStatement implements 
DALStatement, MySQLStatement {
+@Getter
+public final class FlushStatementTestCase extends SQLParserTestCase {
+    
+    @XmlElement(name = "table")
+    private final List<ExpectedSimpleTable> tables = new LinkedList<>();
+    
+    @XmlAttribute(name = "flush-table")
+    private boolean flushTable;
 }
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/flush.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/flush.xml
new file mode 100644
index 0000000..23ebc10
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/flush.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You 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.
+  -->
+
+<sql-parser-test-cases>
+    <flush sql-case-id="flush_privileges" flush-table="false"/>
+    <flush sql-case-id="flush_tables" flush-table="true"/>
+    <flush sql-case-id="flush_tables_with_tables" flush-table="true">
+        <table name="t_order" start-index="13" stop-index="19" />
+        <table name="t_order_item" start-index="21" stop-index="32" />
+    </flush>
+</sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/flush.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/flush.xml
new file mode 100644
index 0000000..3a8a923
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/flush.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You 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.
+  -->
+
+<sql-cases>
+    <sql-case id="flush_privileges" value="FLUSH PRIVILEGES" db-types="MySQL" 
/>
+    <sql-case id="flush_tables" value="FLUSH TABLES" db-types="MySQL" />
+    <sql-case id="flush_tables_with_tables" value="FLUSH TABLES 
t_order,t_order_item" db-types="MySQL" />
+</sql-cases>

Reply via email to