Mysql: Multiple queries in 1 statement

Created on 13 Mar 2018  路  9Comments  路  Source: go-sql-driver/mysql

I just want to inform that multiple queries doesn't work as per this example: https://golang.org/pkg/database/sql/#example_DB_Query_multipleResultSets

I also tried setting the multiStatements setting when opening the database.

Most helpful comment

I said exactly. There are no hint from your comment, it's just a noise.
multi statement is tested, and confirmed to work well.

So complete reproducible example is required. "Not works", "Works" is just a waste of time.

All 9 comments

What "doesn't work" mean?
What did you try and what did you seen, exactly?

What I saw was mysql complaining that the multistatement sql statement was invalid.
When I separated the combined sql into separate statements it worked.

I said exactly. There are no hint from your comment, it's just a noise.
multi statement is tested, and confirmed to work well.

So complete reproducible example is required. "Not works", "Works" is just a waste of time.

Pull request adding test case demonstrates your issue is also welcome.

Or fix this test case, which test multi statement.

Thank you for test case.
And I found binary protocol (used by prepared statement) doesn't support mutli resultset.
You need to use interpolateParams=true to use text protocol, at your own risk.

gotcha, thx

@methane I know this is closed and I know the documentation you linked is incredibly unclear, but I think (can't verify right now, but it shouldn't be hard to do) that actually the binary protocol does support multi resultsets.

Specifically, you can see an example on https://dev.mysql.com/doc/internals/en/multi-resultset.html. I know that page is talking about stored procedures, but if you read at the bottom it says:

The client has to announce that it wants multi-resultsets by either setting the CLIENT_MULTI_RESULTS or CLIENT_PS_MULTI_RESULTS capability.

If you follow the link to CLIENT_PS_MULTI_RESULTS you will see that it says:

CLIENT_PS_MULTI_RESULTS
Server: Can send multiple resultsets for COM_STMT_EXECUTE.
Client: Can handle multiple resultsets for COM_STMT_EXECUTE.

And COM_STMT_EXECUTE is obviously used for prepared statements.

If this is true, then this issue should likely be reopened (alternatively, I can open a new one).

Multi resultset and multi query are different.
And this issue is about multi query.

@methane I was talking about multi resultant because you wrote:

And I found binary protocol (used by prepared statement) doesn't support mutli resultset.

This appears to be incorrect, as I wrote above.

The reason I'm bringing this up is because I ran into what I suspect being the same issue described here. If the only reason why this is not supported is because of what you wrote above, then there's no reason to close as wontfix.

If, on the other hand, the problem is not the same then I will open a different issue as I already have a test case ready. (update: opened #916)

Was this page helpful?
0 / 5 - 0 ratings