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
feature request: mysql: multiple statement execution support #24721
Comments
similar error was in mssql if complex query, but I can't reproduce it ... |
try
|
In mysql client
|
I can reproduce this on CleanShot.2022-02-13.at.03.59.54.mp4of course this isn't very stateful. I also wonder if template variables cannot resolve these situations more often than not. Also, I think this is a problem with the request, not the response. I get a 400 error, and when I tail the MySQL logs I don't see the query making it into the DB. 🤷 |
Has anyone got a solution yet? :( |
The underlying issue is that MySQL's Multiple Statement Execution Support is not enabled by default. A minimal example to reproduce the issue: https://github.com/exul/xorm-multi-statements Relevant connection string: https://github.com/grafana/grafana/blob/main/pkg/tsdb/mysql/mysql.go#L100 (there is a similar connection string here: https://github.com/grafana/grafana/blob/main/pkg/services/sqlstore/sqlstore.go#L284 but that one isn't used when adding a data source, so probably no need to update it). Steps in the code when a MySQL Query is executed from a dashboard using MySQL as a data source (leaving this here as a reminder for myself and hoping it helps others too):
I don't know the Grafana code base well enough to judge how a fix for this should look like. Is it ok to set Video from a successful execution grafana-multi-statements.mp4 |
After some further investigation the best way to deal with this seems to be to add a new config flag to the MySQL data source (similar to |
summary by @gabor the grafana mysql plugin currently only support running a single sql statement. this does not allow certain use-cases, like using user-defined variables. to allow it, we need to add something to the mysql connection string, question is, should we always add it, add a config-checkbox for it, etc.
What happened:
I use mysql data source. When I need to define a variable in the sql, it prompts a syntax error. If it is normal to execute directly in the mysql client, my sql as follows
What you expected to happen:
Can output the result normally as in mysql client
How to reproduce it (as minimally and precisely as possible):
Refer to my sql above. In fact, I want to calculate the monthly profit accumulation. In mysql, you need to use set to define a variable before using it.
Anything else we need to know?:
Environment:
The text was updated successfully, but these errors were encountered: