From 4351c2af45768bcb68b5bb996c1fb6e24dc9556b Mon Sep 17 00:00:00 2001 From: Lorenz Haas Date: Tue, 29 Nov 2016 20:04:12 +0100 Subject: [PATCH] Fix postgres notification subscription on LISTEN failure Register a notification only if the LISTEN call was successful. This behaves now like the UNLISTEN case: the notification is only unregistered if the call was successful. Change-Id: I2b18ec3a619fea5bed0a319013ad9df4b9e15456 Reviewed-by: Matt Newell Reviewed-by: Jesus Fernandez Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index e0f9222902..fecfda22d5 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1420,6 +1420,7 @@ bool QPSQLDriver::subscribeToNotification(const QString &name) QString query = QLatin1String("LISTEN ") + escapeIdentifier(name, QSqlDriver::TableName); PGresult *result = d->exec(query); if (PQresultStatus(result) != PGRES_COMMAND_OK) { + d->seid.removeLast(); setLastError(qMakeError(tr("Unable to subscribe"), QSqlError::StatementError, d, result)); PQclear(result); return false;