Skip to content

Executing many-values or multi-row insert statements with NULL values fails #209

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

Closed
ffdwg opened this issue Jan 24, 2014 · 3 comments
Closed
Labels

Comments

@ffdwg
Copy link

ffdwg commented Jan 24, 2014

Inserting rows with more than 32 values fails if there are NULL values beyond this limit.

You can reproduce the error using a very wide table (>32 fields) and insert a NULL row or similar:

INSERT INTO mytab (x1, x2, x3, ..., x32, x33)
VALUES (?, ?, ?, ..., ?, ?)

Execute it with parameters like:

[ 1, 2, 3, ... , 32, nil ]

The same happens on small tables with a multi-row insert

INSERT INTO mytab VALUES (?, ?, ?), (?, ?, ?), ... (?, ?, ?)

with more than 32 values and latter NULL/nil values.
The SQL server answers with

Error 1210: Incorrect arguments to mysqld_stmt_execute

I assume that there is a bug in packets.go stmt.writeExecutePacket function: The nullMask variable should be an array of byte or uint to support more than 32 fields (bits), right?

@arnehormann
Copy link
Member

Reminder for us: related to #201?

@ffdwg
Copy link
Author

ffdwg commented Jan 27, 2014

No, I don't think so.
The bug I found is definitely related to NULL values mapped to the
placeholders (i.e. NullMask bytes).
It does not cause a GO panic but results in a MySQL error.

I think #201 is a more general error related to the absolute buffer size
for placeholder values.

Am 24.01.2014 17:26 schrieb Arne Hormann:

Reminder for us: related to #201
#201?


Reply to this email directly or view it on GitHub
#209 (comment).

Falko Feßer
Deutsche WindGuard Systems GmbH
Bundesallee 67
D-12161 Berlin
Germany

Tel: +49 (0)30 - 223 200 -10
direct: -27
Fax: -24

E-mail: [email protected]

Web: http://www.windguard.de/

Amtsgericht Charlottenburg HRB 130730 B
Geschäftsführer / Directing manager: Falko Feßer
Prokurist / Proxy: Holger Piper


Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren
sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail.
Any unauthorised copying, disclosure or distribution of the material

in this e-mail is strictly forbidden.

@arnehormann
Copy link
Member

Closing this, further comments in #210 please.

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
Projects
None yet
Development

No branches or pull requests

2 participants