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 d7f6838  fix distsql init context error (#11186)
d7f6838 is described below

commit d7f68387e40bb8063feb700926ea5ce1f18cf3a9
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Wed Jul 7 11:08:21 2021 +0800

    fix distsql init context error (#11186)
---
 .../proxy/backend/text/TextProtocolBackendHandlerFactory.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 f92191b..a289f5a 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
@@ -34,8 +34,8 @@ import 
org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaH
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminBackendHandlerFactory;
-import 
org.apache.shardingsphere.proxy.backend.text.database.DatabaseOperateBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.backend.text.data.DatabaseBackendHandlerFactory;
+import 
org.apache.shardingsphere.proxy.backend.text.database.DatabaseOperateBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.DistSQLBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.backend.text.extra.ExtraTextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLBackendHandlerFactory;
@@ -84,6 +84,9 @@ public final class TextProtocolBackendHandlerFactory {
             return ShardingCTLBackendHandlerFactory.newInstance(trimSQL, 
backendConnection);
         }
         SQLStatement sqlStatement = new 
ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, 
backendConnection).getName()).parse(sql, false);
+        if (sqlStatement instanceof DistSQLStatement) {
+            return DistSQLBackendHandlerFactory.newInstance(databaseType, 
(DistSQLStatement) sqlStatement, backendConnection);
+        }
         SQLStatementContext<?> sqlStatementContext = 
SQLStatementContextFactory.newInstance(
                 
ProxyContext.getInstance().getMetaDataContexts().getMetaDataMap(), 
Collections.emptyList(), sqlStatement, 
backendConnection.getDefaultSchemaName());
         // TODO optimize SQLStatementSchemaHolder
@@ -103,9 +106,6 @@ public final class TextProtocolBackendHandlerFactory {
         if (sqlStatement instanceof CreateDatabaseStatement || sqlStatement 
instanceof DropDatabaseStatement) {
             return 
DatabaseOperateBackendHandlerFactory.newInstance(sqlStatement, 
backendConnection);
         }
-        if (sqlStatement instanceof DistSQLStatement) {
-            return DistSQLBackendHandlerFactory.newInstance(databaseType, 
(DistSQLStatement) sqlStatement, backendConnection);
-        }
         Optional<TextProtocolBackendHandler> databaseAdminBackendHandler = 
DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatement, 
backendConnection);
         return databaseAdminBackendHandler.orElseGet(() -> 
DatabaseBackendHandlerFactory.newInstance(sqlStatementContext, sql, 
backendConnection));
     }

Reply via email to