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/09/07 12:07:35 UTC

[GitHub] [shardingsphere] CodingBingo opened a new issue #12272: Master branch, Insert on duplicate key update error!

CodingBingo opened a new issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272


   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   Current master branch.
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC 
   
   ### Expected behavior
   when i user shardingSephere-jdbc, this sql will occur error.
   ```
   insert into social_count (image, video, feeds, organization,createTime,updateTime) values (  ?, ?, ?, ?, now(), now()) on duplicate key update image = image + ?,video = video + ?,feeds = feeds + ?,updateTime = now()
   ```
   social_count is single table in single database.
   
   error:
   ```
   bad SQL grammar []; nested exception is java.sql.SQLException: No value specified for parameter 6
   ```
   
   ### Reason analyze (If you can)
   In code of **org.apache.shardingsphere.infra.binder.segment.insert.values.OnDuplicateUpdateContext**, we have a function
   ```
        private int calculateParameterCount(final Collection<ExpressionSegment> assignments) {
           int result = 0;
           for (ExpressionSegment each : assignments) {
               if (each instanceof ParameterMarkerExpressionSegment) {
                   result++;
               } 
           }
           return result;
       }
   ```
   when i step into this function, each of element in assignments is an instanceof **BinaryOperationExpression**, not **ParameterMarkerExpressionSegment**, so it will course `parameterCount` always be 0.
   
   ### Example codes for reproduce this issue (such as a github link).
   To fix this bug, i modified the code as below.
   ```
   private int calculateParameterCount(final Collection<ExpressionSegment> assignments) {
           int result = 0;
           for (ExpressionSegment each : assignments) {
               if (each instanceof ParameterMarkerExpressionSegment) {
                   result++;
               } else if (each instanceof BinaryOperationExpression) {
                   if (((BinaryOperationExpression) each).getRight() instanceof ParameterMarkerExpressionSegment) {
                       result++;
                   }
               }
           }
           return result;
       }
   ```
   
   


-- 
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] tristaZero commented on issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272#issuecomment-914904924


   So @strongduanmu It's an existing bug, right?
   Hi @CodingBingo thanks. If so, would you like to try to fix this one?


-- 
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 issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272#issuecomment-915087510


   @CodingBingo You are welcome to submit a PR.


-- 
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] CodingBingo commented on issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
CodingBingo commented on issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272#issuecomment-915081926


   > So @strongduanmu It's an existing bug, right?
   > Hi @CodingBingo thanks. If so, would you like to try to fix this one?
   
   I will try to fix bug and make a pull request, thanks for your guys reply.


-- 
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 closed issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272


   


-- 
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 issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272#issuecomment-914360475


   Hi @CodingBingo 
   Thanks for your report, let's wait for @strongduanmu to have a look.


-- 
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 issue #12272: Master branch, Insert on duplicate key update error!

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #12272:
URL: https://github.com/apache/shardingsphere/issues/12272#issuecomment-914956648


   @tristaZero Yes, it's an bug, and this issue is similar  to #7998.


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