Bug #91751 YEAR column retrieved incorrectly with prepared command
Submitted: 22 Jul 2018 2:55 Modified: 22 Jul 2018 14:03
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.11 OS:Microsoft Windows (10.0.17134.167)
Assigned to: CPU Architecture:Any (x64)

[22 Jul 2018 2:55] Bradley Grainger
Description:
If MySqlCommand.Prepare() is called for a statement that SELECTs a YEAR column, an incorrect value is returned for that column.

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_year;
CREATE TABLE test_year(yr YEAR NOT NULL);
INSERT INTO test_year VALUES(2018);
", connection))
		command.ExecuteNonQuery();
		
	using (var command = new MySqlCommand(@"SELECT yr FROM test_year", connection))
	{
		// *** this causes the bug ***
		command.Prepare();

		using (var reader = command.ExecuteReader())
		{
			while (reader.Read())
			{
				// prints 1828718562, expected 2018
				Console.WriteLine(reader.GetValue(0));
			}
		}
	}
}
[22 Jul 2018 14:03] Umesh Shastry
Hello Bradley,

Thank you for the report and feedback.

Thanks,
Umesh