TinyInt parameters mess up data from consequent parameters.
Posted: Wed 30 Nov 2011 00:09
Hello.
I am using parametrized statements for INSERT, involving a couple columns of type TinyInt. I noticed that if I have a TinyInt parameter in a prepared statement, consequent parameters' values are not sent correctly. Here is an example:
Simple schema:
The update query, and parameter setup:
And finally the code that calls it:
One would expect the query produced to be:
However, mysqld's general log shows that it receives
The expected parameter value is 456 (0x1C8), and the actual parameter value is 116736 (0x1C800). Here is a simple test case: TinyIntTestCase.zip (2.8 KB)
Please let me know if this is something I can fix, or if it's a bug.
I am using parametrized statements for INSERT, involving a couple columns of type TinyInt. I noticed that if I have a TinyInt parameter in a prepared statement, consequent parameters' values are not sent correctly. Here is an example:
Simple schema:
Code: Select all
CREATE TABLE IF NOT EXISTS `tiny_int_test_case` (
`key` int(11) NOT NULL AUTO_INCREMENT,
`value` tinyint(4) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=456;Code: Select all
string UpdateCommandText = "UPDATE `tiny_int_test_case` SET `value`=? WHERE `key`=?;";
var updateCmd = new MySqlCommand( UpdateCommandText, connection );
updateCmd.Parameters.Add( "value", MySqlType.TinyInt );
updateCmd.Parameters.Add( "key", MySqlType.Int );
updateCmd.Prepare();Code: Select all
updateCmd.Parameters[0].Value = (byte)123;
updateCmd.Parameters[1].Value = 456;
updateCmd.ExecuteNonQuery();Code: Select all
UPDATE `tiny_int_test_case` SET `value`=123 WHERE `key`=456Code: Select all
UPDATE `tiny_int_test_case` SET `value`=123 WHERE `key`=116736Please let me know if this is something I can fix, or if it's a bug.