List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:October 6 2010 8:34pm
Subject:bzr commit into connector-net-6.0 branch (reggie.burnett:839) Bug#56756
View as plain text  
#At file:///C:/work/connector-net/6.0/ based on revid:reggie.burnett@stripped

  839 Reggie Burnett	2010-10-06
      - fixed problem with using bit parameters as output (bug #56756)

    modified:
      CHANGES
      MySql.Data/Provider/Source/StoredProcedure.cs
      MySql.Data/Provider/Source/Types/MySqlBit.cs
      MySql.Data/Tests/Source/StoredProcedure.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-08-26 13:17:07 +0000
+++ b/CHANGES	2010-10-06 20:34:20 +0000
@@ -1,3 +1,5 @@
+- fixed problem with using bit parameters as output (bug #56756)
+
 Version 6.0.7
 - Fix authorization popup after modifying stored procedure in VS (Bug #44715)
 - Dispose EventLog after use in MySql.Web.dll provider classes, to avoid wasting resources

=== modified file 'MySql.Data/Provider/Source/StoredProcedure.cs'
--- a/MySql.Data/Provider/Source/StoredProcedure.cs	2010-06-22 11:43:46 +0000
+++ b/MySql.Data/Provider/Source/StoredProcedure.cs	2010-10-06 20:34:20 +0000
@@ -277,7 +277,14 @@
                     string fieldName = reader.GetName(i);
                     fieldName = fieldName.Remove(0, ParameterPrefix.Length + 1);
                     MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true);
-                    reader.values[i] = MySqlField.GetIMySqlValue(parameter.MySqlDbType);
+                    IMySqlValue v = MySqlField.GetIMySqlValue(parameter.MySqlDbType);
+                    reader.values[i] = v;
+                    if (v is MySqlBit)
+                    {
+                        MySqlBit bit = (MySqlBit)v;
+                        bit.ReadAsString = true;
+                        reader.values[i] = bit;
+                    }
                 }
 
                 if (reader.Read())

=== modified file 'MySql.Data/Provider/Source/Types/MySqlBit.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlBit.cs	2010-02-26 21:18:30 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlBit.cs	2010-10-06 20:34:20 +0000
@@ -31,13 +31,21 @@
 	{
 		private ulong mValue;
 		private bool isNull;
+        private bool readAsString;
 
 		public MySqlBit(bool isnull)
 		{
 			mValue = 0;
 			isNull = isnull;
+            readAsString = false;
 		}
 
+        public bool ReadAsString
+        {
+            get { return readAsString; }
+            set { readAsString = value; }
+        }
+
 		public bool IsNull
 		{
 			get { return isNull; }
@@ -92,7 +100,10 @@
 			if (length == -1)
                 length = packet.ReadFieldLength();
 
-            mValue = (UInt64)packet.ReadBitValue((int)length);
+            if (ReadAsString)
+                mValue = UInt64.Parse(packet.ReadString(length));
+            else
+                mValue = (UInt64)packet.ReadBitValue((int)length);
 			return this;
 		}
 

=== modified file 'MySql.Data/Tests/Source/StoredProcedure.cs'
--- a/MySql.Data/Tests/Source/StoredProcedure.cs	2010-04-22 15:29:22 +0000
+++ b/MySql.Data/Tests/Source/StoredProcedure.cs	2010-10-06 20:34:20 +0000
@@ -1313,5 +1313,23 @@
                 cmd.ExecuteScalar();
             }
         }
+
+        /// <summary>
+        /// Bug #56756	Output Parameter MySqlDbType.Bit get a wrong Value (48/49 for false or true)
+        /// </summary>
+        [Test]
+        public void BitTypeAsOutParameter()
+        {
+            execSQL(@"CREATE PROCEDURE `spTest`(out x bit(1))
+                BEGIN
+                Set x = 1; -- Outparameter value is 49
+                Set x = 0; -- Outparameter value is 48
+                END");
+            MySqlCommand cmd = new MySqlCommand("spTest", conn);
+            cmd.CommandType = CommandType.StoredProcedure;
+            cmd.Parameters.Add("x", MySqlDbType.Bit).Direction = ParameterDirection.Output;
+            cmd.ExecuteNonQuery();
+            Assert.AreEqual(0, cmd.Parameters[0].Value);
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20101006203420-yjm1d7n8krz1ieq9.bundle
Thread
bzr commit into connector-net-6.0 branch (reggie.burnett:839) Bug#56756Reggie Burnett6 Oct