You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/04/03 14:33:22 UTC

[GitHub] [shardingsphere] PengWangSan opened a new pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

PengWangSan opened a new pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928


   …e t1 on postgresql DB. #9893
   
   Fixes #9893.
   
   Changes proposed in this pull request:
   org.apache.shardingsphere.infra.metadata.schema.builder.loader.SchemaMetaDataLoader
   


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-813823089


   Hi, How about Oracle and SQLServer? They are same with MySQL or PostgreSQL?


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] PengWangSan commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
PengWangSan commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-813207200


   > Hi @PengWangSan ,
   > 
   > Thanks for your PR.
   > We suggest users configure ShardingSphere with a super user. However, if you only have some users with restricted privileges, I guess this issue is not just about PostgreSQL, but `MySQL` and other databases. How do you think?
   
   HI @tristaZero ,Your suggestion is good,but in some company,the super user can't be granted for devloper team. In sharding jdbc, the loadAllTableNames method invoke jdbc driver for getting result. I have tried, mysql driver will only return the tables that has  permission. so it is ok for mysql.


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-884681768


   Hi @MingxingLAI ,
   
   Do you want to have a try this PR?
   First, Please figure out whether this issue indeed exists.
   Second, 
   > HI, I have confirmed Oracle and SQLServer is same with MySQL.
   
   Is it true?
   
   Third, If so, please consider fixing it.


-- 
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] tristaZero commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-882023325


   Hi We are tidying the PR list, and I found this PR is blocked, could you have a  look here? Therefore, we can get it going.


-- 
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] tristaZero commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-884680768


   Hi since there is no progress, I have to close it.


-- 
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] PengWangSan commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
PengWangSan commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-816007998


   > Hi, How about Oracle and SQLServer? Are they same with MySQL or PostgreSQL?
   
   HI, I have confirmed Oracle and SQLServer  is same with mysql.


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-813823089


   Hi, How about Oracle and SQLServer? Are they same with MySQL or PostgreSQL?


-- 
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#discussion_r671807987



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/loader/SchemaMetaDataLoader.java
##########
@@ -51,23 +51,36 @@
      */
     public static Collection<String> loadAllTableNames(final DataSource dataSource, final DatabaseType databaseType) throws SQLException {
         try (MetaDataLoaderConnectionAdapter connectionAdapter = new MetaDataLoaderConnectionAdapter(databaseType, dataSource.getConnection())) {
-            return loadAllTableNames(connectionAdapter);
+            return loadAllTableNames(connectionAdapter, databaseType);
         }
     }
     
-    private static Collection<String> loadAllTableNames(final Connection connection) throws SQLException {
+    private static Collection<String> loadAllTableNames(final Connection connection, final DatabaseType databaseType) throws SQLException {
         Collection<String> result = new LinkedList<>();
         try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), connection.getSchema(), null, new String[]{TABLE_TYPE, VIEW_TYPE})) {
             while (resultSet.next()) {
                 String table = resultSet.getString(TABLE_NAME);
-                if (!isSystemTable(table)) {
+                if (!isSystemTable(table) && isPermission(connection, databaseType.getName(), table)) {
                     result.add(table);
                 }
             }
         }
         return result;
     }
     
+    private static boolean isPermission(final Connection connection, final String databaseType, final String table)
+            throws SQLException {
+        boolean isPermission = true;
+        if ("postgresql".equalsIgnoreCase(databaseType)) {
+            ResultSet resultSet = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)
+                    .executeQuery("SELECT table_name FROM information_schema.role_table_grants where table_name='" + table + "'");
+            if (!resultSet.next()) {

Review comment:
       Hi @PengWangSan Do you think we can judge `isPermission` or not by using `connection.getMetadata()` or other JDBC interface functions?




-- 
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] MingxingLAI commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
MingxingLAI commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-886021551


   Hi @tristaZero ,I’m glad you still remember me, I went out for a few days of meetings, so I’m late to reply, please don’t mind.
   
   Please assign to me.


-- 
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] tristaZero commented on pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928#issuecomment-886028694


   Hi @MingxingLAI 
   
   Please comment on #9893 so that I can assign it to U.


-- 
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] tristaZero closed pull request #9928: Fixes sharding jdbc startup error when user has no permission of tabl…

Posted by GitBox <gi...@apache.org>.
tristaZero closed pull request #9928:
URL: https://github.com/apache/shardingsphere/pull/9928


   


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