Skip to content

Commit

Permalink
drivers optimized cleanup before query execution
Browse files Browse the repository at this point in the history
Don't cleanup on the newly created instance.
  • Loading branch information
silverqx committed Jul 26, 2024
1 parent 709ac28 commit eba4977
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/common/include_private/orm/drivers/sqlresult_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ namespace Orm::Drivers
bool isActive = false;
/*! Is this result from the SELECT statement? */
bool isSelect = false;
/*! Determine if the instance needs cleanup before executing the query. It's
always true after the first query is executed. */
bool needsCleanup = false;
};

} // namespace Orm::Drivers
Expand Down
14 changes: 14 additions & 0 deletions drivers/mysql/src/orm/drivers/mysql/mysqlresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ void MySqlResult::cleanupForNormal()
{
Q_D(MySqlResult);

/* Helps to avoid cleanup on the newly created instance, it's only false on the newly
created instance. */
if (!d->needsCleanup) {
d->needsCleanup = true;
return;
}

d->recordCache.clear();

// Normal queries
Expand All @@ -540,6 +547,13 @@ void MySqlResult::cleanupForPrepared()
{
Q_D(MySqlResult);

/* Helps to avoid cleanup on the newly created instance, it's only false on the newly
created instance. */
if (!d->needsCleanup) {
d->needsCleanup = true;
return;
}

d->recordCache.clear();

// Prepared queries
Expand Down

0 comments on commit eba4977

Please sign in to comment.