Bug #49794 MySqlDataReader.GetUInt64 doesn't work for large BIGINT UNSIGNED
Submitted: 18 Dec 2009 3:46 Modified: 15 Jan 2010 10:34
Reporter: Marcus Lo Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.1.3 OS:Microsoft Windows
Assigned to: Tony Bedford CPU Architecture:Any

[18 Dec 2009 3:46] Marcus Lo
Description:
MySqlDataReader.GetUInt64 gets a wrong value in BIGINT UNSIGNED column when the value is larger than 2147483647.

How to repeat:
MySQL Server:

CREATE TABLE Test.TestTable (
  Id int(10) unsigned NOT NULL,
  TestValue bigint(20) unsigned NOT NULL,
  PRIMARY KEY  USING BTREE (Id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO Test.TestTable(Id,TestValue) VALUES(1, 3000000000);

C# program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {

            MySqlConnection conn = new MySqlConnection("Server=TestSvr;" +
                                       "User ID=TestUser;" +
                                       "Password=TestPassword;" +
                                       "Convert Zero Datetime=true;" +
                                       "Ignore Prepare=false;" +
                                       "Pooling=false");
            conn.Open();

            MySqlCommand cmd = new MySqlCommand("SELECT TestValue " +
                                                "FROM Test.TestTable " +
                                                "WHERE Id=@Id", conn);
            cmd.Parameters.Add("@Id", MySqlDbType.UInt32);
            cmd.Prepare();

            cmd.Parameters["@Id"].Value = 1;
            using (MySqlDataReader rdr = cmd.ExecuteReader()) {

                while (rdr.Read()) {
                    System.Console.WriteLine(rdr.GetUInt64(0));
                }
            }
        }
    }
}
[8 Jan 2010 23:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/96456

782 Reggie Burnett	2010-01-08
      - fixed a bug with prepared statements and unsigned bigint.  Patch also provided a nice speedup to reading
        integer values from the wire (bug #49794)
[8 Jan 2010 23:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/96459

799 Reggie Burnett	2010-01-08 [merge]
      fixed a bug with prepared statements and unsigned bigint.  Patch also provided a nice speedup to reading
        integer values from the wire (bug #49794)
[8 Jan 2010 23:12] Reggie Burnett
fixed in 6.0.6, 6.1.4, and 6.2.3
[15 Jan 2010 10:34] Tony Bedford
An entry has been added to the 6.0.6, 6.1.4, 6.2.3 changelogs:

MySqlDataReader.GetUInt64 returned an incorrect value when reading a BIGINT UNSIGNED column containing a value greater than 2147483647