Bug #91753 Unnamed parameter not supported by MySqlCommand.Prepare
| Submitted: | 22 Jul 2018 4:11 | Modified: | 18 Nov 2021 18:52 |
|---|---|---|---|
| Reporter: | Bradley Grainger (OCA) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 8.0.11 | OS: | Windows (10.0.17134.167) |
| Assigned to: | CPU Architecture: | Any (x64) |
[22 Jul 2018 14:16]
MySQL Verification Team
Hello Bradley, Thank you for the report and feedback. Thanks, Umesh
[18 Nov 2021 18:52]
Daniel Valdez
Posted by developer: This is no longer a bug. Verified using latest version of Connector/NET, v8.0.27.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: MySqlCommand supports using unnamed (i.e., positional) parameters by using ? in the query. However, if MySqlCommand.Prepare() is called, using a ? parameter throws a MySqlException "Incorrect arguments to mysqld_stmt_execute". at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() The command should succeed whether or not MySqlCommand.Prepare() is called. How to repeat: Run the following C# code: // NOTE: MUST have IgnorePrepare=false in connection string using (var connection = new MySqlConnection("...;IgnorePrepare=false")) { connection.Open(); using (var command = new MySqlCommand(@" DROP TABLE IF EXISTS test; CREATE TABLE test(value INT NOT NULL); ", connection)) command.ExecuteNonQuery(); using (var command = new MySqlCommand(@"INSERT INTO test VALUES(?);", connection)) { command.Parameters.Add(new MySqlParameter { Value = 1 }); // *** this causes the bug *** command.Prepare(); // this throws the exception command.ExecuteNonQuery(); } } A simpler example is changing the command to "SELECT ?" and using command.ExecuteScalar();