List:Commits« Previous MessageNext Message »
From:rburnett Date:May 2 2007 10:59pm
Subject:Connector/NET commit: r702 - in trunk: Driver/Source TestSuite/Source
View as plain text  
Modified:
   trunk/Driver/Source/StoredProcedure.cs
   trunk/TestSuite/Source/StoredProcedure.cs
Log:
Bug #27668  	FillSchema and Stored Proc with an out parameter
Fixed this by only attempting to set the value of output parameters if the read was
successful.  If the read is not successful, then the reason is that the user requested
SchemaOnly command behavior.

Modified: trunk/Driver/Source/StoredProcedure.cs
===================================================================
--- trunk/Driver/Source/StoredProcedure.cs	2007-05-02 20:54:10 UTC (rev 701)
+++ trunk/Driver/Source/StoredProcedure.cs	2007-05-02 20:59:46 UTC (rev 702)
@@ -208,14 +208,16 @@
                 reader.values[i] =
MySqlField.GetIMySqlValue(Parameters[fieldName].MySqlDbType);
             }
 
-            reader.Read();
-            for (int i = 0; i < reader.FieldCount; i++)
+            if (reader.Read())
             {
-                string fieldName = reader.GetName(i);
-                fieldName = marker + fieldName.Remove(0, hash.Length + 1);
-                Parameters[fieldName].Value = reader.GetValue(i);
+                for (int i = 0; i < reader.FieldCount; i++)
+                {
+                    string fieldName = reader.GetName(i);
+                    fieldName = marker + fieldName.Remove(0, hash.Length + 1);
+                    Parameters[fieldName].Value = reader.GetValue(i);
+                }
             }
-            reader.Close();
-        }
-    }
-}
\ No newline at end of file
+		    reader.Close();
+		}
+	}
+}

Modified: trunk/TestSuite/Source/StoredProcedure.cs
===================================================================
--- trunk/TestSuite/Source/StoredProcedure.cs	2007-05-02 20:54:10 UTC (rev 701)
+++ trunk/TestSuite/Source/StoredProcedure.cs	2007-05-02 20:59:46 UTC (rev 702)
@@ -551,7 +551,7 @@
 			cmd.CommandType = CommandType.StoredProcedure;
 			object val = cmd.ExecuteScalar();
 			Assert.AreEqual(1, val, "Checking value");
-			Assert.IsTrue(val is System.Int32, "Checking type");
+			Assert.IsTrue(val is Int32, "Checking type");
 		}
 */
 		/// <summary>
@@ -910,7 +910,7 @@
             execSQL("CREATE PROCEDURE spTest(p int) BEGIN SELECT p; END");
 			MySqlParameter param1;
 			MySqlCommand command = new MySqlCommand("spTest", conn);
-			command.CommandType = System.Data.CommandType.StoredProcedure;
+			command.CommandType = CommandType.StoredProcedure;
 
 			param1 = command.Parameters.Add("?p", MySqlDbType.Int32);
 			param1.Value = 3;
@@ -1163,6 +1163,7 @@
 
         /// <summary>
         /// Bug #25609 MySqlDataAdapter.FillSchema 
+        /// Bug #27668  	FillSchema and Stored Proc with an out parameter
         /// </summary>
         [Test]
         public void GetSchema()
@@ -1184,6 +1185,23 @@
                 DataTable schema = new DataTable();
                 da.FillSchema(schema, SchemaType.Source);
                 Assert.AreEqual(2, schema.Columns.Count);
+
+                //Bug #27668  	FillSchema and Stored Proc with an out parameter
+                execSQL("DROP TABLE IF EXISTS test");
+                execSQL(@"CREATE TABLE test(id INT AUTO_INCREMENT, PRIMARY KEY (id)) ");
+                execSQL("DROP PROCEDURE IF EXISTS spTest");
+                execSQL(@"CREATE PROCEDURE spTest (OUT id INT)
+                    BEGIN INSERT INTO test VALUES (NULL); SET id=520; END");
+
+                cmd = new MySqlCommand("spTest", conn);
+                cmd.CommandType = CommandType.StoredProcedure;
+                cmd.Parameters.Add("?id", MySqlDbType.Int32);
+                cmd.Parameters[0].Direction = ParameterDirection.Output;
+                da = new MySqlDataAdapter(cmd);
+                DataTable dt = new DataTable();
+                cmd.ExecuteNonQuery();
+                da.Fill(dt);
+                da.FillSchema(dt, SchemaType.Mapped);
             }
             catch (Exception ex)
             {
@@ -1298,7 +1316,7 @@
             execSQL(@"CREATE PROCEDURE spTest(in _val bigint unsigned)
                       BEGIN insert into  test set f1=_val; END");
 
-            DbCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
+            DbCommand cmd = new MySqlCommand();
             cmd.Connection = conn;
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "spTest";

Thread
Connector/NET commit: r702 - in trunk: Driver/Source TestSuite/Sourcerburnett2 May