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

Sqlite file locks and undestroyed queries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 4.6.2
    • SQL Support
    • None
    • only apparent on windows because of locking. suspected on others

    Description

      With sqlite if you create queries and do not free/destroy those queries by a explicit delete or let them pass out of scope before closing the database connection Qt leaves a the database file open and locked even after the close. If the query is freed after the query is closed the file is still left open and locked. On windows the database file cannot be removed while still open which makes unit tests that create temporary database files unremovable in the same program if queries are not destroyed before closing.

      The documentation for QSqlDatabase::close() states "Closes the database connection, freeing any resources acquired, and invalidating any existing QSqlQuery objects that are used with the database."

      Note that at least calling QSqlQuery::finish() does not alleviate the described problem. My memory is that QSqlQuery::clear() is similarly ineffective but I could be wrong.

      It would seem that either the documentation needs to be changed to explicitly say that QSqlQuery's must be freed before closing or a bug exists in the Sqlite driver.

      I have seen at least one forum post of the same issue. The poster resolved his issue by switching to a in memory database for his unit test. This is more of a work around than a fix though.

      Thanks!

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mgoddard Michael Goddard (closed Nokia identity) (Inactive)
              schallee Ed Schaller
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes