             error = error1
             statement = nil
         }
+
+        // Close, not reset -- this isn't going to be reused, and the FilledSQLiteCursor
+        // consumes everything.
+        defer { statement?.close() }
+
         if let error = error {
             // Special case: Write additional info to the database log in the case of a database corruption.
             if error.code == Int(SQLITE_CORRUPT) {

        // For where these values come from, see Bug 1213623.
        //

        let currentPageSize = executeQueryUnsafe("PRAGMA page_size", factory: IntFactory)[0]
        let desiredPageSize = 32 * 1024

        // This has to be done without WAL, so we always hop into rollback/delete journal mode.

            }

            log.error("SQL error: \(error.localizedDescription) for SQL \(sqlStr).")
            return error
        }

