Bug #105209 Bug #91752 is marked as fixed in v8.0.16, but still present in v8.0.26
Submitted: 13 Oct 2021 15:07 Modified: 24 Nov 2021 17:23
Reporter: Ann Onymous Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.26 OS:Windows
Assigned to: CPU Architecture:Any

[13 Oct 2021 15:07] Ann Onymous
When reading zero time values from a TIME NOT NULL column, the data reader can return a null value instead of a zero time, causing a SqlNullValueException on an attempt to call GetTimeSpan(). This seems to happen when the reader encounters a nonzero time value, followed by a zero time value for the same column.

How to repeat:
Create a C# console app containing the following methods (connection string removed for privacy), and run it. The first two rows will be processed successfully, the third will throw the exception.

static void Main(string[] args)
    using (var connection = new MySqlConnection("..."))
        using (var command = new MySqlCommand(@"
            DROP TABLE IF EXISTS test_time;
            CREATE TABLE test_time(tm TIME NOT NULL);
            INSERT INTO test_time VALUES('00:00:00');
            INSERT INTO test_time VALUES('01:01:01');
            INSERT INTO test_time VALUES('00:00:00');
            ", connection))

        using (var command = new MySqlCommand(@"SELECT tm FROM test_time", connection))
            using (var reader = command.ExecuteReader())


private static void OutputRow(MySqlDataReader reader)

        Console.WriteLine($"GetValue: {reader.GetValue(0)}, GetTimeSpan: {reader.GetTimeSpan(0)}");
    catch (Exception ex)
[14 Oct 2021 8:15] Ann Onymous
Further testing confirms that this affects nullable as well as non-nullable TIME columns.
[14 Oct 2021 12:48] MySQL Verification Team
Hello Ann Onymous,

Thank you for the report.
Verified as described.

Ashwini Patil
[24 Nov 2021 17:23] Christine Cole
Posted by developer:
Fixed as of the upcoming MySQL Connector/NET 8.0.28 release, and here's the proposed changelog entry from the documentation team:

When reading zero time values from TIME NOT NULL columns, the data reader
could return a NULL value instead of zero, causing subsequent
GetTimeSpan() calls to fail. Now, if Connector/NET encounters NULL when
reading the column value, it resets the value to zero time ('00:00:00').

Thank you for the bug report.