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 2020/10/28 15:37:09 UTC
[GitHub] [shardingsphere] strongduanmu opened a new pull request #7949: fix some sql parse exception and ddl, dcl route logic
strongduanmu opened a new pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949
Fixes #7918.
Changes proposed in this pull request:
- fix `start slave` and `stop slave` statements parse error
- fix `set character` statement parse error
- fix ddl and dcl statement route wrong result when table without sharding rule
----------------------------------------------------------------
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 #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#issuecomment-718303525
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=h1) Report
> Merging [#7949](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/ead87d484543d56a7ceb70ad744a3980baa4f59e?el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `60.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/7949/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7949 +/- ##
============================================
+ Coverage 74.71% 74.72% +0.01%
Complexity 537 537
============================================
Files 1444 1444
Lines 22757 22757
Branches 4064 4062 -2
============================================
+ Hits 17002 17005 +3
+ Misses 4655 4654 -1
+ Partials 1100 1098 -2
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...l/parser/engine/executor/RDLSQLParserExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcmRsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1yZGwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmRsL3BhcnNlci9lbmdpbmUvZXhlY3V0b3IvUkRMU1FMUGFyc2VyRXhlY3V0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...gsphere/sql/parser/api/parser/SQLParserEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9hcGkvcGFyc2VyL1NRTFBhcnNlckVuZ2luZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [.../route/engine/type/ShardingRouteEngineFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL3JvdXRlL2VuZ2luZS90eXBlL1NoYXJkaW5nUm91dGVFbmdpbmVGYWN0b3J5LmphdmE=) | `77.55% <75.00%> (+6.12%)` | `0.00 <0.00> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?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/7949?src=pr&el=footer). Last update [ead87d4...de4eff4](https://codecov.io/gh/apache/shardingsphere/pull/7949?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 #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949
----------------------------------------------------------------
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] strongduanmu commented on a change in pull request #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#discussion_r513968592
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/api/parser/SQLParserEngine.java
##########
@@ -64,7 +64,7 @@ public ParseTree parse(final String sql, final boolean useCache) {
private ParseTree parse(final String sql) {
ParseASTNode result = twoPhaseParse(sql);
if (result.getRootNode() instanceof ErrorNode) {
- throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql));
+ throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql).replaceAll("%", "%%"));
Review comment:
> Why is `replaceAll("%", "%%")` needed?
@tristaZero When user executes a SQL containing `%` and the SQL parsing is abnormal, for example: `SET PASSWORD FOR'bob'@'%.example.org' = PASSWORD('auth_string');`. Since the `%` symbol is a reserved character, an `UnknownFormatConversionException` will occur when the `String.format()` method is executed.
In order to allow users to see the real prompt, such as: `Unsupported SQL of xxxStatement`, we need to escape the `%` symbol, that is, replace it with the `%%` symbol.
----------------------------------------------------------------
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 #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#discussion_r513923047
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
##########
@@ -140,10 +131,16 @@ private static ShardingRouteEngine getDALRoutingEngine(final ShardingRule shardi
return new ShardingDataSourceGroupBroadcastRoutingEngine();
}
- private static ShardingRouteEngine getDCLRoutingEngine(final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
- return isDCLForSingleTable(sqlStatementContext)
- ? new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext)
- : new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());
+ private static ShardingRouteEngine getDCLRoutingEngine(final ShardingRule shardingRule, final Map<String, Collection<String>> unconfiguredSchemaMetaDataMap,
+ final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
+ if (isDCLForSingleTable(sqlStatementContext)) {
+ Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
+ return !shardingRule.tableRuleExists(tableNames)
+ ? new ShardingUnconfiguredTablesRoutingEngine(tableNames, unconfiguredSchemaMetaDataMap, sqlStatementContext.getSqlStatement())
+ : new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext);
+ } else {
+ return new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());
Review comment:
Could you give a SQL example involving `ShardingInstanceBroadcastRoutingEngine`
##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/api/parser/SQLParserEngine.java
##########
@@ -64,7 +64,7 @@ public ParseTree parse(final String sql, final boolean useCache) {
private ParseTree parse(final String sql) {
ParseASTNode result = twoPhaseParse(sql);
if (result.getRootNode() instanceof ErrorNode) {
- throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql));
+ throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql).replaceAll("%", "%%"));
Review comment:
Why is `replaceAll("%", "%%")` needed?
----------------------------------------------------------------
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] strongduanmu commented on a change in pull request #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#discussion_r513970555
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
##########
@@ -140,10 +131,16 @@ private static ShardingRouteEngine getDALRoutingEngine(final ShardingRule shardi
return new ShardingDataSourceGroupBroadcastRoutingEngine();
}
- private static ShardingRouteEngine getDCLRoutingEngine(final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
- return isDCLForSingleTable(sqlStatementContext)
- ? new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext)
- : new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());
+ private static ShardingRouteEngine getDCLRoutingEngine(final ShardingRule shardingRule, final Map<String, Collection<String>> unconfiguredSchemaMetaDataMap,
+ final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
+ if (isDCLForSingleTable(sqlStatementContext)) {
+ Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
+ return !shardingRule.tableRuleExists(tableNames)
+ ? new ShardingUnconfiguredTablesRoutingEngine(tableNames, unconfiguredSchemaMetaDataMap, sqlStatementContext.getSqlStatement())
+ : new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext);
+ } else {
+ return new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());
Review comment:
> ShardingInstanceBroadcastRoutingEngine
@tristaZero If user executes a DCL statement that does not contain tables or contains multiple tables, `ShardingInstanceBroadcastRoutingEngine` will be used at this time. For example: `SET PASSWORD FOR'bob'@'%.example.org' ='auth_string'`;
----------------------------------------------------------------
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 #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#issuecomment-718303525
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=h1) Report
> Merging [#7949](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/b0389897658cc11b53eb845474aa9dffb6b14d8b?el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `60.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/7949/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7949 +/- ##
============================================
+ Coverage 74.67% 74.71% +0.04%
Complexity 538 538
============================================
Files 1447 1447
Lines 22769 22771 +2
Branches 4062 4060 -2
============================================
+ Hits 17002 17013 +11
+ Misses 4669 4661 -8
+ Partials 1098 1097 -1
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...here/sql/parser/exception/SQLParsingException.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9leGNlcHRpb24vU1FMUGFyc2luZ0V4Y2VwdGlvbi5qYXZh) | `50.00% <0.00%> (-50.00%)` | `0.00 <0.00> (ø)` | |
| [.../route/engine/type/ShardingRouteEngineFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL3JvdXRlL2VuZ2luZS90eXBlL1NoYXJkaW5nUm91dGVFbmdpbmVGYWN0b3J5LmphdmE=) | `77.55% <75.00%> (+6.12%)` | `0.00 <0.00> (ø)` | |
| [...gsphere/proxy/config/ProxyConfigurationLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9wcm94eS9jb25maWcvUHJveHlDb25maWd1cmF0aW9uTG9hZGVyLmphdmE=) | `50.00% <0.00%> (+2.94%)` | `0.00% <0.00%> (ø%)` | |
| [...re/scaling/core/schedule/ScalingTaskScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9zY2hlZHVsZS9TY2FsaW5nVGFza1NjaGVkdWxlci5qYXZh) | `74.00% <0.00%> (+10.00%)` | `0.00% <0.00%> (ø%)` | |
| [...e/execute/engine/ShardingScalingExecuteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9leGVjdXRlL2VuZ2luZS9TaGFyZGluZ1NjYWxpbmdFeGVjdXRlRW5naW5lLmphdmE=) | `100.00% <0.00%> (+11.11%)` | `0.00% <0.00%> (ø%)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?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/7949?src=pr&el=footer). Last update [b038989...4b26ba3](https://codecov.io/gh/apache/shardingsphere/pull/7949?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 commented on pull request #7949: fix some sql parse exception and ddl, dcl route logic
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#issuecomment-718303525
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=h1) Report
> Merging [#7949](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/ead87d484543d56a7ceb70ad744a3980baa4f59e?el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `60.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/7949/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7949 +/- ##
============================================
+ Coverage 74.71% 74.72% +0.01%
Complexity 537 537
============================================
Files 1444 1444
Lines 22757 22757
Branches 4064 4062 -2
============================================
+ Hits 17002 17005 +3
+ Misses 4655 4654 -1
+ Partials 1100 1098 -2
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/7949?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...l/parser/engine/executor/RDLSQLParserExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcmRsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1yZGwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmRsL3BhcnNlci9lbmdpbmUvZXhlY3V0b3IvUkRMU1FMUGFyc2VyRXhlY3V0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...gsphere/sql/parser/api/parser/SQLParserEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9hcGkvcGFyc2VyL1NRTFBhcnNlckVuZ2luZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [.../route/engine/type/ShardingRouteEngineFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7949/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL3JvdXRlL2VuZ2luZS90eXBlL1NoYXJkaW5nUm91dGVFbmdpbmVGYWN0b3J5LmphdmE=) | `77.55% <75.00%> (+6.12%)` | `0.00 <0.00> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7949?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/7949?src=pr&el=footer). Last update [ead87d4...de4eff4](https://codecov.io/gh/apache/shardingsphere/pull/7949?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