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/11/08 05:05:54 UTC

[GitHub] [shardingsphere] totalo opened a new pull request, #22004: Do not throw an exception if the statement contains `if not exists`

totalo opened a new pull request, #22004:
URL: https://github.com/apache/shardingsphere/pull/22004

   
   
   ---
   
   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`.
   - [x] I have made corresponding changes to the documentation.
   - [x] 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] totalo commented on a diff in pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
totalo commented on code in PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#discussion_r1016193336


##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -82,9 +83,14 @@ private void route0(final RouteContext routeContext, final SingleTableRule rule)
         if (sqlStatement instanceof CreateTableStatement) {
             String dataSourceName = rule.assignNewDataSourceName();
             QualifiedTable table = singleTableNames.iterator().next();
-            if (isTableExists(table, rule)) {
+            boolean tableExists = isTableExists(table, rule);
+            boolean ifNotExists = CreateTableStatementHandler.ifNotExists((CreateTableStatement) sqlStatement);
+            if (tableExists && !ifNotExists) {

Review Comment:
   Got 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] strongduanmu merged pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004


-- 
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] tuichenchuxin commented on a diff in pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on code in PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#discussion_r1016190734


##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -82,9 +83,14 @@ private void route0(final RouteContext routeContext, final SingleTableRule rule)
         if (sqlStatement instanceof CreateTableStatement) {
             String dataSourceName = rule.assignNewDataSourceName();
             QualifiedTable table = singleTableNames.iterator().next();
-            if (isTableExists(table, rule)) {
+            boolean tableExists = isTableExists(table, rule);
+            boolean ifNotExists = CreateTableStatementHandler.ifNotExists((CreateTableStatement) sqlStatement);
+            if (tableExists && !ifNotExists) {
                 throw new TableExistsException(table.getTableName());
             }
+            if (tableExists) {
+                return;

Review Comment:
   just return may cause create table if not exists actually execute. And if ds_0 has this table. It may execute on ds_1 ,Then we'll get two same name single table.



-- 
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] strongduanmu commented on a diff in pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#discussion_r1016176802


##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -82,9 +83,14 @@ private void route0(final RouteContext routeContext, final SingleTableRule rule)
         if (sqlStatement instanceof CreateTableStatement) {
             String dataSourceName = rule.assignNewDataSourceName();
             QualifiedTable table = singleTableNames.iterator().next();
-            if (isTableExists(table, rule)) {
+            boolean tableExists = isTableExists(table, rule);
+            boolean ifNotExists = CreateTableStatementHandler.ifNotExists((CreateTableStatement) sqlStatement);
+            if (tableExists && !ifNotExists) {

Review Comment:
   Can you move isTableExists to next condition?



-- 
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] totalo commented on a diff in pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
totalo commented on code in PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#discussion_r1016494841


##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -82,9 +83,14 @@ private void route0(final RouteContext routeContext, final SingleTableRule rule)
         if (sqlStatement instanceof CreateTableStatement) {
             String dataSourceName = rule.assignNewDataSourceName();
             QualifiedTable table = singleTableNames.iterator().next();
-            if (isTableExists(table, rule)) {
+            boolean tableExists = isTableExists(table, rule);
+            boolean ifNotExists = CreateTableStatementHandler.ifNotExists((CreateTableStatement) sqlStatement);
+            if (tableExists && !ifNotExists) {
                 throw new TableExistsException(table.getTableName());
             }
+            if (tableExists) {
+                return;

Review Comment:
   Got 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] codecov-commenter commented on pull request #22004: Do not throw an exception if the statement contains `if not exists`

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#issuecomment-1306690619

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/22004?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 [#22004](https://codecov.io/gh/apache/shardingsphere/pull/22004?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2cc0bfc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/5b235c0513465528c8e17dfc6a8dd59c6f4249bc?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5b235c0) will **decrease** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #22004      +/-   ##
   ============================================
   - Coverage     60.88%   60.87%   -0.01%     
   - Complexity     2467     2469       +2     
   ============================================
     Files          4109     4109              
     Lines         57242    57246       +4     
     Branches       9688     9689       +1     
   ============================================
   + Hits          34850    34851       +1     
   - Misses        19450    19453       +3     
     Partials       2942     2942              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/22004?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...e/route/engine/SingleTableStandardRouteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/22004/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-a2VybmVsL3NpbmdsZS10YWJsZS9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaW5nbGV0YWJsZS9yb3V0ZS9lbmdpbmUvU2luZ2xlVGFibGVTdGFuZGFyZFJvdXRlRW5naW5lLmphdmE=) | `61.11% <100.00%> (+4.86%)` | :arrow_up: |
   | [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/22004/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: |
   
   :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