Bug #41452 | MySqlDataReader's GetGuid method does not treat BINARY(16) column as Guid | ||
---|---|---|---|
Submitted: | 14 Dec 2008 10:37 | Modified: | 6 Mar 2009 15:38 |
Reporter: | Christopher Jerdonek | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S3 (Non-critical) |
Version: | 5.2.5 | OS: | Windows |
Assigned to: | CPU Architecture: | Any | |
Tags: | connector, getstring, Guid, IMySqlValue, IsGuid, MySqlBinary, MySqlDataReader, ToString |
[14 Dec 2008 10:37]
Christopher Jerdonek
[1 Jan 2009 4:41]
Christopher Jerdonek
Perhaps a cleaner fix would be along these lines: Add a ToString() method to the internal IMySqlValue interface, and implement this interface method explicitly in each IMySqlValue. For example, in the MySqlTime class (which contains a public override of ToString()), the implementation could look like-- string IMySqlValue.ToString() { return Value.ToString(); } Then MySqlDataReader's GetString method could be simplified to something like the following. /// <include file='docs/MySqlDataReader.xml' path='docs/GetString/*'/> public override String GetString(int i) { IMySqlValue val = GetFieldValue(i, true); return val.ToString(); } This way, the explicit IMySqlValue.ToString() method of the MySqlBinary class can contain the code special to MySqlBinary instances, along with the logic that tests for when IsGuid is true.
[13 Feb 2009 14:38]
Tonci Grgin
Hi Christopher and thanks for your report. Verified as described using 5.2 SVN branch against MySQL server 5.1.30 on W2K8 x64 localhost. .NET FW 2 string szSelect = "SELECT * FROM guid_table"; MySqlCommand myCommand = new MySql.Data.MySqlClient.MySqlCommand(szSelect, conn); //THIS WORKS DataSet myDS = null; using (MySql.Data.MySqlClient.MySqlDataAdapter sqlDA = new MySql.Data.MySqlClient.MySqlDataAdapter(myCommand)) { myDS = new DataSet(); sqlDA.Fill(myDS); } if (null != myDS) if (myDS.Tables.Count > 0) if (myDS.Tables[0].Rows.Count > 0) { Console.Out.WriteLine("GUID returned from mysql: " + myDS.Tables[0].Rows[0]["guid"].ToString()); } THIS DOES NOT MySqlDataReader dr = myCommand.ExecuteReader(); dr.Read(); MessageBox.Show(dr.GetName(0)); MessageBox.Show(dr.GetGuid(0).ToString());
[5 Mar 2009 17:49]
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: http://lists.mysql.com/commits/68409
[5 Mar 2009 17:51]
Reggie Burnett
fixed in 5.2.6
[6 Mar 2009 15:38]
Tony Bedford
An entry was added to the 5.2.6 changelog: The GetGuid() method of MySqlDataReader did not treat BINARY(16) column data as a GUID. When operating on such a column a FormatException exception was generated.