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 2022/10/24 10:36:34 UTC
[GitHub] [shardingsphere] wallacezhou opened a new pull request, #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
wallacezhou opened a new pull request, #21722:
URL: https://github.com/apache/shardingsphere/pull/21722
Fixes #21615.
Changes proposed in this pull request:
- choose only the privileges databases when a connect to proxy from a client tool
---
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 : `mvn clean install -B -T2C -DskipTests -Dmaven.javadoc.skip=true -e`.
- [ ] I have made corresponding changes to the documentation.
- [ ] 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] RaigorJiang commented on a diff in pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on code in PR #21722:
URL: https://github.com/apache/shardingsphere/pull/21722#discussion_r1003215184
##########
proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java:
##########
@@ -84,7 +86,12 @@ private String getFirstDatabaseName() {
if (databaseNames.isEmpty()) {
throw new NoDatabaseSelectedException();
}
- Optional<String> result = databaseNames.stream().filter(each -> ProxyContext.getInstance().getDatabase(each).containsDataSource()).findFirst();
+ AuthorityRule authorityRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(
+ AuthorityRule.class);
+ Optional<ShardingSpherePrivileges> privileges = authorityRule.findPrivileges(connectionSession.getGrantee());
+ Optional<String> result = privileges.isPresent() ? databaseNames.stream().filter(each -> privileges.get().hasPrivileges(each)
Review Comment:
Hi @wallacezhou ,
Welcome, your PR provides a working solution, but please don't do complicated logical operations in the ternary operator, can you extract the judgment condition as a variable?
--
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] codecov-commenter commented on pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #21722:
URL: https://github.com/apache/shardingsphere/pull/21722#issuecomment-1289466465
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/21722?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#21722](https://codecov.io/gh/apache/shardingsphere/pull/21722?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d3f6390) into [master](https://codecov.io/gh/apache/shardingsphere/commit/33fcb8b43b67130c166e96128e0fdee2d2296e5d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (33fcb8b) will **decrease** coverage by `0.01%`.
> The diff coverage is `3.84%`.
```diff
@@ Coverage Diff @@
## master #21722 +/- ##
============================================
- Coverage 61.04% 61.02% -0.02%
+ Complexity 2501 2500 -1
============================================
Files 4112 4112
Lines 57408 57422 +14
Branches 9703 9705 +2
============================================
- Hits 35043 35041 -2
- Misses 19452 19468 +16
Partials 2913 2913
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/21722?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ore/ReadwriteSplittingDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9kaXN0c3FsL3BhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmVhZHdyaXRlc3BsaXR0aW5nL2Rpc3RzcWwvcGFyc2VyL2NvcmUvUmVhZHdyaXRlU3BsaXR0aW5nRGlzdFNRTFN0YXRlbWVudFZpc2l0b3IuamF2YQ==) | `41.02% <0.00%> (-3.42%)` | :arrow_down: |
| [.../ShowReadwriteSplittingReadResourcesStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9kaXN0c3FsL3N0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmVhZHdyaXRlc3BsaXR0aW5nL2Rpc3RzcWwvcGFyc2VyL3N0YXRlbWVudC9TaG93UmVhZHdyaXRlU3BsaXR0aW5nUmVhZFJlc291cmNlc1N0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...t/status/SetReadwriteSplittingStatusStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvcmVhZHdyaXRlLXNwbGl0dGluZy9kaXN0c3FsL3N0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmVhZHdyaXRlc3BsaXR0aW5nL2Rpc3RzcWwvcGFyc2VyL3N0YXRlbWVudC9zdGF0dXMvU2V0UmVhZHdyaXRlU3BsaXR0aW5nU3RhdHVzU3RhdGVtZW50LmphdmE=) | `0.00% <ø> (ø)` | |
| [...ndler/data/impl/UnicastDatabaseBackendHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2RhdGEvaW1wbC9VbmljYXN0RGF0YWJhc2VCYWNrZW5kSGFuZGxlci5qYXZh) | `18.18% <0.00%> (-2.51%)` | :arrow_down: |
| [...le/ShowReadwriteSplittingReadResourcesHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL3F1ZXJ5YWJsZS9TaG93UmVhZHdyaXRlU3BsaXR0aW5nUmVhZFJlc291cmNlc0hhbmRsZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [.../updatable/SetReadwriteSplittingStatusHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL3VwZGF0YWJsZS9TZXRSZWFkd3JpdGVTcGxpdHRpbmdTdGF0dXNIYW5kbGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...eterized/jaxb/cases/domain/SQLParserTestCases.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9wYXJzZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3Rlc3Qvc3FsL3BhcnNlci9wYXJhbWV0ZXJpemVkL2pheGIvY2FzZXMvZG9tYWluL1NRTFBhcnNlclRlc3RDYXNlcy5qYXZh) | `99.31% <100.00%> (ø)` | |
| [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2hpbnQvZW51bXMvSGludFNvdXJjZVR5cGUuamF2YQ==) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
| [...e/driver/jdbc/core/statement/StatementManager.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-amRiYy9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kcml2ZXIvamRiYy9jb3JlL3N0YXRlbWVudC9TdGF0ZW1lbnRNYW5hZ2VyLmphdmE=) | `94.44% <0.00%> (ø)` | |
| [.../proxy/backend/communication/ProxySQLExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9jb21tdW5pY2F0aW9uL1Byb3h5U1FMRXhlY3V0b3IuamF2YQ==) | `34.32% <0.00%> (ø)` | |
| ... and [8 more](https://codecov.io/gh/apache/shardingsphere/pull/21722/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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] RaigorJiang commented on pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on PR #21722:
URL: https://github.com/apache/shardingsphere/pull/21722#issuecomment-1294349423
@wallacezhou
Thank you!
In this operation, stream is used more than before, which may bring performance problems, I will do some tests.
--
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] wallacezhou commented on a diff in pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
Posted by GitBox <gi...@apache.org>.
wallacezhou commented on code in PR #21722:
URL: https://github.com/apache/shardingsphere/pull/21722#discussion_r1003940415
##########
proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java:
##########
@@ -84,7 +86,12 @@ private String getFirstDatabaseName() {
if (databaseNames.isEmpty()) {
throw new NoDatabaseSelectedException();
}
- Optional<String> result = databaseNames.stream().filter(each -> ProxyContext.getInstance().getDatabase(each).containsDataSource()).findFirst();
+ AuthorityRule authorityRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(
+ AuthorityRule.class);
+ Optional<ShardingSpherePrivileges> privileges = authorityRule.findPrivileges(connectionSession.getGrantee());
+ Optional<String> result = privileges.isPresent() ? databaseNames.stream().filter(each -> privileges.get().hasPrivileges(each)
Review Comment:
updated , please help to review 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] RaigorJiang merged pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615
Posted by GitBox <gi...@apache.org>.
RaigorJiang merged PR #21722:
URL: https://github.com/apache/shardingsphere/pull/21722
--
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