IDB: When deleting object stores/indexes, also delete associated records
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Jan 2014 17:03:17 +0000 (17:03 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Jan 2014 17:03:17 +0000 (17:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127872

Reviewed by Anders Carlsson.

This was mostly done via other patches, but clearObjectStore was the last remaining case:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore): Also delete Index records.

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

Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp

index 32bba6d..e8d2b87 100644 (file)
@@ -1,5 +1,16 @@
 2014-01-31  Brady Eidson  <beidson@apple.com>
 
+        IDB: When deleting object stores/indexes, also delete associated records
+        https://bugs.webkit.org/show_bug.cgi?id=127872
+
+        Reviewed by Anders Carlsson.
+
+        This was mostly done via other patches, but clearObjectStore was the last remaining case:
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore): Also delete Index records.
+
+2014-01-31  Brady Eidson  <beidson@apple.com>
+
         IDB: Index writing
         <rdar://problem/15899973> and https://bugs.webkit.org/show_bug.cgi?id=127868
 
index b640044..3ae9b03 100644 (file)
@@ -558,7 +558,16 @@ bool UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore(const IDBIdentifier&
         }
     }
 
-    // FIXME <rdar://problem/15779642>: Once indexes are implemented, drop index records.
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM IndexRecords WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR("Could not delete records from index record store id %lli (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+    }
+
     return true;
 }