totalo commented on a change in pull request #10115:
URL: https://github.com/apache/shardingsphere/pull/10115#discussion_r615537883



##########
File path: 
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandler.java
##########
@@ -46,25 +45,56 @@
  * PostgreSQL privilege handler.
  */
 public final class PostgreSQLPrivilegeHandler implements 
StoragePrivilegeHandler {
-    
+
+    private static final String CREATE_USER_SQL = "CREATE USER %s WITH 
PASSWORD '%s'";
+
+    private static final String GRANT_ALL_SQL = "GRANT ALL ON ALL TABLES IN 
SCHEMA public TO %s";
+
     private static final String ROLES_SQL = "select * from pg_roles WHERE 
rolname IN (%s)";
-    
-    private static final String TABLE_PRIVILEGE_SQL = 
+
+    private static final String TABLE_PRIVILEGE_SQL =
             "SELECT grantor, grantee, table_catalog, table_name, 
privilege_type, is_grantable from information_schema.table_privileges WHERE 
grantee IN (%s)";
-    
+
     @Override
     public Collection<ShardingSphereUser> diff(final 
Collection<ShardingSphereUser> users, final DataSource dataSource) throws 
SQLException {
-        return Collections.emptyList();
+        Collection<Grantee> grantees = new LinkedList<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = 
statement.executeQuery(getRolePrivilegesSQL(users))) {
+                while (resultSet.next()) {
+                    grantees.add(new Grantee(resultSet.getString("rolname"), 
""));

Review comment:
       There is no concept of distinguishing users and roles in PostgreSQL, so 
`rolename` is equivalent to `username` here




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