tuichenchuxin commented on code in PR #25843:
URL: https://github.com/apache/shardingsphere/pull/25843#discussion_r1217826152


##########
proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java:
##########
@@ -88,11 +97,24 @@ private void prepareCalciteConnection(final Connection 
connection) throws SQLExc
     private OpenGaussSystemCatalog constructOgCatalog() {
         Collection<String> allDatabaseNames = 
ProxyContext.getInstance().getAllDatabaseNames();
         OpenGaussDatabase[] openGaussDatabases = new 
OpenGaussDatabase[allDatabaseNames.size()];
-        int i = 0;
-        for (String each : allDatabaseNames) {
-            openGaussDatabases[i++] = new OpenGaussDatabase(each, 
DAT_COMPATIBILITY);
+        List<OpenGaussTables> openGaussTables = new LinkedList<>();
+        List<OpenGaussRoles> openGaussRoles = new LinkedList<>();
+        
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(AuthorityRule.class)
+                .getConfiguration().getUsers().stream().map(user -> 
user.getGrantee().getUsername())
+                .forEach(userName -> openGaussRoles.add(new 
OpenGaussRoles(userName)));
+        int index = 0;
+        for (String databaseName : allDatabaseNames) {

Review Comment:
   better use each to replace databaseName



##########
proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java:
##########
@@ -88,11 +97,24 @@ private void prepareCalciteConnection(final Connection 
connection) throws SQLExc
     private OpenGaussSystemCatalog constructOgCatalog() {
         Collection<String> allDatabaseNames = 
ProxyContext.getInstance().getAllDatabaseNames();
         OpenGaussDatabase[] openGaussDatabases = new 
OpenGaussDatabase[allDatabaseNames.size()];
-        int i = 0;
-        for (String each : allDatabaseNames) {
-            openGaussDatabases[i++] = new OpenGaussDatabase(each, 
DAT_COMPATIBILITY);
+        List<OpenGaussTables> openGaussTables = new LinkedList<>();
+        List<OpenGaussRoles> openGaussRoles = new LinkedList<>();
+        
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(AuthorityRule.class)
+                .getConfiguration().getUsers().stream().map(user -> 
user.getGrantee().getUsername())
+                .forEach(userName -> openGaussRoles.add(new 
OpenGaussRoles(userName)));
+        int index = 0;
+        for (String databaseName : allDatabaseNames) {
+            for (Map.Entry<String, ShardingSphereSchema> schema : 
ProxyContext.getInstance().getDatabase(databaseName).getSchemas().entrySet()) {
+                String schemaName = schema.getKey();
+                for (String tableName : schema.getValue().getAllTableNames()) {

Review Comment:
   replace tableName with each



##########
proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java:
##########
@@ -88,11 +97,24 @@ private void prepareCalciteConnection(final Connection 
connection) throws SQLExc
     private OpenGaussSystemCatalog constructOgCatalog() {
         Collection<String> allDatabaseNames = 
ProxyContext.getInstance().getAllDatabaseNames();
         OpenGaussDatabase[] openGaussDatabases = new 
OpenGaussDatabase[allDatabaseNames.size()];
-        int i = 0;
-        for (String each : allDatabaseNames) {
-            openGaussDatabases[i++] = new OpenGaussDatabase(each, 
DAT_COMPATIBILITY);
+        List<OpenGaussTables> openGaussTables = new LinkedList<>();
+        List<OpenGaussRoles> openGaussRoles = new LinkedList<>();
+        
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(AuthorityRule.class)
+                .getConfiguration().getUsers().stream().map(user -> 
user.getGrantee().getUsername())
+                .forEach(userName -> openGaussRoles.add(new 
OpenGaussRoles(userName)));
+        int index = 0;
+        for (String databaseName : allDatabaseNames) {
+            for (Map.Entry<String, ShardingSphereSchema> schema : 
ProxyContext.getInstance().getDatabase(databaseName).getSchemas().entrySet()) {

Review Comment:
   use `Entry` to replace `Map.Entry` 
   use `entry` to replace `schema`



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to