Bug #64867 Fractional seconds are occasionally passed to the server incorrectly
Submitted: 4 Apr 2012 15:06 Modified: 20 Jan 2023 18:38
Reporter: Andrey Chirikba Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.5.4 OS:Windows (MySQL server 5.6.4)
Assigned to: Assigned Account CPU Architecture:Any
Tags: fractional, SECONDS

[4 Apr 2012 15:06] Andrey Chirikba
Description:
Connector/Net sometimes/often passes fractional seconds incorrectly for datetime columns. In the testcase given, "2012-04-01 22:41:32.040" is passed as "2012-04-01 22:41:32.400". The column is defined as datetime(3). It doesn't matter whether the value is passed as DateTime or as a string.

The same works correctly when typed in manually in the MySQL client.

How to repeat:
CREATE TABLE `clip` (
  `starttime` datetime(3) DEFAULT NULL,
  KEY `starttime` (`starttime`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

MySqlConnection dbh = new MySqlConnection(connectionString);
dbh.Open();

string insertQuery = "INSERT  INTO clip (starttime) VALUES  (@p1)";

MySqlCommand sth = new MySqlCommand(insertQuery, dbh);
sth.Parameters.Add("@p1", MySqlDbType.DateTime).Value = "2012-04-01 22:41:32.040";
sth.ExecuteNonQuery();
dbh.Close();

Suggested fix:
Not use the functionality. Use DATE_ADD(date_without_fractional_seconds, INTERVAL microseconds MICROSECONDS).
[26 Apr 2012 14:57] Gabriela Martinez Sanchez
This bug is duplicated by 64686 which is ready for review.
[19 Feb 2013 20:28] Gabriela Martinez Sanchez
This bug can be closed since 64686 is pushed and released.
[20 Jan 2023 18:38] Daniel Valdez
Posted by developer:
 
No longer a bug. Verified used the latest version of Connector/NET, v8.0.32.