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

[MySQL] Statement with NULL column values fails with "Incorrect arguments to mysqld_stmt_execute" #125

Closed
repnop opened this issue Mar 9, 2020 · 4 comments · Fixed by #126

Comments

@repnop
Copy link
Contributor

repnop commented Mar 9, 2020

Reproduction: https://github.com/repnop/sqlx_issue run with docker-compose up

Error: Database(DatabaseError { message: "Incorrect arguments to mysqld_stmt_execute", details: None, hint: None, table_name: None, column_name: None, constraint_name: None })

I attempted to change the MAX_PACKET_SIZE (here), but even at a value of 10000 I still received the same error

@repnop
Copy link
Contributor Author

repnop commented Mar 9, 2020

I've attached a packet capture of the reproduction I made to help with debugging: sqlx_cap.zip

It looks like something is going pretty wrong with the packet encoding when it attempts to encode the None::<i32> value.

Parameter
    Type: FIELD_TYPE_LONG (3)
    Unsigned: 0
    Value: 1702102282

The data after that is garbage in wireshark and it looks like its not properly encoding the length of the None::<i32> and that means its spilling over into the other value's data.

@repnop
Copy link
Contributor Author

repnop commented Mar 10, 2020

I believe I found the issue :) submitting a PR

@repnop repnop changed the title [MySQL] Statement with many columns fails with "Incorrect arguments to mysqld_stmt_execute" [MySQL] Statement with NULL column values fails with "Incorrect arguments to mysqld_stmt_execute" Mar 10, 2020
@mehcode
Copy link
Member

mehcode commented Mar 10, 2020

Thanks again for looking into this. Released as v0.2.6

@repnop
Copy link
Contributor Author

repnop commented Mar 10, 2020

My pleasure, thanks to you and the other contributors for providing a great crate :) happy to help

shuhaowu added a commit to Shopify/ghostferry that referenced this issue Apr 28, 2021
This error appears to only happen on CI and not locally, despite
everything running with the same version. I have no idea why this is the
case.

Since I removed the `nil` from the prepared statement, it is possible
that this problem is related to
launchbadge/sqlx#125, but I'm not sure. I also
don't really know how to debug in github actions yet, so I don't know
how to confirm if this is indeed the case.
shuhaowu added a commit to Shopify/ghostferry that referenced this issue Apr 28, 2021
This error appears to only happen on CI and not locally, despite
everything running with the same version. I have no idea why this is the
case.

Since I removed the `nil` from the prepared statement, it is possible
that this problem is related to the issues linked below, but I'm not sure. I also
don't really know how to debug in github actions yet, so I don't know
how to confirm if this is indeed the case.

- go-sql-driver/mysql#209
- launchbadge/sqlx#125
- https://stackoverflow.com/questions/16726752/sending-null-in-a-prepared-statement-for-mysql-doesnt-seem-to-work?rq=1
shuhaowu added a commit to Shopify/ghostferry that referenced this issue Apr 28, 2021
This error appears to only happen on CI and not locally, despite
everything running with the same version. I have no idea why this is the
case.

Since I removed the `nil` from the prepared statement, it is possible
that this problem is related to the issues linked below, but I'm not sure. I also
don't really know how to debug in github actions yet, so I don't know
how to confirm if this is indeed the case.

- go-sql-driver/mysql#209
- launchbadge/sqlx#125
- https://stackoverflow.com/questions/16726752/sending-null-in-a-prepared-statement-for-mysql-doesnt-seem-to-work?rq=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants