Bug #113380 | MySql.Data Client creates trailing space in datetime parameter causing app crash | ||
---|---|---|---|
Submitted: | 8 Dec 2023 16:36 | Modified: | 15 Dec 2023 16:58 |
Reporter: | Alex Kundzich | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 8.0.32 | OS: | Windows (2019 Server) |
Assigned to: | CPU Architecture: | Any | |
Tags: | MySqlCommand MySqlParameter datetime |
[8 Dec 2023 16:36]
Alex Kundzich
[13 Dec 2023 12:43]
MySQL Verification Team
Hello Alex, Thank you for the bug report. Could you please provide complete repeatable test case along with table structure for "Activity"? Regards, Ashwini Patil
[15 Dec 2023 4:08]
Alex Kundzich
-- It can be any table with a datatime. Create table Activity (id int, ActivityDate datetime); INSERT INTO Activity () VALUES (1,'2022-01-01'), (2,'2023-01-01'); This is modified sample from your tutorial https://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-sql-command.html public class Tutorial2 { public static void Main() { MySqlConnection conn = new MySqlConnection(ConnectionString); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(SELECT id FROM Activity WHERE ActivityDate >= @cDate", conn); cmd.Parameters.AddWithValue("cDate", new DateTime(2022, 10, 20)); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Console.WriteLine(reader.GetInt32(0).ToString()); } rdr.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); // At this point you will see the exception // "Fatal error encountered attempting to read the resultset." } conn.Close(); } } In MySQL General_Log (should be enabled) you should see the actual Query was SELECT id FROM Activity WHERE ActivityDate >= '2022-10-20 00:00:00 ' - Extra Trailing space causes the error.
[15 Dec 2023 12:38]
MySQL Verification Team
Hello Alex, Thank you for the details. I tried to reproduce your issue on Windows 11 with Connector/NET 8.0.32 and provided test case but I am not seeing any issues at my end. If you can provide more information, feel free to add it to this bug. Thanks. Regards, Ashwini Patil
[15 Dec 2023 16:58]
Alex Kundzich
Was your MySQL Server version also 8.0.32? If this is the case, then likely the issue was resolved in latest MySQL.Data versions, so you can close this issue. I was using MySQL Server 8.0.32 and Connector MySQL.Data version 6.9.9.0.
[16 Dec 2023 18:59]
Bradley Grainger
This bug was fixed in MySql.Data over six years ago: https://github.com/mysql/mysql-connector-net/commit/da35d906125d684e105ced866c438cf3ae36d8.... You should update to a more recent, supported version.