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

zhonghongsheng 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 cff82c0  Stop writing supported for DistSQL (#16468)
cff82c0 is described below

commit cff82c0c0258fdfed11927cdccca0bb9b7e46c77
Author: gin <[email protected]>
AuthorDate: Tue Mar 29 18:08:52 2022 +0800

    Stop writing supported for DistSQL (#16468)
    
    * Stop writing supported for DistSQL
    
    * Optimize intercepted statement types
---
 .../text/distsql/DistSQLBackendHandlerFactory.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
index 6382244..6c8e29a 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
@@ -20,10 +20,15 @@ package 
org.apache.shardingsphere.proxy.backend.text.distsql;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.statement.DistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.QueryableScalingRALStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.UpdatableScalingRALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.rdl.RDLStatement;
 import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.exception.SchemaLockedException;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.RALBackendHandlerFactory;
@@ -52,11 +57,23 @@ public final class DistSQLBackendHandlerFactory {
             return RQLBackendHandlerFactory.newInstance((RQLStatement) 
sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof RDLStatement) {
+            checkLockedSchema(connectionSession);
             return RDLBackendHandlerFactory.newInstance(databaseType, 
(RDLStatement) sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof RALStatement) {
+            if (sqlStatement instanceof QueryableRALStatement || sqlStatement 
instanceof QueryableScalingRALStatement || sqlStatement instanceof 
UpdatableScalingRALStatement) {
+                return RALBackendHandlerFactory.newInstance(databaseType, 
(RALStatement) sqlStatement, connectionSession);
+            }
+            checkLockedSchema(connectionSession);
             return RALBackendHandlerFactory.newInstance(databaseType, 
(RALStatement) sqlStatement, connectionSession);
         }
         throw new 
UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
     }
+    
+    private static void checkLockedSchema(final ConnectionSession 
connectionSession) {
+        String schemaName = connectionSession.getSchemaName();
+        if 
(ProxyContext.getInstance().getContextManager().getLockContext().isLockedSchema(schemaName))
 {
+            throw new SchemaLockedException(schemaName);
+        }
+    }
 }

Reply via email to