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: [email protected]

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


Reply via email to