summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-23 03:41:06 (GMT)
committerDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-23 03:41:06 (GMT)
commit1ce247ec7c2b4bda79cedf5dda2e6b1f636903b1 (patch)
tree725ed03f4df3603f70fd536c6d2cb6ef77ee25b2
parent0cadaf8932355d1fc9cc560d405a3915aeac7d5a (diff)
downloadQt-1ce247ec7c2b4bda79cedf5dda2e6b1f636903b1.zip
Qt-1ce247ec7c2b4bda79cedf5dda2e6b1f636903b1.tar.gz
Qt-1ce247ec7c2b4bda79cedf5dda2e6b1f636903b1.tar.bz2
Handle errors and data truncation in QMYSQLResult::fetchNext()
Add additional error handling Task-number:QTBUG-5758 Reviewed-by: trustme
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index f368d1d..b74babc 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -509,15 +509,24 @@ bool QMYSQLResult::fetchNext()
return false;
if (d->preparedQuery) {
#if MYSQL_VERSION_ID >= 40108
- if (mysql_stmt_fetch(d->stmt))
+ int nRC = mysql_stmt_fetch(d->stmt);
+ if (nRC) {
+#ifdef MYSQL_DATA_TRUNCATED
+ if (nRC == 1 || nRC == MYSQL_DATA_TRUNCATED)
+#else
+ if (nRC == 1)
+#endif // MYSQL_DATA_TRUNCATED
+ setLastError(qMakeStmtError(QCoreApplication::translate("QMYSQLResult",
+ "Unable to fetch data"), QSqlError::StatementError, d->stmt));
return false;
+ }
#else
return false;
#endif
} else {
- d->row = mysql_fetch_row(d->result);
- if (!d->row)
- return false;
+ d->row = mysql_fetch_row(d->result);
+ if (!d->row)
+ return false;
}
setAt(at() + 1);
return true;
@@ -1365,7 +1374,6 @@ QStringList QMYSQLDriver::tables(QSql::TableType type) const
QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
{
QSqlIndex idx;
- bool prepQ;
if (!isOpen())
return idx;