summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLorenz Haas <lorenz.haas@histomatics.de>2016-11-29 20:04:12 +0100
committerLorenz Haas <lorenz.haas@histomatics.de>2017-03-16 17:41:41 +0000
commit4351c2af45768bcb68b5bb996c1fb6e24dc9556b (patch)
tree9657bc22deae75b4669492ebf859c40d93f736d0 /src
parent8ea27bb1c669e21100a6a042b0378b3346bdf671 (diff)
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 <newellm@blur.com> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp1
1 files changed, 1 insertions, 0 deletions
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;