Date: Tuesday, February 21, 2006 @ 11:04:24
  Author: zsolt
    Path: /cvsroot/carob/libmysequoia/src

Modified: CarobStmt.cpp (1.22 -> 1.23)

Because MySQL JDBC client will convert unsigned type to a bigger type, we need 
to use getAsXXX and not getXXX when fetching values. This is safe.


---------------+
 CarobStmt.cpp |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)


Index: libmysequoia/src/CarobStmt.cpp
diff -u libmysequoia/src/CarobStmt.cpp:1.22 libmysequoia/src/CarobStmt.cpp:1.23
--- libmysequoia/src/CarobStmt.cpp:1.22 Mon Feb 13 13:45:20 2006
+++ libmysequoia/src/CarobStmt.cpp      Tue Feb 21 11:04:24 2006
@@ -400,6 +400,7 @@
           fPtr->max_length = 0;
           break;
         default:
+          LOG4CXX_ERROR(logger, "bind_result: unsupported type pno=" << no << 
" type=" << p->buffer_type);
           set_error(CR_UNSUPPORTED_PARAM_TYPE, SQLT_UNKNOWN);
           result = true;
       }
@@ -731,10 +732,14 @@
         result = new short(liveResultSet->getInt32(colNo));
         break;
       case MYSQL_TYPE_LONG:
-        result = new int(liveResultSet->getInt32(colNo));
+        //we need to use getAsInt and not getInt32 because mysql java client 
will convert the
+        //unsigned integer to long
+        result = new int(liveResultSet->getAsInt(colNo));
         break;
       case MYSQL_TYPE_LONGLONG:
-        result = new int64_t(liveResultSet->getInt64(colNo));
+        //we need to use getAsInt64 and not getInt64 because mysql java client 
will convert the
+        //unsigned long to bigint
+        result = new int64_t(liveResultSet->getAsInt64(colNo));
         break;
       case MYSQL_TYPE_FLOAT:
         result = new float(liveResultSet->getFloat(colNo));
@@ -774,7 +779,11 @@
   catch (NullValueException)
   {
   }
-  
+  catch (CarobException &e)
+  {
+    set_error(e.getErrorCode(), toString(e.description()).c_str(), 
toString(e.getSQLState()).c_str());
+  }
+        
   LOG4CXX_DEBUG(logger, "Leaving alloc_fetch_field: result=" << result);
   return result;
 }

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to