From: Daniel Vrátil Date: Sat, 1 Dec 2018 16:56:41 +0000 (+0100) Subject: MySQL: Free the results when QSqlQuery::finished() is called X-Git-Tag: archive/raspbian/5.11.3+dfsg1-1+rpi1^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9857fd784375b340e18884463d709bf357bbedc8;p=qtbase-opensource-src.git MySQL: Free the results when QSqlQuery::finished() is called Calling mysql_stmt_free_result() frees the results of the last executed query while keeping the prepared statement valid. This allows one to keep around prepared QSqlQueries without the overhead of keeping all the results in memory. Change-Id: I4589e90857cc4e9a6f9612799bfca967a67e2ab2 Reviewed-by: Thiago Macieira Reviewed-by: Andy Shaw Gbp-Pq: Name mysql_free_results_when_qsqlquery_finished_is_called.patch --- diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 49bceb88a..82fbe3764 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -193,6 +193,7 @@ protected: QSqlRecord record() const override; void virtual_hook(int id, void *data) override; bool nextResult() override; + void detachFromResultSet() override; #if MYSQL_VERSION_ID >= 40108 bool prepare(const QString &stmt) override; @@ -798,6 +799,15 @@ int QMYSQLResult::numRowsAffected() return d->rowsAffected; } +void QMYSQLResult::detachFromResultSet() +{ + Q_D(QMYSQLResult); + + if (d->preparedQuery) { + mysql_stmt_free_result(d->stmt); + } +} + QVariant QMYSQLResult::lastInsertId() const { Q_D(const QMYSQLResult);