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/02/20 02:32:33 UTC

[GitHub] [shardingsphere] sunday20111107 opened a new issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

sunday20111107 opened a new issue #9446:
URL: https://github.com/apache/shardingsphere/issues/9446


   Caused by: java.lang.ClassCastException: org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment
   at org.apache.shardingsphere.infra.binder.segment.insert.values.OnDuplicateUpdateContext.getValue(OnDuplicateUpdateContext.java:87) ~[shardingsphere-infra-binder-5.0.0-alpha.jar:5.0.0-alpha]
   at org.apache.shardingsphere.encrypt.rewrite.parameter.impl.EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.lambda$rewrite$0(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java:59) ~[shardingsphere-encrypt-rewrite-5.0.0-alpha.jar:5.0.0-alpha]
   at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_73]
   at org.apache.shardingsphere.encrypt.rewrite.parameter.impl.EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.rewrite(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java:58) ~[shardingsphere-encrypt-rewrite-5.0.0-alpha.jar:5.0.0-alpha]
   at
   
   ### Which version of ShardingSphere did you use?
   shardingsphere-jdbc:5.0.0-alpha
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   
   ### Actual behavior
   Caused by: java.lang.ClassCastException: org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment
   ### Reason analyze (If you can)
   1. as follows sql, when i config 'name' use ENCRYPT, my sql like 'ON DUPLICATE KEY UPDATE name=VALUES(name)' will throw As above exception, but i change the sql like this 'ON DUPLICATE KEY UPDATE name=?', ENCRYPT is work good.
   2. i trace the code, find ENCRYPT field will use OnDuplicateUpdateContext 
       public Object getValue(final int index) {
           ExpressionSegment valueExpression = valueExpressions.get(index);
           return valueExpression instanceof ParameterMarkerExpressionSegment ? parameters.get(getParameterIndex(valueExpression)) : ((LiteralExpressionSegment) valueExpression).getLiterals();
       }
   3. when name=VALUES(name) valueExpression will is ExpressionProjectionSegment,  is not LiteralExpressionSegment so will throw as above exception.
   4. when name=? valueExpression will is ParameterMarkerExpressionSegment ,  is work good.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   INSERT INTO anchor_info (id, source, anchorId, name, avatar, status, createTime, updateTime) VALUES
   (#{id,jdbcType=BIGINT}, #{source,jdbcType=VARCHAR}, #{anchorId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
   #{avatar,jdbcType=VARCHAR},#{status,jdbcType=TINYINT}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
   ON DUPLICATE KEY UPDATE name=VALUES(name),
   updateTime=VALUES(updateTime);
   
   rules:
   
   !ENCRYPT
   tables:
   anchor_info:
   columns:
   name:
   cipherColumn: name
   encryptorName: aes
   encryptors:
   aes:
   type: AES
   props:
   aes-key-value: abcdisjckel14003c2f8ea32cc1d59e5
   
   ### Example codes for reproduce this issue (such as a github link).
   


----------------------------------------------------------------
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] cheese8 commented on issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   I'll try to fix it later, please assign it to me. @strongduanmu 


-- 
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 #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   @cheese8 Welcome, I will assign this issue to you.


-- 
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 #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   @cheese8 Welcome, I will assign this issue to you.


-- 
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 #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   Hi @sunday20111107 
   Thanks for feedback.
   
   @jingshanglu 
   Could you check this case? It looks like an issue of parsing.


----------------------------------------------------------------
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] jingshanglu commented on issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   @sunday20111107 @tristaZero It's a bug about binder, new version will fix 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] cheese8 commented on issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   I'll try to fix it later, please assign it to me. @strongduanmu 


-- 
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 closed issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   


-- 
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 #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   @cheese8 Welcome, I will assign this issue to you.


-- 
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 issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   I'll try to fix it later, please assign it to me. @strongduanmu 


-- 
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 issue #9446: Encrypt on duplicate key update name=VALUES(name) will throws ExpressionProjectionSegment canot be cast to LiteralExpressionSegment

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


   Has been Fixed.


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