Bug #106247 "Incorrect arguments to mysqld_stmt_execute" with MySqlDbType.Enum
Submitted: 22 Jan 2022 20:24 Modified: 10 Jun 2022 15:24
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.23, 8.0.28 OS:Windows
Assigned to: CPU Architecture:Any
Tags: regression

[22 Jan 2022 20:24] Bradley Grainger
Description:
With MySQL Server 8.0.22 and later, using MySqlDbType.Enum as the parameter type with a prepared command throws MySqlException "Incorrect arguments to mysqld_stmt_execute".

How to repeat:
Run MySQL Server 8.0.22 or later; I can't repro with 8.0.21.

Execute the following SQL:

CREATE TABLE test(data ENUM('small', 'medium', 'large'));

Run the following C# code:

using var connection = new MySqlConnection("...;IgnorePrepare=false");
using var command = new MySqlCommand("insert into test(data) values(@data);", connection);
var parameter = new MySqlParameter("@data", MySqlDbType.Enum); // parameter type has to be set to MySqlDbType.Enum to trigger the bug
parameter.Value = "medium";
command.Parameters.Add(parameter);
command.Prepare(); // required to trigger the exception; doesn't happen if not prepared
command.ExecuteNonQuery(); // throws MySqlException "Incorrect arguments to mysqld_stmt_execute"
[6 Feb 2022 7:21] MySQL Verification Team
Hello Bradley,

Thank you for the report and test case.

regards,
Ashwini
[10 Jun 2022 15:24] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.30 release, and here's the proposed changelog entry from the documentation team:

Type MySqlDbType.Enum could not be used with the MySqlParameter method in
a prepared statement.

Thank you for the bug report.