List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:December 9 2009 3:08pm
Subject:bzr commit into connector-net-trunk branch (reggie.burnett:813)
Bug#48171
View as plain text  
#At file:///C:/bzr-connector-net/6.2/ based on revid:reggie.burnett@stripped

  813 Reggie Burnett	2009-12-09 [merge]
      Fixed precision calculation on decimal and newdecimal columns (bug #48171)

    modified:
      CHANGES
      MySql.Data/Provider/Source/NativeDriver.cs
      MySql.Data/Tests/Source/DataTypeTests.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2009-11-30 15:33:37 +0000
+++ b/CHANGES	2009-12-09 15:08:49 +0000
@@ -1,5 +1,6 @@
 - When sending file to server (LOAD DATA INFILE) open the file for read only, not for read/write
  (bug #48944)
+- Fixed precision calculation on decimal and newdecimal columns (bug #48171)
 
 Version 6.2.1
 - fixed SessionProvider to be compatible with 4.x MySQL, replaced TIMESTAMPDIFF with TIME_TO_SEC

=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
--- a/MySql.Data/Provider/Source/NativeDriver.cs	2009-12-03 20:33:11 +0000
+++ b/MySql.Data/Provider/Source/NativeDriver.cs	2009-12-09 15:08:49 +0000
@@ -690,10 +690,19 @@
             else
                 colFlags = (ColumnFlags)packet.ReadByte();
             field.Scale = (byte)packet.ReadByte();
+
             if (packet.HasMoreData)
             {
                 packet.ReadInteger(2); // reserved
             }
+
+            if (type == MySqlDbType.Decimal || type == MySqlDbType.NewDecimal)
+            {
+                field.Precision = (byte)(field.ColumnLength - (int)field.Scale);
+                if ((colFlags & ColumnFlags.UNSIGNED) != 0)
+                    field.Precision++;
+            }
+
             field.SetTypeAndFlags(type, colFlags);
         }
 

=== modified file 'MySql.Data/Tests/Source/DataTypeTests.cs'
--- a/MySql.Data/Tests/Source/DataTypeTests.cs	2009-11-11 17:41:52 +0000
+++ b/MySql.Data/Tests/Source/DataTypeTests.cs	2009-12-09 15:08:49 +0000
@@ -23,6 +23,7 @@
 using MySql.Data.Types;
 using System.Data;
 using NUnit.Framework;
+using System.Data.Common;
 
 namespace MySql.Data.MySqlClient.Tests
 {
@@ -1035,5 +1036,27 @@
                 }
             }
         }
+
+        /// <summary>
+        /// Bug #48171	MySqlDataReader.GetSchemaTable() returns 0 in "NumericPrecision" for newdecimal
+        /// </summary>
+        [Test]
+        public void DecimalPrecision()
+        {
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test(a decimal(35,2), b decimal(36,2), c decimal(36,2) unsigned)");
+
+            MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                DataTable dt = reader.GetSchemaTable();
+                DataRow columnDefinition = dt.Rows[0];
+                Assert.AreEqual(35, columnDefinition[SchemaTableColumn.NumericPrecision]);
+                columnDefinition = dt.Rows[1];
+                Assert.AreEqual(36, columnDefinition[SchemaTableColumn.NumericPrecision]);
+                columnDefinition = dt.Rows[2];
+                Assert.AreEqual(36, columnDefinition[SchemaTableColumn.NumericPrecision]);
+            }
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20091209150849-qooe6cgwoesek0fa.bundle
Thread
bzr commit into connector-net-trunk branch (reggie.burnett:813)Bug#48171Reggie Burnett9 Dec