Bug #27269 MySqlConnection.Clone does not mimic SqlConnection.Clone behaviour
Submitted: 19 Mar 2007 18:27 Modified: 26 Mar 2007 6:34
Reporter: Dani Sardà Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.0.5 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[19 Mar 2007 18:27] Dani Sardà
When cloning a MySqlClient.MySqlConnection; if it has been open and Persist Security Info=False, the cloned connection is not usable because the StringConnection has lost the password information.

This is not the case with the SqlClient.SqlConnection or OleDbClient.OleDbConnection.

How to repeat:
Create a connection. (Make sure Persist Security Info is not set to True in the Connection String)
Open it.
Clone it.
Open the clonned connection

//Create a connection
MySql.Data.MySqlClient.MySqlConnection cnMySql = new MySql.Data.MySqlClient.MySqlConnection(CS_MY);
//Open it
//Clone it
ICloneable clMySql = (ICloneable)cnMySql;
MySql.Data.MySqlClient.MySqlConnection cnMySqlClone = (MySql.Data.MySqlClient.MySqlConnection)clMySql.Clone();
//Open the cloned connection

Suggested fix:
In the ICloneable.Clone method of MySqlConnection copy the connection string by using the internal GetConnectionString method rather than using the public ConnectionString property:

//clone.ConnectionString = this.ConnectionString;
clone.ConnectionString = this.settings.GetConnectionString(true);
[22 Mar 2007 19:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

[22 Mar 2007 19:58] Reggie Burnett
Fixed in 5.0.7
[26 Mar 2007 6:29] MC Brown
A note has been added to the 5.0.7 changelog.
[26 Mar 2007 6:34] MC Brown
Closing bug.