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/10/15 18:22:57 UTC

[GitHub] [shardingsphere] KnothHe commented on issue #21584: substr can not be used in insert

KnothHe commented on issue #21584:
URL: https://github.com/apache/shardingsphere/issues/21584#issuecomment-1279800877

   The reason i can find is sql parse engine's parse result SqlStatement. `org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement#sqlStatement`
   
   `sqlStatement = sqlParserEngine.parse(sql, true);`
   
   More precisely is `SQLStatement`'s `InsertStatement.values`'s `InsertValuesSegment.values`'s `FunctionSegment`'s parameters.
   
   <img width="1576" alt="image" src="https://user-images.githubusercontent.com/25814839/196001803-cbfa04e7-8903-4e05-8838-613ab0946d90.png">
   
   Some functions's parse result has no parameters, thus no second parameter pass to JDBC parameter execute.
   In my test, maybe all `customKeyword` has problems.
   I have test `SUBSTRING`, `SUBSTR`, `TRIM`, all of these has same exception.
   
   And I randomly test function `FORMAT`, that's work.
   <img width="1581" alt="image" src="https://user-images.githubusercontent.com/25814839/196001918-9019b19f-79b0-4db7-b3bb-e1dc82791f30.png">
   
   Currently I have no knowledge of ANTLR and can't understand how SqlParser works.
   
   


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