equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtSql module of the Qt Toolkit. |
7 ** This file is part of the QtSql module of the Qt Toolkit. |
8 ** |
8 ** |
318 || t == MYSQL_TYPE_BLOB |
318 || t == MYSQL_TYPE_BLOB |
319 || t == MYSQL_TYPE_MEDIUM_BLOB |
319 || t == MYSQL_TYPE_MEDIUM_BLOB |
320 || t == MYSQL_TYPE_LONG_BLOB; |
320 || t == MYSQL_TYPE_LONG_BLOB; |
321 } |
321 } |
322 |
322 |
|
323 static bool qIsInteger(int t) |
|
324 { |
|
325 return t == MYSQL_TYPE_TINY |
|
326 || t == MYSQL_TYPE_SHORT |
|
327 || t == MYSQL_TYPE_LONG |
|
328 || t == MYSQL_TYPE_LONGLONG |
|
329 || t == MYSQL_TYPE_INT24; |
|
330 } |
|
331 |
|
332 |
323 void QMYSQLResultPrivate::bindBlobs() |
333 void QMYSQLResultPrivate::bindBlobs() |
324 { |
334 { |
325 int i; |
335 int i; |
326 MYSQL_FIELD *fieldInfo; |
336 MYSQL_FIELD *fieldInfo; |
327 MYSQL_BIND *bind; |
337 MYSQL_BIND *bind; |
366 // mysql_stmt_store_result() |
376 // mysql_stmt_store_result() |
367 // after mysql_stmt_exec() in QMYSQLResult::exec() |
377 // after mysql_stmt_exec() in QMYSQLResult::exec() |
368 fieldInfo->length = 0; |
378 fieldInfo->length = 0; |
369 hasBlobs = true; |
379 hasBlobs = true; |
370 } else { |
380 } else { |
|
381 // fieldInfo->length specifies the display width, which may be too |
|
382 // small to hold valid integer values (see |
|
383 // http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ), so |
|
384 // always use the MAX_BIGINT_WIDTH for integer types |
|
385 if (qIsInteger(fieldInfo->type)) { |
|
386 fieldInfo->length = MAX_BIGINT_WIDTH; |
|
387 } |
371 fieldInfo->type = MYSQL_TYPE_STRING; |
388 fieldInfo->type = MYSQL_TYPE_STRING; |
372 } |
389 } |
373 bind = &inBinds[i]; |
390 bind = &inBinds[i]; |
374 field = new char[fieldInfo->length + 1]; |
391 field = new char[fieldInfo->length + 1]; |
375 memset(field, 0, fieldInfo->length + 1); |
392 memset(field, 0, fieldInfo->length + 1); |