Title: [195783] trunk
Revision
195783
Author
beid...@apple.com
Date
2016-01-28 14:40:02 -0800 (Thu, 28 Jan 2016)

Log Message

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.

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195782 => 195783)


--- trunk/LayoutTests/ChangeLog	2016-01-28 22:24:58 UTC (rev 195782)
+++ trunk/LayoutTests/ChangeLog	2016-01-28 22:40:02 UTC (rev 195783)
@@ -1,3 +1,12 @@
+2016-01-28  Brady Eidson  <beid...@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  <clo...@igalia.com>
 
         [GTK] Unreviewed gardening after r195740.

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195782 => 195783)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-28 22:24:58 UTC (rev 195782)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-28 22:40:02 UTC (rev 195783)
@@ -455,13 +455,11 @@
 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 ]

Modified: trunk/Source/WebCore/ChangeLog (195782 => 195783)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 22:24:58 UTC (rev 195782)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 22:40:02 UTC (rev 195783)
@@ -1,3 +1,15 @@
+2016-01-28  Brady Eidson  <beid...@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  <achristen...@webkit.org>
 
         Fix Windows build after r195774.

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (195782 => 195783)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-28 22:24:58 UTC (rev 195782)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-28 22:40:02 UTC (rev 195783)
@@ -1029,9 +1029,33 @@
         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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to