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/08/09 09:17:46 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue #11722: Select statement parse error when include current_date function

strongduanmu opened a new issue #11722:
URL: https://github.com/apache/shardingsphere/issues/11722


   ### Which version of ShardingSphere did you use?
   
   master branch
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   execute select statement success
   
   ### Actual behavior
   
   throw exception——`line 1:56 no viable alternative at input '=current_date('`
   
   ### Reason analyze (If you can)
   
   ```g4
   regularFunction
       : completeRegularFunction
       | shorthandRegularFunction
       ;
       
   shorthandRegularFunction
       : CURRENT_DATE | CURRENT_TIME (LP_ NUMBER_? RP_)? | CURRENT_TIMESTAMP | LAST_DAY | LOCALTIME | LOCALTIMESTAMP
       ;
       
   completeRegularFunction
       : regularFunctionName (LP_ (expr (COMMA_ expr)* | ASTERISK_)? RP_)
       ;
       
   regularFunctionName
       : IF | LOCALTIME | LOCALTIMESTAMP | REPLACE | INTERVAL | MOD
       | DATABASE | SCHEMA | LEFT | RIGHT | DATE | DAY | GEOMETRYCOLLECTION
       | LINESTRING | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | POINT | POLYGON
       | TIME | TIMESTAMP | TIMESTAMP_ADD | TIMESTAMP_DIFF | DATE | CURRENT_TIMESTAMP | identifier
       ;
   ```
   
   From the following g4 file, we can see that the `current_date()` function is ambiguous. Due to the priority during parsing, the shorthandRegularFunction rule will be used for parsing, but the shorthandRegularFunction rule cannot parse the parentheses.
   
   We should define a parenthesized function with the same name in the completeRegularFunction rule to avoid parsing problems caused by priority.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### 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.

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 closed issue #11722: Select statement parse error when include current_date function

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


   


-- 
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 #11722: Select statement parse error when include current_date function

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


   This is mysql official doc for built-in function——https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html.


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