Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84356

QSqlDriver::subscribeToNotification lost if PGSQL server restarts

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.2
    • 5.12.5
    • SQL Support
    • None
    • Linux/X11
    • b1af52f2b2e1d318fc7a5481659e8101bf2e18dd (qt/qtbase/dev) 45194de004a090e0d68b8b117e0f4384919ed24a (qt/qtbase/5.15)

    Description

      Create a database connection:

       

       

      auto db = QSqlDatabase::addDatabase("QPSQL");
      db = QSqlDatabase::database();
      db.setHostName(Settings::instance().dBHostname());
      db.setUserName(Settings::instance().dBUserName());
      db.setPassword(Settings::instance().dBPassword());
      db.setDatabaseName(Settings::instance().database());
      if(!db.isOpen() && !db.open())
      {
        qWarning() << "Could not open database connection!";
        return;
      }
      if(!db.driver()->subscribeToNotification(internmentsChangedNotificationString())) 
        qDebug() << "Could not subscribe to notification" << internmentsChangedNotificationString(); else qDebug() << "Subscribed to notification" << db.driver()->subscribedToNotifications();
      

       

      Start PGSQL server, start the application, everything is fine.

       

      Now stop SQL server, wait some seconds, reopen it.

      db.IsOpen() will return true, and if one tries to subscribe to the notification it will inform the user that it is already subscribed to it. But it isn't. Moreover it seems that db.isOpen() will reconnect against the database.

       

       

      Attachments

        For Gerrit Dashboard: QTBUG-84356
        # Subject Branch Project Status CR V

        Activity

          People

            andysh Andy Shaw
            lisandropm Lisandro Damián Nicanor Pérez Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes