This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 00c68ce Add UseStatement as parent class of MySQLUseStatement (#9220)
00c68ce is described below
commit 00c68cef3f735d52e1ae9c8176d8cbf46663ef3d
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 29 17:32:04 2021 +0800
Add UseStatement as parent class of MySQLUseStatement (#9220)
---
.../backend/text/admin/mysql/MySQLAdminExecutorFactory.java | 6 +++---
.../text/admin/mysql/executor/UseDatabaseExecutor.java | 4 ++--
.../statement/dal/UseStatement.java} | 8 +++-----
.../sql/dialect/statement/mysql/dal/MySQLUseStatement.java | 13 +++----------
4 files changed, 11 insertions(+), 20 deletions(-)
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/MySQLAdminExecutorFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/MySQLAdminExecutorFactory.java
index ce5bb3f..b36a4de 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/MySQLAdminExecutorFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/MySQLAdminExecutorFactory.java
@@ -28,10 +28,10 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.Projecti
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.UseStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowDatabasesStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement;
-import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
import java.util.Optional;
@@ -46,8 +46,8 @@ public final class MySQLAdminExecutorFactory implements
DatabaseAdminExecutorFac
@Override
public Optional<DatabaseAdminExecutor> newInstance(final String
currentSchema, final SQLStatement sqlStatement) {
- if (sqlStatement instanceof MySQLUseStatement) {
- return Optional.of(new UseDatabaseExecutor((MySQLUseStatement)
sqlStatement));
+ if (sqlStatement instanceof UseStatement) {
+ return Optional.of(new UseDatabaseExecutor((UseStatement)
sqlStatement));
}
if (sqlStatement instanceof MySQLShowDatabasesStatement) {
return Optional.of(new ShowDatabasesExecutor());
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
index 5e771ac..3d0c27e 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
@@ -23,8 +23,8 @@ import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.Bac
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import
org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
import
org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.UseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
-import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
import java.util.Collection;
import java.util.Collections;
@@ -36,7 +36,7 @@ import java.util.Optional;
@RequiredArgsConstructor
public final class UseDatabaseExecutor implements DatabaseAdminExecutor {
- private final MySQLUseStatement useStatement;
+ private final UseStatement useStatement;
@Override
public void execute(final BackendConnection backendConnection) {
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/UseStatement.java
similarity index 72%
copy from
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
copy to
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/UseStatement.java
index b57ad40..f34a5bf 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/UseStatement.java
@@ -15,22 +15,20 @@
* 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.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;
/**
- * MySQL use statement.
+ * Use database statement.
*/
@Getter
@Setter
@ToString
-public final class MySQLUseStatement extends AbstractSQLStatement implements
DALStatement, MySQLStatement {
+public abstract class UseStatement extends AbstractSQLStatement implements
DALStatement {
private String schema;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
index b57ad40..db0c112 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/dal/MySQLUseStatement.java
@@ -17,20 +17,13 @@
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.statement.dal.UseStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
/**
- * MySQL use statement.
+ * Use database statement for MySQL.
*/
-@Getter
-@Setter
@ToString
-public final class MySQLUseStatement extends AbstractSQLStatement implements
DALStatement, MySQLStatement {
-
- private String schema;
+public final class MySQLUseStatement extends UseStatement implements
MySQLStatement {
}