-
Notifications
You must be signed in to change notification settings - Fork 14
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
MySQL 8: Error executing statement parameters: Incorrect arguments to mysqld_stmt_execute #64
Comments
Hi, are there any updates on this? I encounter the same issue, and it prevents some people in the Monal XMPP client from sending messages through our Prosody server (which implements luadbi). |
I'm using a custom XMPP client that connects to a Prosody server and am affected by this same issue. |
Is everyone affected using Lua 5.3? |
I'm running Prosody with Lua 5.1:
|
5.2 for me
|
seems to be caused by an update to MySQL, does this need to be patched in luadbi as well? |
I think what I meant was that all numbers in Lua 5.2 are floats, so floats is what gets pushed, but MySQL wants integers here. Was my guess anyway. |
sidorares/node-mysql2#1239 (comment) suggests that MySQL expects these numbers to be strings. And indeed: s = assert(db:prepare("SELECT 1 LIMIT ? OFFSET ?"))
assert(s:execute(1, 1)) --[[
stdin:1: Error executing statement parameters: Incorrect arguments to mysqld_stmt_execute
stack traceback:
[C]: in function 'assert'
stdin:1: in main chunk
[C]: in ?
]]
assert(s:execute("1", "1")) --> true I don't even! |
One solution would be to check whether |
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html#mysqld-8-0-22-optimizer
So: Due to how the Lua C API is implemented, we have no way of knowing within the binding if the value is an integer or a float. And because we're a binding, we also don't have a way to know if a specific parameter is inside a LIMIT or OFFSET clause. TL;DR: we're basically hosed? |
lua_tointeger() ? Or am I missing something? Edit: Never mind, I see what I was missing now. We don't know when we need to use that instead. |
So in Lua 5.3+ we can probably push this burden onto the user, because Lua does differentiate between integers and non-integers itself now. So we just need to ensure we pass to MySQL as integers if(lua_isinteger(param)). We then either drop support for Lua 5.2 and earlier, or just live with them not being able to use LIMIT/OFFSET in recent MySQL versions, or we go an extra mile and make some kind of compatibility API with a wrapper type for integers. The second option seems the most reasonable to me. |
I swear I spent hours looking for exactly this and never found it :) This is exactly what is needed, at least for 5.3 and newer.
I've been thinking about exactly that, for the simple reason that it may be useful in other unexpected contexts, such as emulating booleans, nil/NULL impedence mismatches - or possibly future cases unforseen. The overhead shouldn't be huge, if you don't need it don't use it. Something like: DBI.forceinteger( 123 ) - which returns a Userdata that the underlying DBI layer knows how to interpret. But IMHO we can, and should, move on full 5.3 integer support and worry about that compatibility API later. For correctness alone implement it in the other drivers as well. |
Is a PR being prepared for this? FreeBSD stopped including mysql 5.x in ports, hence I'm not even in the situation of compiling luadbi with it, so I could have mysql support for prosody. |
For what it's worth, I can confirm MariaDB 10.6 is not impacted by this. (I'm fully aware that doesn't mean much to a lot of people who have their reasons to use mainline MySQL.) |
Attempt to provide partial fix for Issue #64.
Finally managed to test #75 against MySQL 8.0.36 with Lua 5.4 and it worked flawlessly. I'm reluctant to close this issue without further confirmation. Can someone who originally reported trouble, ie with Prosody, test and see if the problem is fixed? |
Can be reproduced with e.g.
A MySQL to test against can be brought up easily using:
Theory: MySQL expects integers in the LIMIT slot but LuaDBI is pushing floats, since before Lua 5.3, all numbers are.
The text was updated successfully, but these errors were encountered: