lwclover commented on a change in pull request #10899:
URL: https://github.com/apache/shardingsphere/pull/10899#discussion_r657695849



##########
File path: 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutor.java
##########
@@ -54,18 +54,18 @@ public void execute(final BackendConnection 
backendConnection) {
     private Collection<Object> getSchemaNames(final BackendConnection 
backendConnection) {
         try {
             MetaDataContexts contexts = 
ProxyContext.getInstance().getMetaDataContexts();
-            SQLCheckEngine.check(new MySQLShowDatabasesStatement(), 
Collections.emptyList(), 
-                    contexts.getGlobalRuleMetaData().getRules(), 
backendConnection.getSchemaName(), contexts.getMetaDataMap(), 
backendConnection.getGrantee());
-            return new 
ArrayList<>(ProxyContext.getInstance().getAllSchemaNames());
+            SQLCheckEngine.check(new MySQLShowDatabasesStatement(), 
Collections.emptyList(), contexts.getGlobalRuleMetaData().getRules(), 
backendConnection.getSchemaName(), contexts.getMetaDataMap(),
+                    backendConnection.getGrantee());
         } catch (final SQLCheckException ex) {
-            Collection<Object> result = new LinkedList<>();
-            for (String each : ProxyContext.getInstance().getAllSchemaNames()) 
{
-                if (SQLCheckEngine.check(each, getRules(each), 
backendConnection.getGrantee())) {
-                    result.add(each);
-                }
+            // ignore
+        }

Review comment:
       I think codes below are redundant lines. 
   ```
   MetaDataContexts contexts = ProxyContext.getInstance().getMetaDataContexts();
               SQLCheckEngine.check(new MySQLShowDatabasesStatement(), 
Collections.emptyList(), contexts.getGlobalRuleMetaData().getRules(), 
backendConnection.getSchemaName(), contexts.getMetaDataMap(),
                       backendConnection.getGrantee());
   ```
   
   ```
       private Collection<Object> getSchemaNames(final BackendConnection 
backendConnection) {
           Collection<Object> result = new LinkedList<>();
           for (String each : ProxyContext.getInstance().getAllSchemaNames()) {
               if (SQLCheckEngine.check(each, getRules(each), 
backendConnection.getGrantee())) {
                   result.add(each);
               }
           }
           return result;
       }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to