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.

Pick-to: 6.9
Task-number: QTBUG-132303
Change-Id: Ib1a5ba7b53c156f6a6b93f23a3ec8c851d7398fc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Thierry Bastian <thierryb@filewave.com>
This commit is contained in:
Christian Ehrlicher 2025-01-19 17:35:21 +01:00
parent 0e4f9ffa55
commit 9094ad18b0

View File

@ -387,7 +387,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
@ -416,8 +416,7 @@ QPSQLResult::~QPSQLResult()
Q_D(QPSQLResult);
cleanup();
if (d->preparedQueriesEnabled && !d->preparedStmtId.isNull())
d->deallocatePreparedStmt();
d->deallocatePreparedStmt();
}
QVariant QPSQLResult::handle() const
@ -862,8 +861,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(),