List:Commits« Previous MessageNext Message »
From:rburnett Date:May 19 2006 5:56pm
Subject:Connector/NET commit: r238 - in branches/1.0: . TestSuite mysqlclient
View as plain text  
Modified:
   branches/1.0/CHANGES
   branches/1.0/MySql.Data.csproj
   branches/1.0/TestSuite/DataTypeTests.cs
   branches/1.0/TestSuite/MySql.Data.Tests.csproj
   branches/1.0/TestSuite/PreparedStatements.cs
   branches/1.0/mysqlclient/parameter.cs
Log:
Bug #16934 Unsigned values > 2^63 (UInt64) cannot be used in prepared statements

The problem here is that we were not sending the proper type codes when using unsigned
values.
This is fixed by fixing the GetPSType() method to return the write type code with the
unsigned bit enabled.


Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/CHANGES	2006-05-19 15:56:33 UTC (rev 238)
@@ -7,6 +7,7 @@
     Bug #19261 Supplying Input Parameters [fixed]
     Bug #19481 Where clause with datetime throws exception [any warning causes the
exception] [fixed]
     Bug #15077 Error MySqlCommandBuilder.DeriveParameters for sp without parameters.
[fixed]
+    Bug #16934 Unsigned values > 2^63 (UInt64) cannot be used in prepared statements
     
 x-xx-05 - Version 1.0.7
 

Modified: branches/1.0/MySql.Data.csproj
===================================================================
--- branches/1.0/MySql.Data.csproj	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/MySql.Data.csproj	2006-05-19 15:56:33 UTC (rev 238)
@@ -28,7 +28,7 @@
     </UpgradeBackupLocation>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <OutputPath>bin\net-1.1\Debug\</OutputPath>
+    <OutputPath>bin\net-2.0\Debug\</OutputPath>
     <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <BaseAddress>285212672</BaseAddress>
     <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
@@ -50,7 +50,7 @@
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <OutputPath>bin\net-1.1\Release\</OutputPath>
+    <OutputPath>bin\net-2.0\Release\</OutputPath>
     <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <BaseAddress>285212672</BaseAddress>
     <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>

Modified: branches/1.0/TestSuite/DataTypeTests.cs
===================================================================
--- branches/1.0/TestSuite/DataTypeTests.cs	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/TestSuite/DataTypeTests.cs	2006-05-19 15:56:33 UTC (rev 238)
@@ -1,21 +1,21 @@
-// Copyright (C) 2004-2005 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL 
-// as it is applied to this software. View the full text of the 
-// exception in file EXCEPTIONS in the directory of this software 
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL 
+// as it is applied to this software. View the full text of the 
+// exception in file EXCEPTIONS in the directory of this software 
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
 using System;

Modified: branches/1.0/TestSuite/MySql.Data.Tests.csproj
===================================================================
--- branches/1.0/TestSuite/MySql.Data.Tests.csproj	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/TestSuite/MySql.Data.Tests.csproj	2006-05-19 15:56:33 UTC (rev 238)
@@ -75,9 +75,9 @@
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="MySql.Data">
-      <Name>MySQL.Data</Name>
-      <HintPath>..\bin\net-1.1\Debug\MySQL.Data.dll</HintPath>
+    <Reference Include="MySql.Data, Version=1.0.7.17581, Culture=neutral,
processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\net-2.0\Debug\MySql.Data.dll</HintPath>
     </Reference>
     <Reference Include="nunit.framework">
       <Name>nunit.framework</Name>

Modified: branches/1.0/TestSuite/PreparedStatements.cs
===================================================================
--- branches/1.0/TestSuite/PreparedStatements.cs	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/TestSuite/PreparedStatements.cs	2006-05-19 15:56:33 UTC (rev 238)
@@ -618,5 +618,51 @@
             count = command.ExecuteScalar();
             Assert.AreEqual(1, count);
         }
+
+        /// <summary>
+        /// Bug #16934 Unsigned values > 2^63 (UInt64) cannot be used in prepared
statements
+        /// </summary>
+        [Test]
+        [Category("4.1")]
+        public void UnsignedValues()
+        {
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test (ulVal BIGINT UNSIGNED, lVal INT UNSIGNED, " +
+                "mVal MEDIUMINT UNSIGNED, sVal SMALLINT UNSIGNED)");
+
+            MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (?ulVal, " +
+                "?lVal, ?mVal, ?sVal)", conn);
+            cmd.Parameters.Add("?ulVal", MySqlDbType.UInt64);
+            cmd.Parameters.Add("?lVal", MySqlDbType.UInt32);
+            cmd.Parameters.Add("?mVal", MySqlDbType.UInt32);
+            cmd.Parameters.Add("?sVal", MySqlDbType.UInt16);
+            cmd.Prepare();
+            cmd.Parameters[0].Value = UInt64.MaxValue;
+            cmd.Parameters[1].Value = UInt32.MaxValue;
+            cmd.Parameters[2].Value = 16777215;
+            cmd.Parameters[3].Value = UInt16.MaxValue;
+            Assert.AreEqual(1, cmd.ExecuteNonQuery());
+            cmd.CommandText = "SELECT * FROM test";
+            cmd.CommandType = CommandType.Text;
+            MySqlDataReader reader = null;
+            try
+            {
+                reader = cmd.ExecuteReader();
+                reader.Read();
+                Assert.AreEqual(UInt64.MaxValue, reader.GetUInt64(0));
+                Assert.AreEqual(UInt32.MaxValue, reader.GetUInt32(1));
+                Assert.AreEqual(16777215, reader.GetUInt32(2));
+                Assert.AreEqual(UInt16.MaxValue, reader.GetUInt16(3));
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail(ex.Message);
+            }
+            finally
+            {
+                if (reader != null)
+                    reader.Close();
+            }
+        }
 	}
 }

Modified: branches/1.0/mysqlclient/parameter.cs
===================================================================
--- branches/1.0/mysqlclient/parameter.cs	2006-05-19 13:40:34 UTC (rev 237)
+++ branches/1.0/mysqlclient/parameter.cs	2006-05-19 15:56:33 UTC (rev 238)
@@ -304,12 +304,23 @@
 
 		internal int GetPSType()
 		{
-            if (this.mySqlDbType == MySqlDbType.Bit)
-                return (int)MySqlDbType.Int64 | 0x8000;
-            else if (this.mySqlDbType == MySqlDbType.UByte)
-                return (int)MySqlDbType.Byte | 0x8000;
-            else
-				return (int)this.mySqlDbType;
+            switch (mySqlDbType)
+            {
+                case MySqlDbType.Bit:
+                    return (int)MySqlDbType.Int64 | 0x8000;
+                case MySqlDbType.UByte:
+                    return (int)MySqlDbType.Byte | 0x8000;
+                case MySqlDbType.UInt64:
+                    return (int)MySqlDbType.Int64 | 0x8000;
+                case MySqlDbType.UInt32:
+                    return (int)MySqlDbType.Int32 | 0x8000;
+                case MySqlDbType.UInt24:
+                    return (int)MySqlDbType.Int64 | 0x8000;
+                case MySqlDbType.UInt16:
+                    return (int)MySqlDbType.Int16 | 0x8000;
+                default:
+                    return (int)this.mySqlDbType;
+            }
 		}
 
 		internal void Serialize( PacketWriter writer, bool binary ) 

Thread
Connector/NET commit: r238 - in branches/1.0: . TestSuite mysqlclientrburnett19 May