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/05/17 15:26:01 UTC

[GitHub] [shardingsphere] cheese8 opened a new pull request, #17756: Fix the sharding exception on OnDuplicatedKey

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

   Fixes #17198.
   
   Changes proposed in this pull request:
   
   


-- 
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 #17756: Fix the sharding table skip OnDuplicatedKeyUpdate

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


-- 
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 #17756: Fix the sharding table skip OnDuplicatedKeyUpdate

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


##########
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java:
##########
@@ -217,11 +219,25 @@ public void extractTablesFromInsert(final InsertStatement insertStatement) {
                 extractTablesFromExpression(each);
             }
         }
+        InsertStatementHandler.getOnDuplicateKeyColumnsSegment(insertStatement).ifPresent(each -> extractTablesFromAssignmentItems(each.getColumns()));
         if (insertStatement.getInsertSelect().isPresent()) {
             extractTablesFromSelect(insertStatement.getInsertSelect().get().getSelect());
         }
     }
     
+    private void extractTablesFromAssignmentItems(final Collection<AssignmentSegment> assignmentItems) {
+        assignmentItems.stream().forEach(each -> extractTablesFromColumnSegments(each.getColumns()));

Review Comment:
   Please remove stream api here, it has performance lost.



-- 
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 #17756: Fix the sharding table skip OnDuplicatedKeyUpdate

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


##########
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java:
##########
@@ -217,11 +219,23 @@ public void extractTablesFromInsert(final InsertStatement insertStatement) {
                 extractTablesFromExpression(each);
             }
         }
+        if (insertStatement instanceof MySQLInsertStatement) {
+            ((MySQLInsertStatement) insertStatement).getOnDuplicateKeyColumns().ifPresent(each -> extractTablesFromAssignmentItems(each.getColumns()));
+        }
         if (insertStatement.getInsertSelect().isPresent()) {
             extractTablesFromSelect(insertStatement.getInsertSelect().get().getSelect());
         }
     }
     
+    private void extractTablesFromAssignmentItems(final Collection<AssignmentSegment> assignmentItems) {
+        assignmentItems.stream().flatMap(each -> each.getColumns().stream()).forEach(each -> {

Review Comment:
   Please use foreach instead of stream api.



##########
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java:
##########
@@ -217,11 +219,23 @@ public void extractTablesFromInsert(final InsertStatement insertStatement) {
                 extractTablesFromExpression(each);
             }
         }
+        if (insertStatement instanceof MySQLInsertStatement) {

Review Comment:
   @cheese8 Please use InsertStatementHandler to handle this logic.



-- 
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] cheese8 commented on a diff in pull request #17756: Fix the sharding table skip OnDuplicatedKeyUpdate

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


##########
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java:
##########
@@ -217,11 +219,23 @@ public void extractTablesFromInsert(final InsertStatement insertStatement) {
                 extractTablesFromExpression(each);
             }
         }
+        if (insertStatement instanceof MySQLInsertStatement) {

Review Comment:
   OK, I see



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