Modern IDB: SQLite backend doesn't support deleting ranges with more than one key.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 22:40:02 +0000 (22:40 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 22:40:02 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153604

Reviewed by Andy Estes.

Source/WebCore:

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

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

LayoutTests:

* platform/mac-wk1/TestExpectations:

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

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

index 3cacc87..6ccd92c 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: SQLite backend doesn't support deleting ranges with more than one key.
+        https://bugs.webkit.org/show_bug.cgi?id=153604
+
+        Reviewed by Andy Estes.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-28  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [GTK] Unreviewed gardening after r195740.
index ec03d73..5b257b8 100644 (file)
@@ -455,13 +455,11 @@ 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/delete-range.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/idbobjectstore-delete-1.html [ Failure ]
 storage/indexeddb/modern/index-3.html [ Failure ]
 storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
 storage/indexeddb/mozilla/cursors.html [ Failure ]
index f36678c..9db62b8 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: SQLite backend doesn't support deleting ranges with more than one key.
+        https://bugs.webkit.org/show_bug.cgi?id=153604
+
+        Reviewed by Andy Estes.
+
+        No new tests (A few failing tests pass, a few get closer).
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange):
+
 2016-01-28  Alex Christensen  <achristensen@webkit.org>
 
         Fix Windows build after r195774.
index 3a7c0c9..dcd8700 100644 (file)
@@ -1029,9 +1029,33 @@ IDBError SQLiteIDBBackingStore::deleteRange(const IDBResourceIdentifier& transac
         return { };
     }
 
-    // FIXME: Once cursor support is in place, use a cursor to delete every record in the range.
-    LOG_ERROR("Currently unable to delete all records in a multi-key range");
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Currently unable to delete all records in a multi-key range") };
+    auto cursor = transaction->maybeOpenBackingStoreCursor(objectStoreID, 0, keyRange);
+    if (!cursor) {
+        LOG_ERROR("Cannot open cursor to delete range of records from the database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Cannot open cursor to delete range of records from the database") };
+    }
+
+    Vector<IDBKeyData> keys;
+    while (!cursor->didComplete() && !cursor->didError()) {
+        keys.append(cursor->currentKey());
+        cursor->advance(1);
+    }
+
+    if (cursor->didError()) {
+        LOG_ERROR("Cursor failed while accumulating range of records from the database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Cursor failed while accumulating range of records from the database") };
+    }
+
+    IDBError error;
+    for (auto& key : keys) {
+        error = deleteRecord(*transaction, objectStoreID, key);
+        if (!error.isNull()) {
+            LOG_ERROR("deleteRange: Error deleting keys in range");
+            break;
+        }
+    }
+
+    return error;
 }
 
 IDBError SQLiteIDBBackingStore::updateOneIndexForAddRecord(const IDBIndexInfo& info, const IDBKeyData& key, const ThreadSafeDataBuffer& value)