Modern IDB: SQLite backend mismanages key generator values.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jan 2016 06:50:40 +0000 (06:50 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jan 2016 06:50:40 +0000 (06:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153625

Reviewed by Andy Estes.

Source/WebCore:

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

There's mixed assumptions about whether the value stored is the current value or the next value.

Fixing those assumptions fixes tests.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber): Store/retrieve the correct value.
(WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber): Ditto.
(WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber): Ditto.

LayoutTests:

* platform/mac-wk1/TestExpectations:

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

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

index df0c621..6ddf940 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: SQLite backend mismanages key generator values.
+        https://bugs.webkit.org/show_bug.cgi?id=153625
+
+        Reviewed by Andy Estes.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-28  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: InspectorTimelineAgent doesn't need to recompile functions because it now uses the sampling profiler
index bb07661..4eb5b82 100644 (file)
@@ -256,19 +256,12 @@ inspector/script-profiler/event-type-API.html
 # SQLite backend tests with text failures
 crypto/subtle/rsa-indexeddb-non-exportable.html [ Failure ]
 fast/history/page-cache-indexed-opened-db.html [ Failure ]
-imported/w3c/indexeddb/idbdatabase_deleteObjectStore4-not_reused.htm [ Failure ]
 imported/w3c/indexeddb/idbindex-multientry-big.htm [ Failure ]
-imported/w3c/indexeddb/keygenerator-constrainterror.htm [ Failure ]
-imported/w3c/indexeddb/keygenerator.htm [ Failure ]
-imported/w3c/indexeddb/transaction-requestqueue.htm [ Failure ]
 storage/indexeddb/cursor-continue-validity.html [ Failure ]
 storage/indexeddb/cursor-primary-key-order.html [ Failure ]
 storage/indexeddb/get-keyrange.html [ Failure ]
-storage/indexeddb/index-duplicate-keypaths.html [ Failure ]
-storage/indexeddb/key-generator.html [ Failure ]
 storage/indexeddb/modern/get-keyrange.html [ Failure ]
 storage/indexeddb/modern/index-3.html [ Failure ]
-storage/indexeddb/objectstore-autoincrement.html [ Failure ]
 
 # SQLite backend tests that timeout
 storage/indexeddb/modern/transaction-scheduler-1.html [ Skip ]
index 5b8c81e..8d96df1 100644 (file)
@@ -1,3 +1,21 @@
+2016-01-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: SQLite backend mismanages key generator values.
+        https://bugs.webkit.org/show_bug.cgi?id=153625
+
+        Reviewed by Andy Estes.
+
+        No new tests (Many failing tests pass, a few get closer).
+
+        There's mixed assumptions about whether the value stored is the current value or the next value.
+
+        Fixing those assumptions fixes tests.
+        
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber): Store/retrieve the correct value.
+        (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber): Ditto.
+        (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber): Ditto.
+
 2016-01-28  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: InspectorTimelineAgent doesn't need to recompile functions because it now uses the sampling profiler
index f1ef85e..0e1305d 100644 (file)
@@ -1356,7 +1356,7 @@ IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& t
     if (!error.isNull())
         return error;
 
-    if (currentValue > maxGeneratorValue)
+    if (currentValue + 1 > maxGeneratorValue)
         return { IDBDatabaseException::ConstraintError, "Cannot generate new key value over 2^53 for object store operation" };
 
     generatedKey = currentValue + 1;
@@ -1365,7 +1365,7 @@ IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& t
 
 IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber)
 {
-    LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber");
+    LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber - object store %" PRIu64 ", reverted number %" PRIu64, objectStoreID, newKeyNumber);
 
     ASSERT(m_sqliteDB);
     ASSERT(m_sqliteDB->isOpen());
@@ -1380,7 +1380,8 @@ IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdenti
         return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in a read-only transaction") };
     }
 
-    return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyNumber);
+    ASSERT(newKeyNumber);
+    return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyNumber - 1);
 }
 
 IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber)
@@ -1414,7 +1415,7 @@ IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceI
 
     ASSERT(newKeyInteger > uint64_t(newKeyNumber));
 
-    return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyInteger);
+    return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyInteger - 1);
 }
 
 IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result)