Bug #89085 MySqlConnection.Database not updated after "USE DATABASE;"
Submitted: 1 Jan 2018 7:10 Modified: 1 Jan 2018 12:12
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.10.4 OS:Windows ( 10.0.16299 x64)
Assigned to: CPU Architecture:Any

[1 Jan 2018 7:10] Bradley Grainger
Description:
DbConnection.Database is documented as returning "The name of the current database": https://docs.microsoft.com/en-us/dotnet/api/system.data.common.dbconnection.database?view=...

The value of this property is not updated after executing a "USE <dbname>;" command to change the current database.

How to repeat:
Execute the following C# program against a server that has two databases: "db1" and "db2"

MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder
{
	Server = ...,
	UserID = ...,
	Password = ...,
	Database = "db1",
};

using (var connection = new MySqlConnection(csb.ConnectionString))
{
	connection.Open();
	Console.WriteLine(connection.Database); // "db1"

	using (var cmd = connection.CreateCommand())
	{
		cmd.CommandText = "USE db2;";
		cmd.ExecuteNonQuery();
	}
	Console.WriteLine(connection.Database); // prints "db1", expected "db2"
}

Suggested fix:
Implementing support for CLIENT_SESSION_TRACK would allow changes to the current database to be tracked.
[1 Jan 2018 12:12] Chiranjeevi Battula
Bug #89085 -- 1-01-2018

Hello Bradley Grainger,

Thank you for the bug report and test case.
Verified this behavior on Visual Studio 2015 (C#.Net) and Connector/NET 6.10.4 version.

Thanks,
Chiranjeevi.
[1 Jan 2018 12:12] Chiranjeevi Battula
Screenshot

Attachment: Bug_89085.png (image/png, text), 97.49 KiB.