--- a/src/sql/drivers/mysql/qsql_mysql.cpp Mon Mar 15 12:43:09 2010 +0200
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp Thu Apr 08 14:19:33 2010 +0300
@@ -320,6 +320,16 @@
|| t == MYSQL_TYPE_LONG_BLOB;
}
+static bool qIsInteger(int t)
+{
+ return t == MYSQL_TYPE_TINY
+ || t == MYSQL_TYPE_SHORT
+ || t == MYSQL_TYPE_LONG
+ || t == MYSQL_TYPE_LONGLONG
+ || t == MYSQL_TYPE_INT24;
+}
+
+
void QMYSQLResultPrivate::bindBlobs()
{
int i;
@@ -368,6 +378,13 @@
fieldInfo->length = 0;
hasBlobs = true;
} else {
+ // fieldInfo->length specifies the display width, which may be too
+ // small to hold valid integer values (see
+ // http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ), so
+ // always use the MAX_BIGINT_WIDTH for integer types
+ if (qIsInteger(fieldInfo->type)) {
+ fieldInfo->length = MAX_BIGINT_WIDTH;
+ }
fieldInfo->type = MYSQL_TYPE_STRING;
}
bind = &inBinds[i];