List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:October 22 2009 9:29pm
Subject:bzr commit into connector-net-5.2 branch (reggie.burnett:713) Bug#48101
View as plain text  
#At file:///D:/bzr-connector-net/5.2/ based on revid:reggie@mobilecore-20090827225224-tpmvqoztleh46v8g

  713 Reggie Burnett	2009-10-22
      - fixed indexes schema collection so that it still works with bad table names such as b``a`d (bug #48101)

    modified:
      CHANGES
      MySql.Data/Provider/Source/Connection.cs
      MySql.Data/Provider/Source/MySqlHelper.cs
      MySql.Data/Provider/Source/SchemaProvider.cs
      MySql.Data/Tests/Source/GetSchemaTests.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2009-08-27 22:52:24 +0000
+++ b/CHANGES	2009-10-22 21:29:20 +0000
@@ -17,6 +17,7 @@
   a data adapter and inserts are used (bug #34657)
 - fixed problem with non-IS column parsing that caused data type and column type to be equal when
   parsing set and enum columns
+- fixed indexes schema collection so that it still works with bad table names such as b``a`d (bug #48101)
 
 Version 5.2.7 7/13/09
 - fixed procedure parameters collection so that an exception is thrown if we can't get the 

=== modified file 'MySql.Data/Provider/Source/Connection.cs'
--- a/MySql.Data/Provider/Source/Connection.cs	2008-07-18 19:51:08 +0000
+++ b/MySql.Data/Provider/Source/Connection.cs	2009-10-22 21:29:20 +0000
@@ -645,14 +645,6 @@
         /// <returns>A <see cref="DataTable"/> that contains schema information.</returns>
         public override DataTable GetSchema(string collectionName, string[] restrictionValues)
         {
-/*            string msg = String.Format("collection name2 = {0}", collectionName);
-            if (restrictionValues != null)
-                foreach (string s in restrictionValues)
-                {
-                    msg += String.Format(" res={0}", s);
-                }
-            System.Windows.Forms.MessageBox.Show(msg);
-            */
             if (collectionName == null)
                 collectionName = SchemaProvider.MetaCollection;
 
@@ -664,14 +656,9 @@
                 for (int x = 0; x < restrictions.Length; x++)
                 {
                     string s = restrictions[x];
-                    if (s != null)
-                    {
-                        if (s.StartsWith("`"))
-                            s = s.Substring(1);
-                        if (s.EndsWith("`"))
-                            s = s.Substring(0, s.Length - 1);
-                        restrictions[x] = s;
-                    }
+                    if (s == null) continue;
+                    s = s.Trim('`');
+                    restrictions[x] = s;
                 }
             }
 

=== modified file 'MySql.Data/Provider/Source/MySqlHelper.cs'
--- a/MySql.Data/Provider/Source/MySqlHelper.cs	2009-07-13 20:10:01 +0000
+++ b/MySql.Data/Provider/Source/MySqlHelper.cs	2009-10-22 21:29:20 +0000
@@ -31,7 +31,7 @@
 	{
         private static string stringOfBackslashChars = "\u005c\u00a5\u0160\u20a9\u2216\ufe68\uff3c";
         private static string stringOfQuoteChars =
-            "\u0027\u00b4\u02b9\u02ba\u02bb\u02bc\u02c8\u02ca\u02cb\u02d9\u0300\u0301\u2018\u2019\u201a\u2032\u2035\u275b\u275c\uff07";
+            "\u0027\u0060\u00b4\u02b9\u02ba\u02bb\u02bc\u02c8\u02ca\u02cb\u02d9\u0300\u0301\u2018\u2019\u201a\u2032\u2035\u275b\u275c\uff07";
 
         // this class provides only static methods
 		private MySqlHelper()
@@ -377,8 +377,9 @@
             StringBuilder sb = new StringBuilder();
             foreach (char c in value)
             {
-                if (stringOfQuoteChars.IndexOf(c) >= 0 ||
-                    stringOfBackslashChars.IndexOf(c) >= 0)
+                if (stringOfQuoteChars.IndexOf(c) >= 0)
+                    sb.Append(c);
+                else if (stringOfBackslashChars.IndexOf(c) >= 0)
                     sb.Append("\\");
                 sb.Append(c);
             }

=== modified file 'MySql.Data/Provider/Source/SchemaProvider.cs'
--- a/MySql.Data/Provider/Source/SchemaProvider.cs	2009-08-27 22:52:24 +0000
+++ b/MySql.Data/Provider/Source/SchemaProvider.cs	2009-10-22 21:29:20 +0000
@@ -267,7 +267,8 @@
             foreach (DataRow table in tables.Rows)
             {
                 string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
-                                           table["TABLE_SCHEMA"], table["TABLE_NAME"]);
+                    MySqlHelper.EscapeString((string)table["TABLE_SCHEMA"]), 
+                    MySqlHelper.EscapeString((string)table["TABLE_NAME"]));
                 MySqlDataAdapter da = new MySqlDataAdapter(sql, connection);
                 DataTable indexes = new DataTable();
                 da.Fill(indexes);

=== modified file 'MySql.Data/Tests/Source/GetSchemaTests.cs'
--- a/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-08-27 22:52:24 +0000
+++ b/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-10-22 21:29:20 +0000
@@ -362,13 +362,17 @@
             Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
             Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]);
 
+            /// <summary>
+            /// Bug #48101	MySqlConnection.GetSchema on "Indexes" throws when there's a table named "b`a`d"
+            /// </summary>
 			execSQL("DROP TABLE IF EXISTS test");
-			execSQL("CREATE TABLE test (id int, name varchar(50), " +
+			execSQL(@"CREATE TABLE `te``s``t` (id int, name varchar(50), " +
 				"KEY key2 (name))");
 
+            restrictions[2] = "te`s`t";
 			dt = conn.GetSchema("Indexes", restrictions);
 			Assert.AreEqual(1, dt.Rows.Count);
-			Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+			Assert.AreEqual("te`s`t", dt.Rows[0]["TABLE_NAME"]);
 			Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]);
 			Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
 			Assert.AreEqual(false, dt.Rows[0]["UNIQUE"]);


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20091022212920-znpm6hv81l9ld5sj.bundle
Thread
bzr commit into connector-net-5.2 branch (reggie.burnett:713) Bug#48101Reggie Burnett22 Oct