MyCATApache / Mycat2

MySQL Proxy using Java NIO based on Sharding SQL,Calcite ,simple and fast
http://www.mycat.org.cn/
GNU General Public License v3.0
1.71k stars 478 forks source link

mysql 语法 use index 支持 force index 不支持 #695

Open GiftLee opened 2 years ago

GiftLee commented 2 years ago

sql 如下

select * from table1 FORCE index (index1)

会报如下错误:

org.jkiss.dbeaver.model.sql.DBSQLException: SQL 错误 [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `table1`
LIMIT 200
OFFSET 0' at line 2

    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133)

    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:513)

    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$0(SQLQueryJob.java:444)

    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:171)

    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:431)

    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:816)

    at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:3494)

    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:118)

    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:171)

    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:116)

    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:4823)

    at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
junwen12221 commented 2 years ago

http://dl.mycat.org.cn/2.0/1.22-release/mycat2-1.22-release-jar-with-dependencies-2022-5-11.jar

hanchikang commented 1 year ago

http://dl.mycat.org.cn/2.0/1.22-release/mycat2-1.22-release-jar-with-dependencies-2022-5-11.jar

生成的sql,没有在索引名称前后加 `` ,导致错误:select * from table1 FORCE index (table1.index1`) mycat生成的sql: select * from table1 FORCE index (table1.index1)