Hello,
I'm in the process of updating some old code from MySQL++ 2.1.1 to 3.2.4. Using MySQL++ 2.1.1 I had some code that looked something like:
query << "INSERT INTO mytable SET ";
query << "order_number='" << escape << order_number << "', ";
query << "line_number='" << escape << results.insert_id << "', ";
which worked fine for many years. In MySQL++ 3.2.4 the insert_id changed to a function so I changed the code to:
query << "INSERT INTO mytable SET ";
query << "order_number='" << escape << order_number << "', ";
query << "line_number='" << escape << results.insert_id() << "', ";
but upon running my program, when the query goes to execute this error occurs:
Error: Failed to find MySQL C API type ID for y
So then I tried casting to an unsigned long like:
query << "INSERT INTO mytable SET ";
query << "order_number='" << escape << order_number << "', ";
query << "line_number='" << escape << (unsigned long)results.insert_id() << "', ";
and the code ran fine!
Digging into the code further, I see that insert_id() is returning a ulonglong so I tried to explicitly cast to that in case something weird was going on:
query << "line_number='" << escape << (ulonglong)results.insert_id() << "', ";
and that caused the same error as before:
Error: Failed to find MySQL C API type ID for y
I also tried:
query << "line_number='" << escape << (unsigned long long)results.insert_id() << "', ";
and that gives the same error.
I'm not familiar with the actual MySQL C API but it seems to me like perhaps it is not liking this unsigned long long data type.
I see in MySQL++ 2.1.1 insert_id was defined as "my_ulonglong" which is an actual datatype found in mysql.h, but this was changed. Could the issue be a mismatch between ulonglong and my_ulonglong since these are typedef'ed differently with the #ifdef logic in the corresponding h files? Like maybe my_ulonglong is defined as an unsigned long on my system but ulonglong is being defined as an unsigned long long?
For further information, this is a 64-bit system running Debian 8, g++ 4.9.2. Thanks and let me know if you need me to look up any more info.