IndexedDB: When doing puts, don't "updateAllIndexesForAddRecord" if there are no...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 02:42:28 +0000 (02:42 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 02:42:28 +0000 (02:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165215

Reviewed by Alex Christensen.

No new tests (No observable behavior change).

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Don't "updateAllIndexesForAddRecord" if there are no indexes.
  Avoiding this saved us some IDBKey serialization and Javascript object manipulation.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

index 0792e96..1953043 100644 (file)
@@ -1,3 +1,16 @@
+2016-11-30  Brady Eidson  <beidson@apple.com>
+
+        IndexedDB: When doing puts, don't "updateAllIndexesForAddRecord" if there are no indexes.
+        https://bugs.webkit.org/show_bug.cgi?id=165215
+
+        Reviewed by Alex Christensen.
+
+        No new tests (No observable behavior change).
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Don't "updateAllIndexesForAddRecord" if there are no indexes.
+          Avoiding this saved us some IDBKey serialization and Javascript object manipulation.
+
 2016-11-30  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] LayoutNode: only mark properties as dirty if different than current value
index fb6d378..927d492 100644 (file)
@@ -1660,19 +1660,21 @@ IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transacti
         recordID = m_sqliteDB->lastInsertRowID();
     }
 
-    auto error = updateAllIndexesForAddRecord(objectStoreInfo, keyData, value.data());
+    if (!objectStoreInfo.indexMap().isEmpty()) {
+        auto error = updateAllIndexesForAddRecord(objectStoreInfo, keyData, value.data());
 
-    if (!error.isNull()) {
-        auto* sql = cachedStatement(SQL::DeleteObjectStoreRecord, ASCIILiteral("DELETE FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);"));
-        if (!sql
-            || sql->bindInt64(1, objectStoreInfo.identifier()) != SQLITE_OK
-            || sql->bindBlob(2, keyBuffer->data(), keyBuffer->size()) != SQLITE_OK
-            || sql->step() != SQLITE_DONE) {
-            LOG_ERROR("Indexing new object store record failed, but unable to remove the object store record itself");
-            return { IDBDatabaseException::UnknownError, ASCIILiteral("Indexing new object store record failed, but unable to remove the object store record itself") };
-        }
+        if (!error.isNull()) {
+            auto* sql = cachedStatement(SQL::DeleteObjectStoreRecord, ASCIILiteral("DELETE FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);"));
+            if (!sql
+                || sql->bindInt64(1, objectStoreInfo.identifier()) != SQLITE_OK
+                || sql->bindBlob(2, keyBuffer->data(), keyBuffer->size()) != SQLITE_OK
+                || sql->step() != SQLITE_DONE) {
+                LOG_ERROR("Indexing new object store record failed, but unable to remove the object store record itself");
+                return { IDBDatabaseException::UnknownError, ASCIILiteral("Indexing new object store record failed, but unable to remove the object store record itself") };
+            }
 
-        return error;
+            return error;
+        }
     }
 
     const Vector<String>& blobURLs = value.blobURLs();
@@ -1728,7 +1730,7 @@ IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transacti
 
     transaction->notifyCursorsOfChanges(objectStoreInfo.identifier());
 
-    return error;
+    return { };
 }
 
 IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths)