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/02 14:43:08 UTC

[GitHub] [shardingsphere] zhujunxxxxx opened a new pull request #9924: Add PostgreSQL privilege loader

zhujunxxxxx opened a new pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924


   Fixes #9853.
   
   Changes proposed in this pull request:
   - add PostgreSQL privilege loader
   - add PostgreSQL privilege loader testcase
   


-- 
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] codecov-io edited a comment on pull request #9924: Add PostgreSQL privilege loader

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924#issuecomment-812955023


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=h1) Report
   > Merging [#9924](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=desc) (489f497) into [master](https://codecov.io/gh/apache/shardingsphere/commit/00b1703646aa8d144e73d4e56ae8514036bf690c?el=desc) (00b1703) will **increase** coverage by `0.06%`.
   > The diff coverage is `85.10%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/9924/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #9924      +/-   ##
   ============================================
   + Coverage     67.99%   68.05%   +0.06%     
   - Complexity      677      678       +1     
   ============================================
     Files          1684     1685       +1     
     Lines         28281    28389     +108     
     Branches       5017     5049      +32     
   ============================================
   + Hits          19230    19321      +91     
   - Misses         7628     7636       +8     
   - Partials       1423     1432       +9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...lder/loader/dialect/PostgreSQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvUG9zdGdyZVNRTFByaXZpbGVnZUxvYWRlci5qYXZh) | `83.72% <83.72%> (ø)` | `1.00 <1.00> (?)` | |
   | [...a/metadata/auth/model/privilege/PrivilegeType.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL21vZGVsL3ByaXZpbGVnZS9Qcml2aWxlZ2VUeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlUHJlcGFyZWRTdGF0ZW1lbnQuamF2YQ==) | `74.37% <0.00%> (-0.38%)` | `1.00% <0.00%> (ø%)` | |
   | [...r/jdbc/core/statement/ShardingSphereStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlU3RhdGVtZW50LmphdmE=) | `58.98% <0.00%> (-0.28%)` | `1.00% <0.00%> (ø%)` | |
   | [...nfra/context/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29udGV4dC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvY29udGV4dC9tZXRhZGF0YS9NZXRhRGF0YUNvbnRleHRzQnVpbGRlci5qYXZh) | `90.74% <0.00%> (-0.17%)` | `0.00% <0.00%> (ø%)` | |
   | [.../infra/metadata/auth/builder/PrivilegeBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvUHJpdmlsZWdlQnVpbGRlci5qYXZh) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...infra/rule/builder/ShardingSphereRulesBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9ydWxlL2J1aWxkZXIvU2hhcmRpbmdTcGhlcmVSdWxlc0J1aWxkZXIuamF2YQ==) | `100.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...a/executor/sql/execute/engine/raw/RawExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9leGVjdXRlL2VuZ2luZS9yYXcvUmF3RXhlY3V0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...e/shardingsphere/authority/rule/AuthorityRule.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtYXV0aG9yaXR5L3NoYXJkaW5nc3BoZXJlLWF1dGhvcml0eS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2F1dGhvcml0eS9ydWxlL0F1dGhvcml0eVJ1bGUuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...gsphere/shadow/rule/builder/ShadowRuleBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYWRvdy9ydWxlL2J1aWxkZXIvU2hhZG93UnVsZUJ1aWxkZXIuamF2YQ==) | `100.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | ... and [14 more](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=footer). Last update [00b1703...489f497](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


-- 
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] zhujunxxxxx commented on a change in pull request #9924: Add PostgreSQL privilege loader

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builder/loader/dialect/PostgreSQLPrivilegeLoader.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.auth.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.auth.builder.loader.PrivilegeLoader;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.ShardingSpherePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.SchemaPrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.TablePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * PostgreSQL privilege loader.
+ */
+public final class PostgreSQLPrivilegeLoader implements PrivilegeLoader {
+
+    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 Map<ShardingSphereUser, ShardingSpherePrivilege> load(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
+        Map<ShardingSphereUser, ShardingSpherePrivilege> result = new LinkedHashMap<>();
+        users.forEach(user -> result.put(user, new ShardingSpherePrivilege()));
+        fillTablePrivilege(result, dataSource, users);
+        return result;
+    }
+    
+    private void fillTablePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getTablePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    collectPrivilege(privilegeCache, resultSet);
+                }
+            }
+        }
+        fillTablePrivilege(privilegeCache, privileges);
+    }
+
+    private void fillTablePrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges) {
+        for (ShardingSphereUser user : privilegeCache.keySet()) {
+            for (String db : privilegeCache.get(user).keySet()) {
+                for (String tableName : privilegeCache.get(user).get(db).keySet()) {
+                    TablePrivilege tablePrivilege = new TablePrivilege(tableName, privilegeCache.get(user).get(db).get(tableName));
+                    ShardingSpherePrivilege privilege = privileges.get(user);
+                    if (!privilege.getDatabasePrivilege().getSpecificPrivileges().containsKey(db)) {
+                        privilege.getDatabasePrivilege().getSpecificPrivileges().put(db, new SchemaPrivilege(db));
+                    }
+                    privilege.getDatabasePrivilege().getSpecificPrivileges().get(db).getSpecificPrivileges().put(tableName, tablePrivilege);
+                }
+            }
+        }
+    }
+
+    private void collectPrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final ResultSet resultSet) throws SQLException {
+        String db = resultSet.getString("table_catalog");
+        String tableName = resultSet.getString("table_name");
+        String privilegeType = resultSet.getString("privilege_type");
+        Boolean hasPrivilege = resultSet.getBoolean("is_grantable");
+        String grantee = resultSet.getString("grantee");
+        if (hasPrivilege) {
+            privilegeCache
+                    .computeIfAbsent(new ShardingSphereUser(grantee, "", ""), k -> new HashMap<>())
+                    .computeIfAbsent(db, k -> new HashMap<>())
+                    .computeIfAbsent(tableName, k -> new ArrayList<>())
+                    .add(getPrivilegeType(privilegeType));
+        }
+    }
+
+    private String getTablePrivilegeSQL(final Collection<ShardingSphereUser> users) {
+        String userList = users.stream().map(each -> each.getGrantee().getUsername())
+                .collect(Collectors.joining(", "));
+        return String.format(TABLE_PRIVILEGE_SQL, userList);
+    }
+
+    private PrivilegeType getPrivilegeType(final String privilege) {
+        switch (privilege) {
+            case "SELECT":
+                return PrivilegeType.SELECT;
+            case "INSERT":
+                return PrivilegeType.INSERT;
+            case "UPDATE":
+                return PrivilegeType.UPDATE;
+            case "DELETE":
+                return PrivilegeType.DELETE;
+            case "CREATE":
+                return PrivilegeType.CREATE;
+            case "REFERENCES":
+                return PrivilegeType.REFERENCES;

Review comment:
       OK,I will add other `PrivilegeType`.
   
   > I am curious there are only privileges on tables in Pg database? How about super privilege?
   Can you give me some tips on how to get super privilege,I can't find it myself, it's not like MySQL.
   

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builder/loader/dialect/PostgreSQLPrivilegeLoader.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.auth.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.auth.builder.loader.PrivilegeLoader;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.ShardingSpherePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.SchemaPrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.TablePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * PostgreSQL privilege loader.
+ */
+public final class PostgreSQLPrivilegeLoader implements PrivilegeLoader {
+
+    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 Map<ShardingSphereUser, ShardingSpherePrivilege> load(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
+        Map<ShardingSphereUser, ShardingSpherePrivilege> result = new LinkedHashMap<>();
+        users.forEach(user -> result.put(user, new ShardingSpherePrivilege()));
+        fillTablePrivilege(result, dataSource, users);
+        return result;
+    }
+    
+    private void fillTablePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getTablePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    collectPrivilege(privilegeCache, resultSet);
+                }
+            }
+        }
+        fillTablePrivilege(privilegeCache, privileges);
+    }
+
+    private void fillTablePrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges) {
+        for (ShardingSphereUser user : privilegeCache.keySet()) {
+            for (String db : privilegeCache.get(user).keySet()) {
+                for (String tableName : privilegeCache.get(user).get(db).keySet()) {
+                    TablePrivilege tablePrivilege = new TablePrivilege(tableName, privilegeCache.get(user).get(db).get(tableName));
+                    ShardingSpherePrivilege privilege = privileges.get(user);
+                    if (!privilege.getDatabasePrivilege().getSpecificPrivileges().containsKey(db)) {
+                        privilege.getDatabasePrivilege().getSpecificPrivileges().put(db, new SchemaPrivilege(db));
+                    }
+                    privilege.getDatabasePrivilege().getSpecificPrivileges().get(db).getSpecificPrivileges().put(tableName, tablePrivilege);
+                }
+            }
+        }
+    }
+
+    private void collectPrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final ResultSet resultSet) throws SQLException {
+        String db = resultSet.getString("table_catalog");
+        String tableName = resultSet.getString("table_name");
+        String privilegeType = resultSet.getString("privilege_type");
+        Boolean hasPrivilege = resultSet.getBoolean("is_grantable");
+        String grantee = resultSet.getString("grantee");
+        if (hasPrivilege) {
+            privilegeCache
+                    .computeIfAbsent(new ShardingSphereUser(grantee, "", ""), k -> new HashMap<>())
+                    .computeIfAbsent(db, k -> new HashMap<>())
+                    .computeIfAbsent(tableName, k -> new ArrayList<>())
+                    .add(getPrivilegeType(privilegeType));
+        }
+    }
+
+    private String getTablePrivilegeSQL(final Collection<ShardingSphereUser> users) {
+        String userList = users.stream().map(each -> each.getGrantee().getUsername())
+                .collect(Collectors.joining(", "));
+        return String.format(TABLE_PRIVILEGE_SQL, userList);
+    }
+
+    private PrivilegeType getPrivilegeType(final String privilege) {
+        switch (privilege) {
+            case "SELECT":
+                return PrivilegeType.SELECT;
+            case "INSERT":
+                return PrivilegeType.INSERT;
+            case "UPDATE":
+                return PrivilegeType.UPDATE;
+            case "DELETE":
+                return PrivilegeType.DELETE;
+            case "CREATE":
+                return PrivilegeType.CREATE;
+            case "REFERENCES":
+                return PrivilegeType.REFERENCES;

Review comment:
       OK,I will add other `PrivilegeType`.
   
   > I am curious there are only privileges on tables in Pg database? How about super privilege?
   
   Can you give me some tips on how to get super privilege,I can't find it myself, it's not like 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 a change in pull request #9924: Add PostgreSQL privilege loader

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builder/loader/dialect/PostgreSQLPrivilegeLoader.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.auth.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.auth.builder.loader.PrivilegeLoader;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.ShardingSpherePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.SchemaPrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.TablePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * PostgreSQL privilege loader.
+ */
+public final class PostgreSQLPrivilegeLoader implements PrivilegeLoader {
+
+    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 Map<ShardingSphereUser, ShardingSpherePrivilege> load(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
+        Map<ShardingSphereUser, ShardingSpherePrivilege> result = new LinkedHashMap<>();
+        users.forEach(user -> result.put(user, new ShardingSpherePrivilege()));
+        fillTablePrivilege(result, dataSource, users);
+        return result;
+    }
+    
+    private void fillTablePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getTablePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    collectPrivilege(privilegeCache, resultSet);
+                }
+            }
+        }
+        fillTablePrivilege(privilegeCache, privileges);
+    }
+
+    private void fillTablePrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges) {
+        for (ShardingSphereUser user : privilegeCache.keySet()) {
+            for (String db : privilegeCache.get(user).keySet()) {
+                for (String tableName : privilegeCache.get(user).get(db).keySet()) {
+                    TablePrivilege tablePrivilege = new TablePrivilege(tableName, privilegeCache.get(user).get(db).get(tableName));
+                    ShardingSpherePrivilege privilege = privileges.get(user);
+                    if (!privilege.getDatabasePrivilege().getSpecificPrivileges().containsKey(db)) {
+                        privilege.getDatabasePrivilege().getSpecificPrivileges().put(db, new SchemaPrivilege(db));
+                    }
+                    privilege.getDatabasePrivilege().getSpecificPrivileges().get(db).getSpecificPrivileges().put(tableName, tablePrivilege);
+                }
+            }
+        }
+    }
+
+    private void collectPrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final ResultSet resultSet) throws SQLException {
+        String db = resultSet.getString("table_catalog");
+        String tableName = resultSet.getString("table_name");
+        String privilegeType = resultSet.getString("privilege_type");
+        Boolean hasPrivilege = resultSet.getBoolean("is_grantable");
+        String grantee = resultSet.getString("grantee");
+        if (hasPrivilege) {
+            privilegeCache
+                    .computeIfAbsent(new ShardingSphereUser(grantee, "", ""), k -> new HashMap<>())
+                    .computeIfAbsent(db, k -> new HashMap<>())
+                    .computeIfAbsent(tableName, k -> new ArrayList<>())
+                    .add(getPrivilegeType(privilegeType));
+        }
+    }
+
+    private String getTablePrivilegeSQL(final Collection<ShardingSphereUser> users) {
+        String userList = users.stream().map(each -> each.getGrantee().getUsername())
+                .collect(Collectors.joining(", "));
+        return String.format(TABLE_PRIVILEGE_SQL, userList);
+    }
+
+    private PrivilegeType getPrivilegeType(final String privilege) {
+        switch (privilege) {
+            case "SELECT":
+                return PrivilegeType.SELECT;
+            case "INSERT":
+                return PrivilegeType.INSERT;
+            case "UPDATE":
+                return PrivilegeType.UPDATE;
+            case "DELETE":
+                return PrivilegeType.DELETE;
+            case "CREATE":
+                return PrivilegeType.CREATE;
+            case "REFERENCES":
+                return PrivilegeType.REFERENCES;

Review comment:
       How about `usage`, `connect` and others?  If needed, you can add more types in `PrivilegeType`.

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builder/loader/dialect/PostgreSQLPrivilegeLoader.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.auth.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.auth.builder.loader.PrivilegeLoader;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.ShardingSpherePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.SchemaPrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.TablePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * PostgreSQL privilege loader.
+ */
+public final class PostgreSQLPrivilegeLoader implements PrivilegeLoader {
+
+    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 Map<ShardingSphereUser, ShardingSpherePrivilege> load(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
+        Map<ShardingSphereUser, ShardingSpherePrivilege> result = new LinkedHashMap<>();
+        users.forEach(user -> result.put(user, new ShardingSpherePrivilege()));
+        fillTablePrivilege(result, dataSource, users);
+        return result;
+    }
+    
+    private void fillTablePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getTablePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    collectPrivilege(privilegeCache, resultSet);
+                }
+            }
+        }
+        fillTablePrivilege(privilegeCache, privileges);
+    }
+
+    private void fillTablePrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges) {
+        for (ShardingSphereUser user : privilegeCache.keySet()) {
+            for (String db : privilegeCache.get(user).keySet()) {
+                for (String tableName : privilegeCache.get(user).get(db).keySet()) {
+                    TablePrivilege tablePrivilege = new TablePrivilege(tableName, privilegeCache.get(user).get(db).get(tableName));
+                    ShardingSpherePrivilege privilege = privileges.get(user);
+                    if (!privilege.getDatabasePrivilege().getSpecificPrivileges().containsKey(db)) {
+                        privilege.getDatabasePrivilege().getSpecificPrivileges().put(db, new SchemaPrivilege(db));
+                    }
+                    privilege.getDatabasePrivilege().getSpecificPrivileges().get(db).getSpecificPrivileges().put(tableName, tablePrivilege);
+                }
+            }
+        }
+    }
+
+    private void collectPrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final ResultSet resultSet) throws SQLException {
+        String db = resultSet.getString("table_catalog");
+        String tableName = resultSet.getString("table_name");
+        String privilegeType = resultSet.getString("privilege_type");
+        Boolean hasPrivilege = resultSet.getBoolean("is_grantable");
+        String grantee = resultSet.getString("grantee");
+        if (hasPrivilege) {
+            privilegeCache
+                    .computeIfAbsent(new ShardingSphereUser(grantee, "", ""), k -> new HashMap<>())
+                    .computeIfAbsent(db, k -> new HashMap<>())
+                    .computeIfAbsent(tableName, k -> new ArrayList<>())
+                    .add(getPrivilegeType(privilegeType));
+        }
+    }
+
+    private String getTablePrivilegeSQL(final Collection<ShardingSphereUser> users) {
+        String userList = users.stream().map(each -> each.getGrantee().getUsername())
+                .collect(Collectors.joining(", "));
+        return String.format(TABLE_PRIVILEGE_SQL, userList);
+    }
+
+    private PrivilegeType getPrivilegeType(final String privilege) {
+        switch (privilege) {
+            case "SELECT":
+                return PrivilegeType.SELECT;
+            case "INSERT":
+                return PrivilegeType.INSERT;
+            case "UPDATE":
+                return PrivilegeType.UPDATE;
+            case "DELETE":
+                return PrivilegeType.DELETE;
+            case "CREATE":
+                return PrivilegeType.CREATE;
+            case "REFERENCES":
+                return PrivilegeType.REFERENCES;

Review comment:
       Can we transfer `Role Attributes` (login,superuser,createdb,createrole,replication,passwod,inherit) and put them info this privilege system?




-- 
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] codecov-io edited a comment on pull request #9924: Add PostgreSQL privilege loader

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924#issuecomment-812955023


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=h1) Report
   > Merging [#9924](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=desc) (956b625) into [master](https://codecov.io/gh/apache/shardingsphere/commit/00b1703646aa8d144e73d4e56ae8514036bf690c?el=desc) (00b1703) will **decrease** coverage by `0.02%`.
   > The diff coverage is `85.10%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/9924/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #9924      +/-   ##
   ============================================
   - Coverage     67.99%   67.97%   -0.03%     
   - Complexity      677      678       +1     
   ============================================
     Files          1684     1686       +2     
     Lines         28281    28381     +100     
     Branches       5017     5048      +31     
   ============================================
   + Hits          19230    19291      +61     
   - Misses         7628     7658      +30     
   - Partials       1423     1432       +9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...lder/loader/dialect/PostgreSQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvUG9zdGdyZVNRTFByaXZpbGVnZUxvYWRlci5qYXZh) | `83.72% <83.72%> (ø)` | `1.00 <1.00> (?)` | |
   | [...a/metadata/auth/model/privilege/PrivilegeType.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL21vZGVsL3ByaXZpbGVnZS9Qcml2aWxlZ2VUeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...xt/admin/mysql/executor/ShowDatabasesExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2FkbWluL215c3FsL2V4ZWN1dG9yL1Nob3dEYXRhYmFzZXNFeGVjdXRvci5qYXZh) | `43.75% <0.00%> (-33.18%)` | `1.00% <0.00%> (ø%)` | |
   | [...sphere/scaling/core/job/schedule/JobScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2Ivc2NoZWR1bGUvSm9iU2NoZWR1bGVyLmphdmE=) | `22.22% <0.00%> (-29.63%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/scaling/core/executor/engine/ExecuteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9leGVjdXRvci9lbmdpbmUvRXhlY3V0ZUVuZ2luZS5qYXZh) | `88.88% <0.00%> (-11.12%)` | `0.00% <0.00%> (ø%)` | |
   | [...scaling/core/job/task/inventory/InventoryTask.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvdGFzay9pbnZlbnRvcnkvSW52ZW50b3J5VGFzay5qYXZh) | `68.88% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | [...rontend/mysql/auth/MySQLAuthenticationHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3Byb3h5L2Zyb250ZW5kL215c3FsL2F1dGgvTXlTUUxBdXRoZW50aWNhdGlvbkhhbmRsZXIuamF2YQ==) | `95.00% <0.00%> (-5.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...ing/core/job/task/incremental/IncrementalTask.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvdGFzay9pbmNyZW1lbnRhbC9JbmNyZW1lbnRhbFRhc2suamF2YQ==) | `72.91% <0.00%> (-2.09%)` | `0.00% <0.00%> (ø%)` | |
   | [...nfra/context/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29udGV4dC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvY29udGV4dC9tZXRhZGF0YS9NZXRhRGF0YUNvbnRleHRzQnVpbGRlci5qYXZh) | `89.79% <0.00%> (-1.12%)` | `0.00% <0.00%> (ø%)` | |
   | [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlUHJlcGFyZWRTdGF0ZW1lbnQuamF2YQ==) | `74.37% <0.00%> (-0.38%)` | `1.00% <0.00%> (ø%)` | |
   | ... and [30 more](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=footer). Last update [00b1703...956b625](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


-- 
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] codecov-io edited a comment on pull request #9924: Add PostgreSQL privilege loader

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924#issuecomment-812955023


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=h1) Report
   > Merging [#9924](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=desc) (b1a20ed) into [master](https://codecov.io/gh/apache/shardingsphere/commit/00b1703646aa8d144e73d4e56ae8514036bf690c?el=desc) (00b1703) will **increase** coverage by `0.06%`.
   > The diff coverage is `85.10%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/9924/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #9924      +/-   ##
   ============================================
   + Coverage     67.99%   68.05%   +0.06%     
   - Complexity      677      678       +1     
   ============================================
     Files          1684     1685       +1     
     Lines         28281    28389     +108     
     Branches       5017     5049      +32     
   ============================================
   + Hits          19230    19321      +91     
   - Misses         7628     7636       +8     
   - Partials       1423     1432       +9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...lder/loader/dialect/PostgreSQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvUG9zdGdyZVNRTFByaXZpbGVnZUxvYWRlci5qYXZh) | `83.72% <83.72%> (ø)` | `1.00 <1.00> (?)` | |
   | [...a/metadata/auth/model/privilege/PrivilegeType.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL21vZGVsL3ByaXZpbGVnZS9Qcml2aWxlZ2VUeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlUHJlcGFyZWRTdGF0ZW1lbnQuamF2YQ==) | `74.37% <0.00%> (-0.38%)` | `1.00% <0.00%> (ø%)` | |
   | [...r/jdbc/core/statement/ShardingSphereStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlU3RhdGVtZW50LmphdmE=) | `58.98% <0.00%> (-0.28%)` | `1.00% <0.00%> (ø%)` | |
   | [...nfra/context/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29udGV4dC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvY29udGV4dC9tZXRhZGF0YS9NZXRhRGF0YUNvbnRleHRzQnVpbGRlci5qYXZh) | `90.74% <0.00%> (-0.17%)` | `0.00% <0.00%> (ø%)` | |
   | [.../infra/metadata/auth/builder/PrivilegeBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvUHJpdmlsZWdlQnVpbGRlci5qYXZh) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...infra/rule/builder/ShardingSphereRulesBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9ydWxlL2J1aWxkZXIvU2hhcmRpbmdTcGhlcmVSdWxlc0J1aWxkZXIuamF2YQ==) | `100.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...a/executor/sql/execute/engine/raw/RawExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9leGVjdXRlL2VuZ2luZS9yYXcvUmF3RXhlY3V0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...e/shardingsphere/authority/rule/AuthorityRule.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtYXV0aG9yaXR5L3NoYXJkaW5nc3BoZXJlLWF1dGhvcml0eS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2F1dGhvcml0eS9ydWxlL0F1dGhvcml0eVJ1bGUuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...gsphere/shadow/rule/builder/ShadowRuleBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYWRvdy9ydWxlL2J1aWxkZXIvU2hhZG93UnVsZUJ1aWxkZXIuamF2YQ==) | `100.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | ... and [14 more](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=footer). Last update [00b1703...b1a20ed](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


-- 
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 merged pull request #9924: Add PostgreSQL privilege loader

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


   


-- 
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 #9924: Add PostgreSQL privilege loader

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builder/loader/dialect/PostgreSQLPrivilegeLoader.java
##########
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.auth.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.auth.builder.loader.PrivilegeLoader;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.ShardingSpherePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.SchemaPrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.privilege.database.TablePrivilege;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.Grantee;
+import org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * PostgreSQL privilege loader.
+ */
+public final class PostgreSQLPrivilegeLoader implements PrivilegeLoader {
+
+    private static final String ROLES_SQL = "select * from pg_roles WHERE rolname IN (%s)";
+
+    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 Map<ShardingSphereUser, ShardingSpherePrivilege> load(final Collection<ShardingSphereUser> users, final DataSource dataSource) throws SQLException {
+        Map<ShardingSphereUser, ShardingSpherePrivilege> result = new LinkedHashMap<>();
+        users.forEach(user -> result.put(user, new ShardingSpherePrivilege()));
+        fillTablePrivilege(result, dataSource, users);
+        fillRolePrivilege(result, dataSource, users);
+        return result;
+    }
+    
+    private void fillTablePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache = new HashMap<>();
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getTablePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    collectPrivilege(privilegeCache, resultSet);
+                }
+            }
+        }
+        fillTablePrivilege(privilegeCache, privileges);
+    }
+
+    private void fillTablePrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges) {
+        for (ShardingSphereUser user : privilegeCache.keySet()) {
+            for (String db : privilegeCache.get(user).keySet()) {
+                for (String tableName : privilegeCache.get(user).get(db).keySet()) {
+                    TablePrivilege tablePrivilege = new TablePrivilege(tableName, privilegeCache.get(user).get(db).get(tableName));
+                    ShardingSpherePrivilege privilege = privileges.get(user);
+                    if (!privilege.getDatabasePrivilege().getSpecificPrivileges().containsKey(db)) {
+                        privilege.getDatabasePrivilege().getSpecificPrivileges().put(db, new SchemaPrivilege(db));
+                    }
+                    privilege.getDatabasePrivilege().getSpecificPrivileges().get(db).getSpecificPrivileges().put(tableName, tablePrivilege);
+                }
+            }
+        }
+    }
+
+    private void collectPrivilege(final Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>> privilegeCache, final ResultSet resultSet) throws SQLException {
+        String db = resultSet.getString("table_catalog");
+        String tableName = resultSet.getString("table_name");
+        String privilegeType = resultSet.getString("privilege_type");
+        Boolean hasPrivilege = resultSet.getString("is_grantable").equalsIgnoreCase("TRUE");
+        String grantee = resultSet.getString("grantee");
+        if (hasPrivilege) {
+            privilegeCache
+                    .computeIfAbsent(new ShardingSphereUser(grantee, "", ""), k -> new HashMap<>())
+                    .computeIfAbsent(db, k -> new HashMap<>())
+                    .computeIfAbsent(tableName, k -> new ArrayList<>())
+                    .add(getPrivilegeType(privilegeType));
+        }
+    }
+
+    private void fillRolePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final DataSource dataSource, final Collection<ShardingSphereUser> users) throws SQLException {
+        try (Connection connection = dataSource.getConnection()) {
+            Statement statement = connection.createStatement();
+            try (ResultSet resultSet = statement.executeQuery(getRolePrivilegeSQL(users))) {
+                while (resultSet.next()) {
+                    fillRolePrivilege(privileges, resultSet);
+                }
+            }
+        }
+    }
+
+    private void fillRolePrivilege(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final ResultSet resultSet) throws SQLException {
+        Optional<ShardingSphereUser> user = getShardingSphereUser(privileges, resultSet);
+        if (user.isPresent()) {
+            privileges.get(user.get()).getAdministrativePrivilege().getPrivileges().addAll(loadRolePrivileges(resultSet));
+        }
+    }
+
+    private Optional<ShardingSphereUser> getShardingSphereUser(final Map<ShardingSphereUser, ShardingSpherePrivilege> privileges, final ResultSet resultSet) throws SQLException {
+        Grantee grantee = new Grantee(resultSet.getString("rolname"), "");
+        return privileges.keySet().stream().filter(each -> each.getGrantee().equals(grantee)).findFirst();
+    }
+
+    private Collection<PrivilegeType> loadRolePrivileges(final ResultSet resultSet) throws SQLException {
+        Collection<PrivilegeType> result = new LinkedList<>();
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolsuper"), PrivilegeType.SUPER, result);
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolcreaterole"), PrivilegeType.CREATE_ROLE, result);
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolcreatedb"), PrivilegeType.CREATE_DATABASE, result);
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolreplication"), PrivilegeType.REPL_CLIENT, result);
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolinherit"), PrivilegeType.INHERIT, result);
+        addToPrivilegeTypesIfPresent(resultSet.getBoolean("rolcanlogin"), PrivilegeType.CAN_LOGIN, result);
+        return result;
+    }
+
+    private String getTablePrivilegeSQL(final Collection<ShardingSphereUser> users) {
+        String userList = users.stream().map(each -> each.getGrantee().getUsername())

Review comment:
       Hi which is correct one for a query? `user1, user2` or `'user1', 'user2'`?




-- 
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] codecov-io commented on pull request #9924: Add PostgreSQL privilege loader

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924#issuecomment-812955023


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=h1) Report
   > Merging [#9924](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=desc) (d544611) into [master](https://codecov.io/gh/apache/shardingsphere/commit/00b1703646aa8d144e73d4e56ae8514036bf690c?el=desc) (00b1703) will **increase** coverage by `0.03%`.
   > The diff coverage is `83.01%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/9924/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #9924      +/-   ##
   ============================================
   + Coverage     67.99%   68.02%   +0.03%     
   - Complexity      677      678       +1     
   ============================================
     Files          1684     1685       +1     
     Lines         28281    28334      +53     
     Branches       5017     5035      +18     
   ============================================
   + Hits          19230    19275      +45     
   - Misses         7628     7632       +4     
   - Partials       1423     1427       +4     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...lder/loader/dialect/PostgreSQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvUG9zdGdyZVNRTFByaXZpbGVnZUxvYWRlci5qYXZh) | `83.01% <83.01%> (ø)` | `1.00 <1.00> (?)` | |
   | [.../auth/model/privilege/database/TablePrivilege.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL21vZGVsL3ByaXZpbGVnZS9kYXRhYmFzZS9UYWJsZVByaXZpbGVnZS5qYXZh) | `100.00% <0.00%> (+100.00%)` | `0.00% <0.00%> (ø%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=footer). Last update [00b1703...d544611](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


-- 
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] codecov-io edited a comment on pull request #9924: Add PostgreSQL privilege loader

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #9924:
URL: https://github.com/apache/shardingsphere/pull/9924#issuecomment-812955023


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=h1) Report
   > Merging [#9924](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=desc) (2873de2) into [master](https://codecov.io/gh/apache/shardingsphere/commit/00b1703646aa8d144e73d4e56ae8514036bf690c?el=desc) (00b1703) will **decrease** coverage by `0.00%`.
   > The diff coverage is `85.10%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/9924/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #9924      +/-   ##
   ============================================
   - Coverage     67.99%   67.98%   -0.01%     
   - Complexity      677      678       +1     
   ============================================
     Files          1684     1686       +2     
     Lines         28281    28385     +104     
     Branches       5017     5048      +31     
   ============================================
   + Hits          19230    19298      +68     
   - Misses         7628     7656      +28     
   - Partials       1423     1431       +8     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...lder/loader/dialect/PostgreSQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvUG9zdGdyZVNRTFByaXZpbGVnZUxvYWRlci5qYXZh) | `83.72% <83.72%> (ø)` | `1.00 <1.00> (?)` | |
   | [...a/metadata/auth/model/privilege/PrivilegeType.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL21vZGVsL3ByaXZpbGVnZS9Qcml2aWxlZ2VUeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...sphere/scaling/core/job/schedule/JobScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2Ivc2NoZWR1bGUvSm9iU2NoZWR1bGVyLmphdmE=) | `22.22% <0.00%> (-29.63%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/scaling/core/executor/engine/ExecuteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9leGVjdXRvci9lbmdpbmUvRXhlY3V0ZUVuZ2luZS5qYXZh) | `88.88% <0.00%> (-11.12%)` | `0.00% <0.00%> (ø%)` | |
   | [...scaling/core/job/task/inventory/InventoryTask.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvdGFzay9pbnZlbnRvcnkvSW52ZW50b3J5VGFzay5qYXZh) | `68.88% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | [...ing/core/job/task/incremental/IncrementalTask.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvdGFzay9pbmNyZW1lbnRhbC9JbmNyZW1lbnRhbFRhc2suamF2YQ==) | `72.91% <0.00%> (-2.09%)` | `0.00% <0.00%> (ø%)` | |
   | [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlUHJlcGFyZWRTdGF0ZW1lbnQuamF2YQ==) | `74.37% <0.00%> (-0.38%)` | `1.00% <0.00%> (ø%)` | |
   | [...r/jdbc/core/statement/ShardingSphereStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlU3RhdGVtZW50LmphdmE=) | `58.98% <0.00%> (-0.28%)` | `1.00% <0.00%> (ø%)` | |
   | [...h/builder/loader/dialect/MySQLPrivilegeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9hdXRoL2J1aWxkZXIvbG9hZGVyL2RpYWxlY3QvTXlTUUxQcml2aWxlZ2VMb2FkZXIuamF2YQ==) | `78.63% <0.00%> (-0.19%)` | `1.00% <0.00%> (ø%)` | |
   | [...nfra/context/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29udGV4dC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvY29udGV4dC9tZXRhZGF0YS9NZXRhRGF0YUNvbnRleHRzQnVpbGRlci5qYXZh) | `90.74% <0.00%> (-0.17%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [22 more](https://codecov.io/gh/apache/shardingsphere/pull/9924/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=footer). Last update [00b1703...2873de2](https://codecov.io/gh/apache/shardingsphere/pull/9924?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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