Request to add words RANK and FUNCTION as MySQL unreserved Word in mysql sql parser module
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
5.0.0.RC1
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
Expected behavior
SQL with column name RANK and FUNCTION can run without issue
Actual behavior
ss-proxy reports unsupported sql
Reason analyze (If you can)
The SQL contains column names like RANK and FUNCTION which were defined as reserved words in sql-parser-mysql module
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Create a table with column name rank and function Then run sql over ss-proxy to query those columns
Example codes for reproduce this issue (such as a github link).
Hi @zhaopinglu
- What if you use
FUNCTIONto execute SQL? - Keyworkd of MySQL tell me
FUNCTION (R)is reserved in 8.x
Hi @tristaZero In my subquery case add '``' will report NPE.
select schema from (select * from table where id = 4) a
It seems a bug cause column name not trim '``'

My version is the master version. Thx for investigating this
@chana71 Thanks for your feedback.
- What your query SQL? The following one?
select schema from (select * from table where id = 4) a
- What if you do not use subquery? Could you give it a test?
@tristaZero
- Complete SQL looks like this. Please check
SELECT SCHEMA_SIZE, A.CHECKTIME, A.`SCHEMA`
FROM (
SELECT SCHEMA_SIZE, CHECKTIME, `SCHEMA`
FROM MYSQL_SCHEMA_SIZE
WHERE DBID IN (1) AND `SCHEMA` IN ('test')) A
RIGHT JOIN (
SELECT MAX(CHECKTIME) CHECKTIME, `SCHEMA`
FROM MYSQL_SCHEMA_SIZE
WHERE DBID IN (1) AND `SCHEMA` IN ('test')
GROUP BY `SCHEMA`) B ON A.CHECKTIME = B.CHECKTIME AND A.`SCHEMA` = B.`SCHEMA`
- If not with a subquery,e.g.
SELECT SCHEMA_SIZE,SCHEMAFROM SCHEMA_SIZE;, It works.
@chana71 So could we conclude that the possible issue is subquery cannot support keyword of MySQL?
Plus, what if there is no keyword in subquery?
@jingshanglu Could you check whether the SQL above is supported on our master branch?
@chana71 So could we conclude that the possible issue is
subquerycannot supportkeywordofMySQL? Plus, what if there is nokeywordinsubquery?@jingshanglu Could you check whether the SQL above is supported on our master branch?
Statement is right, rewrite is wrong.
@jingshanglu You mean we get the wrong rewritten SQL? Which part of the rewritten SQL is unexpected?
@chana71 #7476 The pr maybe fix it, when it is merged, you can try the master branch.