summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/mysql
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2018-12-01 17:56:41 +0100
committerDaniel Vrátil <dvratil@kde.org>2018-12-06 09:33:45 +0000
commit97d8be10cd97cf997286ed0ca0a5d8b360fa942e (patch)
tree4a2c187876144e5ff03cf97a6ae11057e590a1ff /src/plugins/sqldrivers/mysql
parent19863922558987136c320a08f46e3c3239094b7c (diff)
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 to keep around prepared QSqlQueries without the overhead of keeping all the results in memory. Change-Id: I4589e90857cc4e9a6f9612799bfca967a67e2ab2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/mysql')
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index f2ae3fbc47..80c0c9c522 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -197,6 +197,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;
@@ -804,6 +805,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);