question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect arguments to mysqld_stmt_execute (MySQL 8.0.22)

See original GitHub issue

Hi, love this library!

Have been using it successfully across a large number of projects and it’s worked flawlessly for me so far. Just now I’ve seen that I have a single test case failing on the CI server (Gitlab), MySQL 8, failing with the following error:

VError: Failed executing query: \"SELECT * FROM message WHERE chat_id = ? ORDER BY sent DESC LIMIT ? OFFSET ?\" [01ensmg6m4dea0gh7gsjgaa5gb, 50, 0]: Incorrect arguments to mysqld_stmt_execute
    at ConnectionPool.<anonymous> (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:128:27)
    at Generator.throw (<anonymous>)
    at rejected (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
caused by: Error: Incorrect arguments to mysqld_stmt_execute
    at PromiseConnection.execute (/data/node_modules/mysql2/promise.js:110:22)
    at ConnectionPool.<anonymous> (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:117:58)
    at Generator.next (<anonymous>)
    at fulfilled (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:5:58)

Now this error is wrapped by my own logic, but the cause I think it quite clear: Incorrect arguments to mysqld_stmt_execute. The query being passed to the execute method on the mysql2/promise library is SELECT * FROM message WHERE chat_id = ? ORDER BY sent DESC LIMIT ? OFFSET ? and the values are ["01ensmg6m4dea0gh7gsjgaa5gb", 50, 0]. For some reason this only fails on the CI, and not locally on any of my (or my colleagues’) machines.

If I change this to query instead of execute, it works on the CI. If I form this query manually using the values that were passed-in, and run it, it also works.

Any idea what’s happening here? Is there some failure in how the parameters are being transferred to the MySQL service before being inserted?

EDIT 1: I’m also using v2.2.5 of the library

EDIT 2: Seems after the suggestions made here that the issue, at least for me, is only with mysql2 and MySQL server 8.0.22. 8.0.21 seems to work fine.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:42 (17 by maintainers)

github_iconTop GitHub Comments

16reactions
YangJ0605commented, Jan 14, 2021

mysql => 8.0.22 mysql2 => 2.2.5

const statement = SELECT moment.id as id, moment.content as content, moment.createAt createTime, moment.updateAt updataTime, JSON_OBJECT('id', users.id, 'username', users.username) author FROM moment LEFT JOIN users ON moment.user_id = users.id LIMIT ? OFFSET ?;

connection.execute(statement, [size + “”, page + “”])

replace number with characters

6reactions
dalalmjcommented, Jan 14, 2021

@sidorares, just FYI, instead of passing javascript number type, if value is passed as “string” (even though column in int), it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Incorrect arguments to mysqld_stmt_execute
This appears to be a bug introduced in MySQL version 8.0.22, I'm getting the same error after updating from 8.0.19.
Read more >
Error 1210 - “Incorrect arguments to mysqld_stmt_execute
We suspect the query failure happens when we create a row in the table containing a blob column and if the blob is...
Read more >
Incorrect arguments to mysqld_stmt_execute (MySQL 8.0.22)
Hi, love this library! Have been using it successfully across a large number of projects and it's worked flawlessly for me so far....
Read more >
#1639 Error executing statement parameters: Incorrect ...
Configure with sql backend with mysql (version >= 8.0.22) 3. ... executing statement parameters: Incorrect arguments to mysqld_stmt_execute ...
Read more >
How to avoid the error "Incorrect arguments to ...
How to avoid the error "Incorrect arguments to mysqld_stmt_execute"? ... This error is very likely due to a bug in the SQL driver...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found