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

panjuan 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 c92cef1  #12469 - Supporting administration statements for CLONE 
command (#13046)
c92cef1 is described below

commit c92cef1c4f0d3b2204867442c1e53ac5fa476620
Author: Oresztesz Margaritisz <[email protected]>
AuthorDate: Tue Oct 19 13:41:04 2021 +0200

    #12469 - Supporting administration statements for CLONE command (#13046)
---
 .../impl/MySQLDALStatementSQLVisitor.java          | 35 ++++++++++++++
 .../core/database/visitor/SQLVisitorRule.java      |  2 +
 .../statement/mysql/dal/MySQLCloneStatement.java   | 37 ++++++++++++++
 .../mysql/segment/CloneActionSegment.java          | 42 ++++++++++++++++
 .../mysql/segment/CloneInstanceSegment.java        | 48 +++++++++++++++++++
 .../asserts/statement/dal/DALStatementAssert.java  |  5 ++
 .../statement/dal/impl/CloneStatementAssert.java   | 56 ++++++++++++++++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  5 ++
 .../segment/impl/clone/ExpectedDataDirectory.java  | 33 +++++++++++++
 .../segment/impl/clone/ExpectedInstance.java       | 45 +++++++++++++++++
 .../statement/dal/CloneStatementTestCase.java      | 39 +++++++++++++++
 .../src/main/resources/case/dal/clone.xml          | 36 ++++++++++++++
 .../src/main/resources/sql/supported/dal/clone.xml | 25 ++++++++++
 13 files changed, 408 insertions(+)

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 c4719d9..86d31d6 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
@@ -24,6 +24,9 @@ import 
org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.AnalyzeTableContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CacheIndexContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ChecksumTableContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CloneContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CloneActionContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CloneInstanceContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ComponentNameContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.CreateLoadableFunctionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.ExplainContext;
@@ -89,10 +92,12 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.Sim
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLAnalyzeTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLCacheIndexStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLChecksumTableStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLCloneStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLCreateLoadableFunctionStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLExplainStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLFlushStatement;
@@ -127,6 +132,8 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQ
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUninstallComponentStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUninstallPluginStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.CloneActionSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.CloneInstanceSegment;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -279,6 +286,34 @@ public final class MySQLDALStatementSQLVisitor extends 
MySQLStatementSQLVisitor
         result.setPluginName(((IdentifierValue) 
visit(ctx.pluginName())).getValue());
         return result;
     }
+
+    @Override
+    public ASTNode visitClone(final CloneContext ctx) {
+        MySQLCloneStatement result = new MySQLCloneStatement();
+        result.setCloneActionSegment((CloneActionSegment) 
visit(ctx.cloneAction()));
+        return result;
+    }
+
+    @Override
+    public ASTNode visitCloneAction(final CloneActionContext ctx) {
+        CloneActionSegment result = new 
CloneActionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex());
+        if (null != ctx.cloneInstance()) {
+            CloneInstanceContext cloneInstance = ctx.cloneInstance();
+            CloneInstanceSegment cloneInstanceSegment = new 
CloneInstanceSegment(cloneInstance.start.getStartIndex(), 
cloneInstance.stop.getStopIndex());
+            cloneInstanceSegment.setUserName(((StringLiteralValue) 
visitUserName(cloneInstance.userName())).getValue());
+            cloneInstanceSegment.setHostName(((StringLiteralValue) 
visit(cloneInstance.hostName())).getValue());
+            cloneInstanceSegment.setPort(new 
NumberLiteralValue(cloneInstance.port().NUMBER_().getText()).getValue().intValue());
+            cloneInstanceSegment.setPassword(((StringLiteralValue) 
visit(ctx.string_())).getValue());
+            if (null != ctx.SSL() && null == ctx.NO()) {
+                cloneInstanceSegment.setSslRequired(true);
+            }
+            result.setCloneInstance(cloneInstanceSegment);
+        }
+        if (null != ctx.cloneDir()) {
+            result.setCloneDir(((StringLiteralValue) 
visit(ctx.cloneDir())).getValue());
+        }
+        return result;
+    }
     
     @Override
     public ASTNode visitOptimizeTable(final OptimizeTableContext ctx) {
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 9b43aab..450ac25 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
@@ -267,6 +267,8 @@ public enum SQLVisitorRule {
     UNINSTALL("Uninstall", SQLStatementType.DAL),
     
     FLUSH("Flush", SQLStatementType.DAL),
+
+    CLONE("Clone", SQLStatementType.DAL),
     
     CALL("Call", SQLStatementType.DML),
     
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLCloneStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLCloneStatement.java
new file mode 100644
index 0000000..bc6ec6e
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLCloneStatement.java
@@ -0,0 +1,37 @@
+/*
+ * 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.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.dialect.statement.mysql.MySQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.CloneActionSegment;
+
+/**
+ * MySQL clone statement.
+ */
+@ToString
+@Getter
+@Setter
+public final class MySQLCloneStatement extends AbstractSQLStatement implements 
DALStatement, MySQLStatement {
+
+    private CloneActionSegment cloneActionSegment;
+}
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneActionSegment.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneActionSegment.java
new file mode 100644
index 0000000..5588833
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneActionSegment.java
@@ -0,0 +1,42 @@
+/*
+ * 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.statement.mysql.segment;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+/**
+ * Clone action segment.
+ */
+@RequiredArgsConstructor
+@ToString
+@Getter
+@Setter
+public final class CloneActionSegment implements SQLSegment {
+
+    private final int startIndex;
+
+    private final int stopIndex;
+
+    private String cloneDir;
+
+    private CloneInstanceSegment cloneInstance;
+}
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneInstanceSegment.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneInstanceSegment.java
new file mode 100644
index 0000000..d01add4
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/CloneInstanceSegment.java
@@ -0,0 +1,48 @@
+/*
+ * 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.statement.mysql.segment;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+/**
+ * Clone instance segment.
+ */
+@RequiredArgsConstructor
+@ToString
+@Getter
+@Setter
+public final class CloneInstanceSegment implements SQLSegment {
+
+    private final int startIndex;
+
+    private final int stopIndex;
+
+    private String userName;
+
+    private String hostName;
+
+    private String password;
+
+    private int port;
+
+    private boolean sslRequired;
+}
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 d8c9483..d5d01d2 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
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
 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.SetStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLCloneStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLFlushStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLInstallComponentStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLInstallPluginStatement;
@@ -38,6 +39,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQ
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLShowStatement;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.CloneStatementAssert;
 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.FlushStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.InstallComponentStatementAssert;
@@ -56,6 +58,7 @@ import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.UninstallComponentStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.dal.impl.UninstallPluginStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.CloneStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ExplainStatementTestCase;
 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.dal.InstallComponentStatementTestCase;
@@ -118,6 +121,8 @@ public final class DALStatementAssert {
             FlushStatementAssert.assertIs(assertContext, (MySQLFlushStatement) 
actual, (FlushStatementTestCase) expected);
         } else if (actual instanceof MySQLInstallPluginStatement) {
             InstallPluginStatementAssert.assertIs(assertContext, 
(MySQLInstallPluginStatement) actual, (InstallPluginStatementTestCase) 
expected);
+        } else if (actual instanceof MySQLCloneStatement) {
+            CloneStatementAssert.assertIs(assertContext, (MySQLCloneStatement) 
actual, (CloneStatementTestCase) expected);
         } else if (actual instanceof MySQLUninstallComponentStatement) {
             UninstallComponentStatementAssert.assertIs(assertContext, 
(MySQLUninstallComponentStatement) actual, 
(UninstallComponentStatementTestCase) expected);
         } else if (actual instanceof MySQLUninstallPluginStatement) {
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/CloneStatementAssert.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/CloneStatementAssert.java
new file mode 100644
index 0000000..45eb602
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dal/impl/CloneStatementAssert.java
@@ -0,0 +1,56 @@
+/*
+ * 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.MySQLCloneStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.segment.CloneInstanceSegment;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.CloneStatementTestCase;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Clone statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CloneStatementAssert {
+    
+    /**
+     * Assert clone statement is correct with expected clone statement test 
case.
+     *
+     * @param assertContext assert context
+     * @param actual actual clone statement
+     * @param expected expected clone statement test case
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final MySQLCloneStatement actual, final CloneStatementTestCase expected) {
+        if (null != expected.getDataDirectory()) {
+            assertThat(assertContext.getText("Actual data directory does not 
match: "), actual.getCloneActionSegment().getCloneDir(), 
is(expected.getDataDirectory().getLocation()));
+        }
+        if (null != expected.getInstance()) {
+            CloneInstanceSegment instance = 
actual.getCloneActionSegment().getCloneInstance();
+            assertThat(assertContext.getText("Actual instance hostname does 
not match: "), instance.getHostName(), 
is(expected.getInstance().getHostname()));
+            assertThat(assertContext.getText("Actual instance username does 
not match: "), instance.getUserName(), 
is(expected.getInstance().getUsername()));
+            assertThat(assertContext.getText("Actual instance port does not 
match: "), instance.getPort(), is(expected.getInstance().getPort()));
+            assertThat(assertContext.getText("Actual instance password does 
not match: "), instance.getPassword(), 
is(expected.getInstance().getPassword()));
+            assertThat(assertContext.getText("Actual instance SSL requirement 
does not match: "), instance.isSslRequired(), 
is(expected.getInstance().isSslRequired()));
+        }
+    }
+}
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 be73c84..8079068 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
@@ -21,6 +21,7 @@ import com.google.common.base.Preconditions;
 import lombok.Getter;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.CommonStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.CloneStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dal.ExplainStatementTestCase;
 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.dal.InstallComponentStatementTestCase;
@@ -623,6 +624,9 @@ public final class SQLParserTestCases {
     @XmlElement(name = "show-instance")
     private final List<ShowInstanceStatementTestCase> 
showInstanceStatementTestCases = new LinkedList<>();
     
+    @XmlElement(name = "clone")
+    private final List<CloneStatementTestCase> cloneStatementTestCases = new 
LinkedList<>();
+    
     @XmlElement(name = "show-readwrite-splitting-read-resources")
     private final List<ShowReadwriteSplittingReadResourcesStatementTestCase> 
showReadwriteSplittingReadResourcesStatementTestCases = new LinkedList<>();
     
@@ -786,6 +790,7 @@ public final class SQLParserTestCases {
         putAll(flushStatementTestCase, result);
         putAll(installPluginStatementTestCase, result);
         putAll(showInstanceStatementTestCases, result);
+        putAll(cloneStatementTestCases, result);
         putAll(showReadwriteSplittingReadResourcesStatementTestCases, result);
         putAll(uninstallComponentStatementTestCases, result);
         putAll(uninstallPluginStatementTestCases, result);
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedDataDirectory.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedDataDirectory.java
new file mode 100644
index 0000000..1bb1735
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedDataDirectory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.jaxb.cases.domain.segment.impl.clone;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import lombok.Getter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;
+
+/**
+ * Expected data directory.
+ */
+@Getter
+public final class ExpectedDataDirectory extends AbstractExpectedSQLSegment {
+    
+    @XmlAttribute(name = "location")
+    private String location;
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedInstance.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedInstance.java
new file mode 100644
index 0000000..dac7663
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/clone/ExpectedInstance.java
@@ -0,0 +1,45 @@
+/*
+ * 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.jaxb.cases.domain.segment.impl.clone;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import lombok.Getter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;
+
+/**
+ * Expected instance.
+ */
+@Getter
+public final class ExpectedInstance extends AbstractExpectedSQLSegment {
+    
+    @XmlAttribute(name = "username")
+    private String username;
+
+    @XmlAttribute(name = "hostname")
+    private String hostname;
+
+    @XmlAttribute(name = "port")
+    private Integer port;
+
+    @XmlAttribute(name = "password")
+    private String password;
+
+    @XmlAttribute(name = "require-ssl")
+    private boolean sslRequired;
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/CloneStatementTestCase.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/CloneStatementTestCase.java
new file mode 100644
index 0000000..7a6ed8d
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dal/CloneStatementTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * 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.jaxb.cases.domain.statement.dal;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import lombok.Getter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.clone.ExpectedInstance;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.clone.ExpectedDataDirectory;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+/**
+ * Clone statement test case.
+ */
+@Getter
+public final class CloneStatementTestCase extends SQLParserTestCase {
+
+    @XmlElement(name = "data-directory")
+    private ExpectedDataDirectory dataDirectory;
+
+    @XmlElement(name = "instance")
+    private ExpectedInstance instance;
+
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/clone.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/clone.xml
new file mode 100644
index 0000000..90316da
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dal/clone.xml
@@ -0,0 +1,36 @@
+<?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>
+    <clone sql-case-id="clone_local">
+        <data-directory location="/path/to/clone_dir"/>
+    </clone>
+    <clone sql-case-id="clone_instance">
+        <instance username="donor_clone_user" 
hostname="example.donor.host.com" port="3306" password="password"/>
+    </clone>
+    <clone sql-case-id="clone_instance_with_data_dir">
+        <instance username="donor_clone_user" 
hostname="example.donor.host.com" port="3306" password="password"/>
+        <data-directory location="/tmp/clone_dir"/>
+    </clone>
+    <clone sql-case-id="clone_instance_require_ssl">
+        <instance username="donor_clone_user" 
hostname="example.donor.host.com" port="3306" password="password" 
require-ssl="true"/>
+    </clone>
+    <clone sql-case-id="clone_instance_require_no_ssl">
+        <instance username="donor_clone_user" 
hostname="example.donor.host.com" port="3306" password="password" 
require-ssl="false"/>
+    </clone>
+</sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/clone.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/clone.xml
new file mode 100644
index 0000000..b9a61a3
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/clone.xml
@@ -0,0 +1,25 @@
+<?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="clone_local" value="CLONE LOCAL DATA DIRECTORY = 
'/path/to/clone_dir'" db-types="MySQL" />
+    <sql-case id="clone_instance" value="CLONE INSTANCE FROM 
'donor_clone_user'@'example.donor.host.com':3306 IDENTIFIED BY 'password'" 
db-types="MySQL" />
+    <sql-case id="clone_instance_with_data_dir" value="CLONE INSTANCE FROM 
'donor_clone_user'@'example.donor.host.com':3306 IDENTIFIED BY 'password' DATA 
DIRECTORY = '/tmp/clone_dir'" db-types="MySQL" />
+    <sql-case id="clone_instance_require_ssl" value="CLONE INSTANCE FROM 
'donor_clone_user'@'example.donor.host.com':3306 IDENTIFIED BY 'password' 
REQUIRE SSL" db-types="MySQL" />
+    <sql-case id="clone_instance_require_no_ssl" value="CLONE INSTANCE FROM 
'donor_clone_user'@'example.donor.host.com':3306 IDENTIFIED BY 'password' 
REQUIRE NO SSL" db-types="MySQL" />
+</sql-cases>

Reply via email to