Modern IDB: Fix several more problems with object store changes during cursor iterati...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 23:18:55 +0000 (23:18 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 23:18:55 +0000 (23:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153616

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (A few failing tests pass, a few get closer).

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):

* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::SQLiteIDBCursor::resetAndRebindStatement):
(WebCore::IDBServer::SQLiteIDBCursor::bindArguments):

* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::iterateCursor):

LayoutTests:

* platform/mac-wk1/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195787 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp

index fe57658..62cfd33 100644 (file)
@@ -1,5 +1,14 @@
 2016-01-28  Brady Eidson  <beidson@apple.com>
 
+        Modern IDB: Fix several more problems with object store changes during cursor iteration in SQLite backend.
+        https://bugs.webkit.org/show_bug.cgi?id=153616
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
         Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.
         https://bugs.webkit.org/show_bug.cgi?id=153614
 
index 1340fd7..968ea39 100644 (file)
@@ -454,11 +454,9 @@ imported/w3c/indexeddb/value_recursive.htm [ Failure ]
 imported/w3c/indexeddb/writer-starvation.htm [ Failure ]
 storage/indexeddb/cursor-continue-validity.html [ Failure ]
 storage/indexeddb/cursor-primary-key-order.html [ Failure ]
-storage/indexeddb/cursor-update.html [ Failure ]
 storage/indexeddb/get-keyrange.html [ Failure ]
 storage/indexeddb/index-duplicate-keypaths.html [ Failure ]
 storage/indexeddb/key-generator.html [ Failure ]
-storage/indexeddb/modern/cursor-7.html [ Failure ]
 storage/indexeddb/modern/get-keyrange.html [ Failure ]
 storage/indexeddb/modern/index-3.html [ Failure ]
 storage/indexeddb/objectstore-autoincrement.html [ Failure ]
index 6998ddf..3cb2492 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Fix several more problems with object store changes during cursor iteration in SQLite backend.
+        https://bugs.webkit.org/show_bug.cgi?id=153616
+
+        Reviewed by Alex Christensen.
+
+        No new tests (A few failing tests pass, a few get closer).
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):
+        
+        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+        (WebCore::IDBServer::SQLiteIDBCursor::resetAndRebindStatement):
+        (WebCore::IDBServer::SQLiteIDBCursor::bindArguments):
+        
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::iterateCursor):
+
 2016-01-28  Daniel Bates  <dabates@apple.com>
 
         Cleanup: Make DedicatedWorkerThread::create() an inline template method
index e7cfbf9..f1ef85e 100644 (file)
@@ -673,6 +673,8 @@ IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& t
 
 IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID)
 {
+    LOG(IndexedDB, "SQLiteIDBBackingStore::clearObjectStore - object store %" PRIu64, objectStoreID);
+
     ASSERT(m_sqliteDB);
     ASSERT(m_sqliteDB->isOpen());
 
@@ -706,6 +708,8 @@ IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& tr
         }
     }
 
+    transaction->notifyCursorsOfChanges(objectStoreID);
+
     return { };
 }
 
index b9a0ef5..a9aa7d4 100644 (file)
@@ -223,10 +223,29 @@ void SQLiteIDBCursor::resetAndRebindStatement()
 
     // Otherwise update the lower key or upper key used for the cursor range.
     // This is so the cursor can pick up where we left off.
-    if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate)
+    // We might also have to change the statement from closed to open so we don't refetch the current key a second time.
+    if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
         m_currentLowerKey = m_currentKey;
-    else
+        if (!m_keyRange.lowerOpen) {
+            m_keyRange.lowerOpen = true;
+            m_keyRange.lowerKey = m_currentLowerKey;
+            m_statement = nullptr;
+            m_currentRecordID = -1;
+        }
+    } else {
         m_currentUpperKey = m_currentKey;
+        if (!m_keyRange.upperOpen) {
+            m_keyRange.upperOpen = true;
+            m_keyRange.upperKey = m_currentUpperKey;
+            m_statement = nullptr;
+            m_currentRecordID = -1;
+        }
+    }
+
+    if (!m_statement && !establishStatement()) {
+        LOG_ERROR("Unable to establish new statement for cursor iteration");
+        return;
+    }
 
     if (m_statement->reset() != SQLITE_OK) {
         LOG_ERROR("Could not reset cursor statement to respond to object store changes");
@@ -238,6 +257,8 @@ void SQLiteIDBCursor::resetAndRebindStatement()
 
 bool SQLiteIDBCursor::bindArguments()
 {
+    LOG(IndexedDB, "Cursor is binding lower key '%s' and upper key '%s'", m_currentLowerKey.loggingString().utf8().data(), m_currentUpperKey.loggingString().utf8().data());
+
     if (m_statement->bindInt64(1, m_boundID) != SQLITE_OK) {
         LOG_ERROR("Could not bind id argument (bound ID)");
         return false;
index 868133b..41ef8c2 100644 (file)
@@ -281,7 +281,7 @@ void UniqueIDBDatabaseTransaction::iterateCursor(const IDBRequestData& requestDa
 
     RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
     m_databaseConnection->database().iterateCursor(requestData, key, count, [this, protectedThis, requestData](const IDBError& error, const IDBGetResult& result) {
-        LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor (callback)");
+        LOG(IndexedDB, "UniqueIDBDatabaseTransaction::iterateCursor (callback)");
 
         if (error.isNull())
             m_databaseConnection->connectionToClient().didIterateCursor(IDBResultData::iterateCursorSuccess(requestData.requestIdentifier(), result));