SQL/PSQL: call deallocatePreparedStmt() unconditionally

deallocatePreparedStmt() knows by itself when to call the psql cleanup
routines or not. No need to have this logic outside this function.

Task-number: QTBUG-132303
Change-Id: Ib1a5ba7b53c156f6a6b93f23a3ec8c851d7398fc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Thierry Bastian <thierryb@filewave.com>
(cherry picked from commit 9094ad18b0d909f7490dec3451ec7ef9c312f42a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2025-01-19 17:35:21 +01:00 committed by Qt Cherry-pick Bot
parent 7782f2ad14
commit 0f744e6b2b

View File

@ -382,7 +382,7 @@ static QMetaType qDecodePSQLType(int t)
void QPSQLResultPrivate::deallocatePreparedStmt()
{
if (drv_d_func()) {
if (drv_d_func() && !preparedStmtId.isEmpty()) {
#if defined(LIBPQ_HAS_CLOSE_PREPARED)
PGresult *result = PQclosePrepared(drv_d_func()->connection, preparedStmtId.toUtf8());
#else
@ -411,8 +411,7 @@ QPSQLResult::~QPSQLResult()
Q_D(QPSQLResult);
cleanup();
if (d->preparedQueriesEnabled && !d->preparedStmtId.isNull())
d->deallocatePreparedStmt();
d->deallocatePreparedStmt();
}
QVariant QPSQLResult::handle() const
@ -855,8 +854,7 @@ bool QPSQLResult::prepare(const QString &query)
cleanup();
if (!d->preparedStmtId.isEmpty())
d->deallocatePreparedStmt();
d->deallocatePreparedStmt();
const QString stmtId = qMakePreparedStmtId();
PGresult *result = PQprepare(d->drv_d_func()->connection, stmtId.toUtf8(),