Closed
Description
Issue description
In our "BatchInsert" function, we prepare a query with the maximum number of placeholders.
But when we try to execute the prepared statement, with empty strings in the arguments, we get an error.
stmt.Exec(args...) returns an "Error 1210" when args contains empty strings, and when its length is close to 65536 (maximum possible length of placeholders)
When we limit the number of placeholders to 60000, it works again.
Example code
// caller
columnNames := []string{"id", "id1", "text", "id2", "id3"}
params := []interface{}{}
nbLine := 100000
for i := 0; i < nbLine; i ++ {
params = append(params, i+1, i+1, "", i+1, i+1)
}
BatchInsert(db, "tablename", columnNames, params_tmp...)
//in BatchInsert
func BatchInsert(db *sql.DB, tableName string, columnNames []string, args ...interface{}) error {
...
//stuff before
stmt, err := db.Prepare(finalRequest)
if err != nil {
return errors.Wrap(err, " Mass Insert : Prepare FinalRequest")
}
defer stmt.Close()
//stuff
_, err := stmt.Exec(args[indexStart:indexEnd]...)
//this returns an error, when args contains an empty string, and its length approaches 65536
//stuff after
}
Error log
Error 1210: Incorrect arguments to mysqld_stmt_execute
Configuration
Driver version (or git SHA):
9181e3a
Go version: run go version
in your console
1.9.1
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL 5.7.19
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
Debian GNU/Linux 8.9 (jessie)
Metadata
Metadata
Assignees
Labels
No labels