Bug #20707 | NULLs get passed as parameters to stored procedure. | ||
---|---|---|---|
Submitted: | 26 Jun 2006 21:18 | Modified: | 29 Jun 2006 7:51 |
Reporter: | Tristan Aubrey-Jones | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 1.0.7 | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[26 Jun 2006 21:18]
Tristan Aubrey-Jones
[26 Jun 2006 21:19]
Tristan Aubrey-Jones
To invoke the stored procedure directly (and see it working) use the following from the mysql console: CALL Sp_UserLogin_Create("tristan", "passwordhash12345678", "salt012345", 0, 1, 1, 1, 0, @oID);
[28 Jun 2006 10:39]
Tristan Aubrey-Jones
Ive isolated the problem though I still cant solve it. If the stored procedure and related code is altered to exclude the iStatus tinyint unsigned parameter, everything works. Unfortuantley I need this parameter - I have looked into the driver's database type selection and discovered that if you declare the parameter as UByte it tried to serialize the parameter as a MySqlBinaryValue - this being Bug number 1. p = new MySqlParameter("iStatus", MySqlDbType.UByte); p.Value = 1; p.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(p); This can be simply solved by altering the internal method: MySqlValue.GetMySqlValue in the drivers source to include cases for the unsigned integer types. However once this was solved and the parameter was being serialized as an unsigned byte value I get a database exception "#HY000Incorrect arguments to mysql_stmt_execute" - Bug number 2 - so it looks like MySql doesnt expect unsigned tinyints to be serialized as unsigned bytes - odd but ok. Now I try passing the parameter as a UInt32 - this is inserted into the table: mysql> select ID, Username, Password_Hash, IsBetaTester, Status from userlogin; +----+----------+----------------------+--------------+--------+ | ID | Username | Password_Hash | IsBetaTester | Status | +----+----------+----------------------+--------------+--------+ | 1 | 4 | 0 | | 0 | +----+----------+----------------------+--------------+--------+ 1 row in set (0.00 sec) Huh!? Now if I try it as Int32 i get: mysql> select ID, Username, Password_Hash, IsBetaTester, Status from userlogin; +----+----------+----------------------+--------------+--------+ | ID | Username | Password_Hash | IsBetaTester | Status | +----+----------+----------------------+--------------+--------+ | 1 | 4 | 0 | | 0 | | 2 | 0 | 0 | | 0 | +----+----------+----------------------+--------------+--------+ 2 rows in set (0.00 sec) :S And the same pattern for UInt64 and Int64 respectively. What is going on? What datatype does the MySql client protocol want UNSIGNED TINYINTS to be transmitted? Any help?
[29 Jun 2006 7:02]
Tonci Grgin
Hi again Tristan. Great test case! Can you tell me what happens if you remove // open connection and execute procedure connection.Open(); //this line command.Prepare(); command.ExecuteNonQuery(); connection.Close(); ?
[29 Jun 2006 7:47]
Tristan Aubrey-Jones
Thanks! It works - just removing the prepare line seems to work! I can send in the Status parameter as a Byte or UByte and the line appears as it should. So shouldn't I be using the prepare statement? Whats it doing to muck up the final execution? P.S. Id still like to see bug 1 (the issue of UByte and UInt32 etc not appearing in various switch statments) addressed in the next release.
[29 Jun 2006 7:51]
Tonci Grgin
Trista, glad it works! This seems to be the duplicate of http://bugs.mysql.com/bug.php?id=18570. Patch is in review.