List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:June 22 2011 12:47am
Subject:Re: Unsigned 64-bit Issue
View as plain text  
Some quotes come from the SO post, since it contains more detail.

Answering here instead of there because I do not yet have "the answer".

On 6/21/2011 4:12 PM, Benjamin Johnson wrote:
> host_guid value...unsigned __int64,

Why are you calling a 64-bit value a GUID?  GUIDs are 128 bits.

> a win32 c++ app

Do you mean a Win64 app?

Or is it the case that you are building 32-bit binaries and are relying 
on MS's compiler to give you non-native 64-bit integer support?

> if I dump the mysql database, move it over to windows 7 and run the
> same binary that reads the database, it works great.

I don't quite see how that can be the case with a statically-compiled, 
statically-typed language like C++.  It is true that MySQL++ essentially 
adds a dynamic typing system to your program, but once you compile code 
like you show, the types get fixed in stone.

The only guess I have is that the C++ RTL is different, and you're 
linking against a copy MS ships with the OS, and it is different between 
the two OSes.  The way to test this is to statically link your program. 
  (/MT, rather than /MD.)

> I'm including the code that reproduces it.

Thanks, but I for one do not have a Windows 2008 server sitting around.

>      mysqlpp::Query query = conn.query();
>      query<<  "select 15216036968564760613 as host_guid";

Do you get the same behavior if you select the data from an actual 
database, so that the code has type info from the MySQL server to work 
with?  I tried it on a 64-bit Linux box, and it works fine here:

Index: examples/stock.h
===================================================================
--- examples/stock.h    (revision 2692)
+++ examples/stock.h    (working copy)
@@ -39,7 +39,7 @@
  sql_create_6(stock,
     1, 6, // The meaning of these values is covered in the user manual
     mysqlpp::sql_char, item,
-   mysqlpp::sql_bigint, num,
+   mysqlpp::sql_bigint_unsigned, num,
     mysqlpp::sql_double, weight,
     mysqlpp::sql_double_null, price,
     mysqlpp::sql_date, sDate,           // SSQLS isn't case-sensitive!
Index: examples/resetdb.cpp
===================================================================
--- examples/resetdb.cpp    (revision 2692)
+++ examples/resetdb.cpp    (working copy)
@@ -135,7 +135,7 @@
         query <<
                 "CREATE TABLE stock (" <<
                 "  item CHAR(30) NOT NULL, " <<
-               "  num BIGINT NOT NULL, " <<
+               "  num BIGINT UNSIGNED NOT NULL, " <<
                 "  weight DOUBLE NOT NULL, " <<
                 "  price DECIMAL(6,2) NULL, " << // NaN & inf. == NULL
                 "  sdate DATE NOT NULL, " <<
@@ -165,7 +165,10 @@
         query.execute("Pickle Relish", 87, 1.5, 1.75, "1998-09-04");
         query.execute("Hot Mustard", 73, .95, .97, "1998-05-25",
                 "good American yellow mustard, not that European stuff");
-       query.execute("Hotdog Buns", 65, 1.1, 1.1, "1998-04-23");
+       query.execute("Hotdog Buns",
+               mysqlpp::sql_bigint_unsigned(15216036968564760613ULL),
+               1.1, 1.1, "1998-04-23");
+       cout << "SIZEOF: " << sizeof(mysqlpp::sql_bigint_unsigned) <<
endl;

         // Test that above did what we wanted.
         cout << "inserted " << con.count_rows("stock") << " rows."
<< endl;
Thread
Unsigned 64-bit IssueBenjamin Johnson22 Jun
  • Re: Unsigned 64-bit IssueWarren Young22 Jun
    • Re: Unsigned 64-bit IssueBenjamin Johnson22 Jun
      • Re: Unsigned 64-bit IssueBenjamin Johnson22 Jun
        • Re: Unsigned 64-bit IssueWarren Young22 Jun