List:Commits« Previous MessageNext Message »
From:rburnett Date:March 31 2009 7:39pm
Subject:Connector/NET commit: r1540 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Source
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Data/Provider/Source/SchemaProvider.cs
   branches/5.2/MySql.Data/Tests/Source/GetSchemaTests.cs
Log:
  - fixed index and index column schema collections that would fail if you specified the
    any restrictions more specific than table name (bug #43991)


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2009-03-31 19:38:16 UTC (rev 1539)
+++ branches/5.2/CHANGES	2009-03-31 19:39:41 UTC (rev 1540)
@@ -27,6 +27,8 @@
   rolled back in every case (bug #43553)   
 - Fixed typo in the collection returned when you request the MetaDataCollections collection.  The
   NumberOfRestrictions column was missing the trailing s. (bug #43990)      
+- fixed index and index column schema collections that would fail if you specified the
+  any restrictions more specific than table name (bug #43991)      
       
 Version 5.2.5 - 11/14/2008
 - fixed problem with package registration that kept the DDEX provider from working (bug #40726)

Modified: branches/5.2/MySql.Data/Provider/Source/SchemaProvider.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/SchemaProvider.cs	2009-03-31 19:38:16 UTC (rev 1539)
+++ branches/5.2/MySql.Data/Provider/Source/SchemaProvider.cs	2009-03-31 19:39:41 UTC (rev 1540)
@@ -256,7 +256,14 @@
             dt.Columns.Add("UNIQUE", typeof (bool));
             dt.Columns.Add("PRIMARY", typeof (bool));
 
-            DataTable tables = GetTables(restrictions);
+            // Get the list of tables first
+            int max = restrictions == null ? 4 : restrictions.Length;
+            string[] tableRestrictions = new string[Math.Max(max, 4)];
+            if (restrictions != null)
+                restrictions.CopyTo(tableRestrictions, 0);
+            tableRestrictions[3] = "BASE TABLE";
+            DataTable tables = GetTables(tableRestrictions);
+
             foreach (DataRow table in tables.Rows)
             {
                 string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
@@ -295,8 +302,10 @@
             dt.Columns.Add("COLUMN_NAME", typeof (string));
             dt.Columns.Add("ORDINAL_POSITION", typeof (int));
 
-            string[] tableRestrictions = new string[Math.Max(restrictions.Length, 4)]; 
-            restrictions.CopyTo(tableRestrictions, 0);
+            int max = restrictions == null ? 4 : restrictions.Length;
+            string[] tableRestrictions = new string[Math.Max(max, 4)];
+            if (restrictions != null)
+                restrictions.CopyTo(tableRestrictions, 0);
             tableRestrictions[3] = "BASE TABLE";
             DataTable tables = GetTables(tableRestrictions);
 

Modified: branches/5.2/MySql.Data/Tests/Source/GetSchemaTests.cs
===================================================================
--- branches/5.2/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-03-31 19:38:16 UTC (rev 1539)
+++ branches/5.2/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-03-31 19:39:41 UTC (rev 1540)
@@ -335,6 +335,14 @@
 			Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
 			Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]);
 
+            restrictions[3] = "key2";
+            dt = conn.GetSchema("Indexes", restrictions);
+            Assert.AreEqual(1, dt.Rows.Count);
+            Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+            Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]);
+            Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
+            Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]);
+
 			execSQL("DROP TABLE IF EXISTS test");
 			execSQL("CREATE TABLE test (id int, name varchar(50), " +
 				"KEY key2 (name))");
@@ -372,6 +380,13 @@
 			Assert.AreEqual("id2", dt.Rows[0]["COLUMN_NAME"]);
 			Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]);
 
+            restrictions[3] = "key1";
+            dt = conn.GetSchema("IndexColumns", restrictions);
+            Assert.AreEqual(1, dt.Rows.Count);
+            Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+            Assert.AreEqual("id2", dt.Rows[0]["COLUMN_NAME"]);
+            Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]);
+
 			restrictions = new string[3];
 			restrictions[1] = database0;
 			restrictions[2] = "test";
@@ -383,8 +398,16 @@
 			Assert.AreEqual("test", dt.Rows[1]["TABLE_NAME"]);
 			Assert.AreEqual("id2", dt.Rows[1]["COLUMN_NAME"]);
 			Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]);
-		}
 
+            restrictions = new string[4];
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test (id int primary key, id1 int, KEY key1 (id1))");
+            restrictions[2] = "test";
+            restrictions[1] = database0;
+            restrictions[3] = "PRIMARY";
+            dt = conn.GetSchema("IndexColumns", restrictions);
+        }
+
 		[Test]
 		public void Views()
 		{

Thread
Connector/NET commit: r1540 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Sourcerburnett31 Mar