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

zhangyonglun 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 71e0c30  Support Drop Database for Sharding Proxy (#7202)
71e0c30 is described below

commit 71e0c30381def2fb58567a89002f294f311480df
Author: Juan Pan(Trista) <[email protected]>
AuthorDate: Tue Sep 1 21:21:16 2020 +0800

    Support Drop Database for Sharding Proxy (#7202)
    
    * Support Drop Database for Sharding Proxy
    
    * fix unit test
---
 .../mysql/constant/MySQLServerErrorCode.java       |  2 ++
 .../governance/core/config/ConfigCenter.java       | 14 ++++++++++-
 .../backend/exception/DBDropExistsException.java   | 15 ++++++++----
 .../text/TextProtocolBackendHandlerFactory.java    |  9 +++----
 .../backend/text/admin/RDLBackendHandler.java      | 28 ++++++++++++++++++----
 .../backend/text/admin/RDLBackendHandlerTest.java  | 13 ++++++++++
 .../frontend/mysql/MySQLErrPacketFactory.java      |  4 ++++
 .../prepare/MySQLComStmtPrepareCheckerTest.java    |  2 +-
 .../ddl/DropDatabaseStatementContext.java}         | 15 ++++++++----
 .../parser/mysql/visitor/impl/MySQLDDLVisitor.java |  2 +-
 .../statement/ddl/DropDatabaseStatement.java       |  6 +++++
 11 files changed, 91 insertions(+), 19 deletions(-)

diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerErrorCode.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerErrorCode.java
index 86e9229..e381946 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerErrorCode.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerErrorCode.java
@@ -44,6 +44,8 @@ public enum MySQLServerErrorCode implements SQLErrorCode {
     
     ER_DB_CREATE_EXISTS_ERROR(1007, "HY000", "Can't create database '%s'; 
database exists"),
     
+    ER_DB_DROP_EXISTS_ERROR(1008, "HY000", "Can't drop database '%s'; database 
doesn't exist"),
+    
     ER_TABLE_EXISTS_ERROR(1050, "42S01", "Table '%s' already exists"),
     
     ER_NOT_SUPPORTED_YET(1235, "42000", "This version of ShardingProxy doesn't 
yet support this SQL. '%s'"),
diff --git 
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
 
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
index be7f48a..a0878eb 100644
--- 
a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
+++ 
b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
@@ -46,6 +46,7 @@ import 
org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -67,7 +68,7 @@ public final class ConfigCenter {
         this.repository = repository;
         
DataSourceCallback.getInstance().register(this::persistDataSourceConfiguration);
         RuleCallback.getInstance().register(this::persistRuleConfigurations);
-        SchemaNameCallback.getInstance().register(this::persistSchemaName);
+        SchemaNameCallback.getInstance().register(this::persistSchema);
     }
     
     /**
@@ -199,6 +200,17 @@ public final class ConfigCenter {
         repository.persist(node.getSchemaPath(), 
Joiner.on(",").join(newArrayList));
     }
     
+    private void persistSchema(final String schemaName, final boolean 
isDeleted) {
+        String schemaNames = repository.get(node.getSchemaPath());
+        Collection<String> schemas = new 
LinkedHashSet<>(Splitter.on(",").splitToList(schemaNames));
+        if (isDeleted) {
+            schemas.remove(schemaName);
+        } else if (!schemas.contains(schemaName)) {
+            schemas.add(schemaName);
+        }
+        repository.persist(node.getSchemaPath(), Joiner.on(",").join(schemas));
+    }
+    
     /**
      * Load data source configurations.
      *
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/DBDropExistsException.java
similarity index 68%
copy from 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
copy to 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/DBDropExistsException.java
index 033c60e..0f80bf6 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/DBDropExistsException.java
@@ -15,12 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
+package org.apache.shardingsphere.proxy.backend.exception;
 
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 
 /**
- * Drop database statement.
+ * DB drop exists exception.
  */
-public final class DropDatabaseStatement extends AbstractSQLStatement 
implements DDLStatement {
+@RequiredArgsConstructor
+@Getter
+public final class DBDropExistsException extends BackendException {
+    
+    private static final long serialVersionUID = 6088272565526510361L;
+    
+    private final String databaseName;
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
index bf40f8d..64690f4 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
@@ -38,15 +38,16 @@ import 
org.apache.shardingsphere.rdl.parser.statement.rdl.RDLStatement;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
-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 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.BeginTransactionStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.SetAutoCommitStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
+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 org.apache.shardingsphere.transaction.core.TransactionOperationType;
 
 /**
@@ -73,7 +74,7 @@ public final class TextProtocolBackendHandlerFactory {
             return ShardingCTLBackendHandlerFactory.newInstance(trimSQL, 
backendConnection);
         }
         SQLStatement sqlStatement = 
ShardingSphereSQLParserEngineFactory.getSQLParserEngine(databaseType.getName()).parse(sql,
 false);
-        if (sqlStatement instanceof RDLStatement || sqlStatement instanceof 
CreateDatabaseStatement) {
+        if (sqlStatement instanceof RDLStatement || sqlStatement instanceof 
CreateDatabaseStatement || sqlStatement instanceof DropDatabaseStatement) {
             return new RDLBackendHandler(backendConnection, sqlStatement);
         }
         if (sqlStatement instanceof TCLStatement) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
index f7b5b93..1982678 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
@@ -23,9 +23,9 @@ import 
org.apache.shardingsphere.infra.callback.governance.RuleCallback;
 import org.apache.shardingsphere.infra.callback.governance.SchemaNameCallback;
 import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.context.impl.StandardSchemaContexts;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import 
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.infra.context.impl.StandardSchemaContexts;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import 
org.apache.shardingsphere.proxy.backend.exception.DBCreateExistsException;
 import org.apache.shardingsphere.proxy.backend.response.BackendResponse;
@@ -45,8 +45,10 @@ import 
org.apache.shardingsphere.sharding.convert.CreateShardingRuleStatementCon
 import 
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.ddl.CreateDatabaseStatementContext;
+import 
org.apache.shardingsphere.sql.parser.binder.statement.ddl.DropDatabaseStatementContext;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
 
 import java.sql.SQLException;
 import java.util.Collection;
@@ -76,13 +78,24 @@ public final class RDLBackendHandler implements 
TextProtocolBackendHandler {
         if 
(ProxySchemaContexts.getInstance().getSchemaNames().contains(context.getSqlStatement().getDatabaseName()))
 {
             return new ErrorResponse(new 
DBCreateExistsException(context.getSqlStatement().getDatabaseName()));
         }
-        
SchemaNameCallback.getInstance().run(context.getSqlStatement().getDatabaseName(),
 true);
+        
SchemaNameCallback.getInstance().run(context.getSqlStatement().getDatabaseName(),
 false);
         // TODO Need to get the executed feedback from registry center for 
returning.
         UpdateResponse result = new UpdateResponse();
         result.setType("CREATE");
         return result;
     }
     
+    private BackendResponse execute(final DropDatabaseStatementContext 
context) {
+        if 
(!ProxySchemaContexts.getInstance().getSchemaNames().contains(context.getSqlStatement().getDatabaseName()))
 {
+            return new ErrorResponse(new 
DBCreateExistsException(context.getSqlStatement().getDatabaseName()));
+        }
+        
SchemaNameCallback.getInstance().run(context.getSqlStatement().getDatabaseName(),
 true);
+        // TODO Need to get the executed feedback from registry center for 
returning.
+        UpdateResponse result = new UpdateResponse();
+        result.setType("DROP");
+        return result;
+    }
+    
     private BackendResponse execute(final CreateDataSourcesStatementContext 
context) {
         Map<String, YamlDataSourceParameter> parameters = new 
CreateDataSourcesStatementContextConverter().convert(context);
         Map<String, DataSourceConfiguration> dataSources = 
DataSourceConverter.getDataSourceConfigurationMap(DataSourceConverter.getDataSourceParameterMap2(parameters));
@@ -107,10 +120,14 @@ public final class RDLBackendHandler implements 
TextProtocolBackendHandler {
         DatabaseType databaseType = 
ProxySchemaContexts.getInstance().getSchemaContexts().getDatabaseType();
         if (sqlStatement instanceof CreateDataSourcesStatement) {
             return new 
CreateDataSourcesStatementContext((CreateDataSourcesStatement) sqlStatement, 
databaseType);
-        } else if (sqlStatement instanceof CreateShardingRuleStatement) {
+        }
+        if (sqlStatement instanceof CreateShardingRuleStatement) {
             return new 
CreateShardingRuleStatementContext((CreateShardingRuleStatement) sqlStatement);
         }
-        return new CreateDatabaseStatementContext((CreateDatabaseStatement) 
sqlStatement);
+        if (sqlStatement instanceof CreateDatabaseStatement) {
+            return new 
CreateDatabaseStatementContext((CreateDatabaseStatement) sqlStatement);
+        }
+        return new DropDatabaseStatementContext((DropDatabaseStatement) 
sqlStatement);
     }
     
     private BackendResponse getBackendResponse(final SQLStatementContext<?> 
context) {
@@ -120,6 +137,9 @@ public final class RDLBackendHandler implements 
TextProtocolBackendHandler {
         if (context instanceof CreateDataSourcesStatementContext) {
             return execute((CreateDataSourcesStatementContext) context);
         }
+        if (context instanceof DropDatabaseStatementContext) {
+            return execute((DropDatabaseStatementContext) context);
+        }
         return execute((CreateShardingRuleStatementContext) context);
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
index a2ef8fa..4c92818 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
@@ -33,6 +33,7 @@ import 
org.apache.shardingsphere.proxy.backend.schema.ProxySchemaContexts;
 import 
org.apache.shardingsphere.rdl.parser.statement.rdl.CreateDataSourcesStatement;
 import 
org.apache.shardingsphere.rdl.parser.statement.rdl.CreateShardingRuleStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -71,6 +72,18 @@ public final class RDLBackendHandlerTest {
     }
     
     @Test
+    public void assertExecuteDropDatabaseContext() {
+        BackendConnection connection = mock(BackendConnection.class);
+        when(connection.getSchema()).thenReturn("schema");
+        RDLBackendHandler executeEngine = new RDLBackendHandler(connection, 
new DropDatabaseStatement("schema"));
+        BackendResponse response = executeEngine.execute();
+        assertThat(response, instanceOf(ErrorResponse.class));
+        setGovernanceSchemaContexts(true);
+        response = executeEngine.execute();
+        assertThat(response, instanceOf(UpdateResponse.class));
+    }
+    
+    @Test
     public void assertExecuteCreateDatabaseContextWithException() {
         BackendConnection connection = mock(BackendConnection.class);
         when(connection.getSchema()).thenReturn("schema");
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLErrPacketFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLErrPacketFactory.java
index b75155b..f7437f4 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLErrPacketFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLErrPacketFactory.java
@@ -24,6 +24,7 @@ import 
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerErrorCode
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
 import 
org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
 import 
org.apache.shardingsphere.proxy.backend.exception.DBCreateExistsException;
+import org.apache.shardingsphere.proxy.backend.exception.DBDropExistsException;
 import 
org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
 import 
org.apache.shardingsphere.proxy.backend.exception.TableModifyInTransactionException;
 import 
org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
@@ -69,6 +70,9 @@ public final class MySQLErrPacketFactory {
         if (cause instanceof DBCreateExistsException) {
             return new MySQLErrPacket(sequenceId, 
MySQLServerErrorCode.ER_DB_CREATE_EXISTS_ERROR, ((DBCreateExistsException) 
cause).getDatabaseName());
         }
+        if (cause instanceof DBDropExistsException) {
+            return new MySQLErrPacket(sequenceId, 
MySQLServerErrorCode.ER_DB_DROP_EXISTS_ERROR, ((DBDropExistsException) 
cause).getDatabaseName());
+        }
         if (cause instanceof TableExistsException) {
             return new MySQLErrPacket(sequenceId, 
MySQLServerErrorCode.ER_TABLE_EXISTS_ERROR, ((TableExistsException) 
cause).getTableName());
         }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareCheckerTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareCheckerTest.java
index b6dcd24..e37afd6 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareCheckerTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareCheckerTest.java
@@ -83,7 +83,7 @@ public final class MySQLComStmtPrepareCheckerTest {
         List<SQLStatement> statementList = Arrays.asList(
             new AlterTableStatement(mock(SimpleTableSegment.class)), new 
AlterUserStatement(), new MySQLAnalyzeTableStatement(), new 
MySQLCacheIndexStatement(),
             new CallStatement(), new ChangeMasterStatement(), new 
MySQLChecksumTableStatement(), new CommitStatement(), new 
CreateIndexStatement(), new DropIndexStatement(),
-            new CreateDatabaseStatement(""), new DropDatabaseStatement(), new 
CreateTableStatement(mock(SimpleTableSegment.class)), new DropTableStatement(), 
new CreateUserStatement(),
+            new CreateDatabaseStatement(""), new DropDatabaseStatement(""), 
new CreateTableStatement(mock(SimpleTableSegment.class)), new 
DropTableStatement(), new CreateUserStatement(),
             new RenameUserStatement(), new DropUserStatement(), new 
CreateViewStatement(), new DropViewStatement(), new DeleteStatement(), new 
DoStatement(), new MySQLFlushStatement(),
             new GrantStatement(), new InsertStatement(), new 
MySQLInstallPluginStatement(), new MySQLKillStatement(), new 
MySQLLoadIndexInfoStatement(), new MySQLOptimizeTableStatement(),
             new RenameTableStatement(), new MySQLRepairTableStatement(), new 
MySQLResetStatement(), new RevokeStatement(), new SelectStatement(), new 
SetStatement(), new MySQLShowWarningsStatement(),
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/ddl/DropDatabaseStatementContext.java
similarity index 64%
copy from 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
copy to 
shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/ddl/DropDatabaseStatementContext.java
index 033c60e..93652fd 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/ddl/DropDatabaseStatementContext.java
@@ -15,12 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
+package org.apache.shardingsphere.sql.parser.binder.statement.ddl;
 
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import lombok.Getter;
+import 
org.apache.shardingsphere.sql.parser.binder.statement.CommonSQLStatementContext;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
 
 /**
- * Drop database statement.
+ * Drop database statement context.
  */
-public final class DropDatabaseStatement extends AbstractSQLStatement 
implements DDLStatement {
+@Getter
+public final class DropDatabaseStatementContext extends 
CommonSQLStatementContext<DropDatabaseStatement> {
+    
+    public DropDatabaseStatementContext(final DropDatabaseStatement 
sqlStatement) {
+        super(sqlStatement);
+    }
 }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java
index 5019dc5..51bf2f7 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java
@@ -151,7 +151,7 @@ public final class MySQLDDLVisitor extends MySQLVisitor 
implements DDLVisitor {
     
     @Override
     public ASTNode visitDropDatabase(final DropDatabaseContext ctx) {
-        return new DropDatabaseStatement();
+        return new DropDatabaseStatement(ctx.schemaName().getText());
     }
     
     @Override
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
index 033c60e..ebd07ac 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/DropDatabaseStatement.java
@@ -17,10 +17,16 @@
 
 package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
 
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
 
 /**
  * Drop database statement.
  */
+@RequiredArgsConstructor
+@Getter
 public final class DropDatabaseStatement extends AbstractSQLStatement 
implements DDLStatement {
+    
+    private final String databaseName;
 }

Reply via email to