Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to run EXPLAIN query in SQL editor: Please check if the statement is correct #348

Closed
yidoa opened this issue Jan 10, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@yidoa
Copy link

yidoa commented Jan 10, 2022

数据库版本:MySQL57
平台版本:v0.11.0
部署方式:二进制部署
操作:
在 SQL editor 里面:
explain select * from abc;
报错:Please check if the statement is correct
image

@yidoa yidoa added the bug Something isn't working label Jan 10, 2022
@tianzhou
Copy link
Collaborator

We need to address it in both frontend and backend to whitelist EXPLAIN. @boojack PTAL

@xiaoluoboding
Copy link
Contributor

@tianzhou @boojack maybe we do not need to validate the SQL statement is correct or not. pass the statement to the back-end. At the front-end, we only validate the query is a SELECT statement or not.

@tianzhou
Copy link
Collaborator

@xiaoluoboding

For frontend, I think do a simple validation to check whether it's SELECT or EXPLAIN SELECT is sufficient.

@boojack
Copy link
Contributor

boojack commented Jan 10, 2022

@xiaoluoboding @tianzhou This failure is because of the frontend package node-sql-parser will throw an SyntaxError with statement explain select * from abc which is correct. And I think maybe using the simple regex is more efficient than node-sql-parser in this situation.

@xiaoluoboding
Copy link
Contributor

@boojack just remove isValidStatement function, will be fine. I use the noe-sql-parser to parse the SQL statement, in case we want to use the more info of the query. If we really does not need it. We can remove it.

@tianzhou tianzhou changed the title mysql5.7环境 在 SQL editor 里面 执行explain 时报错:Please check if the statement is correct Fails to run EXPLAIN query in SQL editor: Please check if the statement is correct Jan 10, 2022
@xiaoluoboding
Copy link
Contributor

Already fixed in the latest version v0.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants