#At file:///D:/bzr-connector-net/6.1/ based on revid:reggie.burnett@stripped
781 Reggie Burnett 2009-10-23
- fixed guid type so that multi-byte character sets will not effect how it works. A column would be
considered a guid if it has a *character* length of 36, not a *byte* length of 36 (bug #47985)
modified:
CHANGES
MySql.Data/Provider/Source/Field.cs
MySql.Data/Provider/Source/NativeDriver.cs
MySql.Data/Tests/Source/DataTypeTests.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES 2009-10-23 15:50:17 +0000
+++ b/CHANGES 2009-10-23 15:53:16 +0000
@@ -6,6 +6,8 @@
- fixed crash that can occur when oldGuids are used and binary(16) column used for GUID
contains a null value (thanks Troy!) (bug#47928)
- fixed indexes schema collection so that it still works with bad table names such as b``a`d (bug #48101)
+- fixed guid type so that multi-byte character sets will not effect how it works. A column would be
+ considered a guid if it has a *character* length of 36, not a *byte* length of 36 (bug #47985)
Version 6.1.2
- fixed hanging after losing network connectivity to server (bug#43761)
=== modified file 'MySql.Data/Provider/Source/Field.cs'
--- a/MySql.Data/Provider/Source/Field.cs 2009-07-28 20:40:35 +0000
+++ b/MySql.Data/Provider/Source/Field.cs 2009-10-23 15:53:16 +0000
@@ -179,6 +179,11 @@
}
}
+ public int CharacterLength
+ {
+ get { return ColumnLength / MaxLength; }
+ }
+
#endregion
public void SetTypeAndFlags(MySqlDbType type, ColumnFlags flags)
@@ -263,7 +268,7 @@
if (connection.Settings.RespectBinaryFlags)
CheckForExceptions();
- if (Type == MySqlDbType.String && ColumnLength == 36 && !connection.Settings.OldGuids)
+ if (Type == MySqlDbType.String && CharacterLength == 36 && !connection.Settings.OldGuids)
mySqlDbType = MySqlDbType.Guid;
if (!IsBinary) return;
=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
--- a/MySql.Data/Provider/Source/NativeDriver.cs 2009-09-16 19:05:15 +0000
+++ b/MySql.Data/Provider/Source/NativeDriver.cs 2009-10-23 15:53:16 +0000
@@ -717,12 +717,7 @@
colFlags = (ColumnFlags)packet.ReadInteger(2);
else
colFlags = (ColumnFlags)packet.ReadByte();
-
- field.SetTypeAndFlags(type, colFlags);
-
field.Scale = (byte)packet.ReadByte();
-
-
if (packet.HasMoreData)
{
packet.ReadInteger(2); // reserved
@@ -730,7 +725,7 @@
if (charSets != null && field.CharacterSetIndex != -1)
{
- CharacterSet cs = CharSetMap.GetCharacterSet(Version, (string) charSets[field.CharacterSetIndex]);
+ CharacterSet cs = CharSetMap.GetCharacterSet(Version, (string)charSets[field.CharacterSetIndex]);
// starting with 6.0.4 utf8 has a maxlen of 4 instead of 3. The old
// 3 byte utf8 is utf8mb3
if (cs.name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "utf-8" &&
@@ -738,9 +733,10 @@
field.MaxLength = 4;
else
field.MaxLength = cs.byteCount;
- field.Encoding = CharSetMap.GetEncoding(version, (string) charSets[field.CharacterSetIndex]);
+ field.Encoding = CharSetMap.GetEncoding(version, (string)charSets[field.CharacterSetIndex]);
}
+ field.SetTypeAndFlags(type, colFlags);
return field;
}
=== modified file 'MySql.Data/Tests/Source/DataTypeTests.cs'
--- a/MySql.Data/Tests/Source/DataTypeTests.cs 2009-10-16 14:45:02 +0000
+++ b/MySql.Data/Tests/Source/DataTypeTests.cs 2009-10-23 15:53:16 +0000
@@ -979,5 +979,30 @@
}
}
}
+
+ /// <summary>
+ /// Bug #47985 UTF-8 String Length Issue (guids etc)
+ /// </summary>
+ [Test]
+ public void UTF8Char12AsGuid()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT, name CHAR(12) CHARSET utf8)");
+ execSQL("INSERT INTO Test VALUES (1, 'Name')");
+
+ string connStr = GetConnectionString(true) + ";charset=utf8";
+ using (MySqlConnection c = new MySqlConnection(connStr))
+ {
+ c.Open();
+
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c);
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ string s = reader.GetString(1);
+ Assert.AreEqual("Name", s);
+ }
+ }
+ }
}
}
Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20091023155316-hlb2qhfkhrqbbmze.bundle
| Thread |
|---|
| • bzr commit into connector-net-6.1 branch (reggie.burnett:781) Bug#47985 | Reggie Burnett | 23 Oct |