You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "JiekerTime (via GitHub)" <gi...@apache.org> on 2023/05/22 08:56:53 UTC

[GitHub] [shardingsphere] JiekerTime opened a new pull request, #25843: Support metadata table pg_tables,pg_roles in og scenario.

JiekerTime opened a new pull request, #25843:
URL: https://github.com/apache/shardingsphere/pull/25843

   Enhance https://github.com/apache/shardingsphere/pull/25741
   
   Liked to issue #25468 #24662. maybe.
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [x] I have (or in comment I request) added corresponding labels for the pull request.
   - [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [x] I have added corresponding unit tests for my changes.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] JiekerTime merged pull request #25843: Support metadata table pg_tables,pg_roles in og scenario.

Posted by "JiekerTime (via GitHub)" <gi...@apache.org>.
JiekerTime merged PR #25843:
URL: https://github.com/apache/shardingsphere/pull/25843


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #25843: Support metadata table pg_tables,pg_roles in og scenario.

Posted by "tuichenchuxin (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] JiekerTime commented on pull request #25843: Support metadata table pg_tables,pg_roles in og scenario.

Posted by "JiekerTime (via GitHub)" <gi...@apache.org>.
JiekerTime commented on PR #25843:
URL: https://github.com/apache/shardingsphere/pull/25843#issuecomment-1556824203

   @sandynz 


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org