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

   Fixes #30966 
   
   Changes proposed in this pull request:
     -
   This pull request modify the parsing of the following sql:
   
   ```sql
   SELECT * FROM t1 USE INDEX (i1) IGNORE INDEX (i2) USE INDEX (i2);
   
   SELECT * FROM t1
     USE INDEX () IGNORE INDEX (i2) USE INDEX (i1) USE INDEX (i2);
   
   SELECT * FROM t1
      USE INDEX (i1,i2) IGNORE INDEX (i2);
   ```
   
   Syntax specifications in official documentation,index_list can be empty when 
using `IGNORE` or `FORCE`. So I modified the syntax of `indexHintList` and 
split the `indexHint` in DMLStatement.g4.
   
   ```sql
   tbl_name [[AS] alias] [index_hint_list]
   
   index_hint_list:
       index_hint [index_hint] ...
   
   index_hint:
       USE {INDEX|KEY}
         [FOR {JOIN|ORDER BY|GROUP BY}] ([index_list])
     | {IGNORE|FORCE} {INDEX|KEY}
         [FOR {JOIN|ORDER BY|GROUP BY}] (index_list)
   
   index_list:
       index_name [, index_name] ...
   ```
   
   see : [Index Hints](https://dev.mysql.com/doc/refman/8.0/en/index-hints.html)
   
   And other  two sql involves MySQL keywords `column`, cannot be executed in 
MySQL. If replace `column` with other non-keywords, ShardingSphere can parse 
right.
   
   ```sql
   SELECT * FROM ref_table,other_table
     WHERE ref_table.key_column=other_table.column;
   
   SELECT * FROM ref_table,other_table
     WHERE ref_table.key_column_part1=other_table.column
     AND ref_table.key_column_part2=1;
   ```
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following 
options:
   - [ ] My code follows the [code of 
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) 
of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the 
pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to