Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195647 => 195648)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2016-01-27 02:16:57 UTC (rev 195647)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2016-01-27 02:25:58 UTC (rev 195648)
@@ -470,7 +470,6 @@
storage/indexeddb/cursor-properties.html [ Failure ]
storage/indexeddb/cursor-reverse-bug.html [ Failure ]
storage/indexeddb/cursor-skip-deleted.html [ Failure ]
-storage/indexeddb/cursor-update-value-argument-required.html [ Failure ]
storage/indexeddb/cursor-update.html [ Failure ]
storage/indexeddb/cursor-value.html [ Failure ]
storage/indexeddb/delete-range.html [ Failure ]
@@ -489,12 +488,10 @@
storage/indexeddb/key-sort-order-across-types.html [ Failure ]
storage/indexeddb/key-sort-order-date.html [ Failure ]
storage/indexeddb/keypath-arrays.html [ Failure ]
-storage/indexeddb/keypath-edges.html [ Failure ]
storage/indexeddb/keypath-fetch-key.html [ Failure ]
storage/indexeddb/keypath-intrinsic-properties.html [ Failure ]
storage/indexeddb/lazy-index-population.html [ Failure ]
storage/indexeddb/lazy-index-types.html [ Failure ]
-storage/indexeddb/modern/autoincrement-abort.html [ Failure ]
storage/indexeddb/modern/cursor-1.html [ Failure ]
storage/indexeddb/modern/cursor-2.html [ Failure ]
storage/indexeddb/modern/cursor-3.html [ Failure ]
@@ -506,8 +503,6 @@
storage/indexeddb/modern/deleteindex-1.html [ Failure ]
storage/indexeddb/modern/deleteindex-2.html [ Failure ]
storage/indexeddb/modern/get-keyrange.html [ Failure ]
-storage/indexeddb/modern/idbobjectstore-clear-1.html [ Failure ]
-storage/indexeddb/modern/idbobjectstore-clear-2.html [ Failure ]
storage/indexeddb/modern/idbobjectstore-delete-1.html [ Failure ]
storage/indexeddb/modern/index-1.html [ Failure ]
storage/indexeddb/modern/index-2.html [ Failure ]
@@ -526,17 +521,9 @@
storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
storage/indexeddb/mozilla/cursor-update-updates-indexes.html [ Failure ]
storage/indexeddb/mozilla/cursors.html [ Failure ]
-storage/indexeddb/mozilla/delete-result.html [ Failure ]
-storage/indexeddb/mozilla/event-source.html [ Failure ]
storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Failure ]
storage/indexeddb/mozilla/indexes.html [ Failure ]
-storage/indexeddb/mozilla/key-requirements.html [ Failure ]
storage/indexeddb/mozilla/object-cursors.html [ Failure ]
-storage/indexeddb/mozilla/object-store-inline-autoincrement-key-added-on-put.html [ Failure ]
-storage/indexeddb/mozilla/object-store-remove-values.html [ Failure ]
-storage/indexeddb/mozilla/odd-result-order.html [ Failure ]
-storage/indexeddb/mozilla/put-get-values.html [ Failure ]
-storage/indexeddb/mozilla/readwrite-transactions.html [ Failure ]
storage/indexeddb/mozilla/remove-objectstore.html [ Failure ]
storage/indexeddb/mutating-cursor.html [ Failure ]
storage/indexeddb/objectstore-autoincrement.html [ Failure ]
Modified: trunk/Source/WebCore/ChangeLog (195647 => 195648)
--- trunk/Source/WebCore/ChangeLog 2016-01-27 02:16:57 UTC (rev 195647)
+++ trunk/Source/WebCore/ChangeLog 2016-01-27 02:25:58 UTC (rev 195648)
@@ -1,3 +1,20 @@
+2016-01-26 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Key generator support for SQLite backend.
+ https://bugs.webkit.org/show_bug.cgi?id=153427
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Existing failing tests now pass, others improved).
+
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetKeyGeneratorValue):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
2016-01-26 Simon Fraser <simon.fra...@apple.com>
Allow canvas to use display-list drawing for testing
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (195647 => 195648)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-01-27 02:16:57 UTC (rev 195647)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-01-27 02:25:58 UTC (rev 195648)
@@ -1180,21 +1180,128 @@
return { };
}
-IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier&, uint64_t, uint64_t&)
+IDBError SQLiteIDBBackingStore::uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue)
{
- return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+ SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT currentKey FROM KeyGenerators WHERE objectStoreID = ?;"));
+ if (sql.prepare() != SQLITE_OK
+ || sql.bindInt64(1, objectStoreID) != SQLITE_OK) {
+ LOG_ERROR("Could not retrieve currentKey from KeyGenerators table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Error getting current key generator value from database") };
+ }
+ int result = sql.step();
+ if (result != SQLITE_ROW) {
+ LOG_ERROR("Could not retreive key generator value for object store, but it should be there.");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Error finding current key generator value in database") };
+ }
+
+ int64_t value = sql.getColumnInt64(0);
+ if (value < 0)
+ return { IDBDatabaseException::ConstraintError, "Current key generator value from database is invalid" };
+
+ outValue = value;
+ return { };
}
-IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier&, uint64_t, uint64_t)
+IDBError SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value)
{
- return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+ SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO KeyGenerators VALUES (?, ?);"));
+ if (sql.prepare() != SQLITE_OK
+ || sql.bindInt64(1, objectStoreID) != SQLITE_OK
+ || sql.bindInt64(2, value) != SQLITE_OK
+ || sql.step() != SQLITE_DONE) {
+ LOG_ERROR("Could not update key generator value (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+ return { IDBDatabaseException::ConstraintError, "Error storing new key generator value in database" };
+ }
+
+ return { };
}
-IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier&, uint64_t, double)
+IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey)
{
- return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+ LOG(IndexedDB, "SQLiteIDBBackingStore::generateKeyNumber");
+
+ ASSERT(m_sqliteDB);
+ ASSERT(m_sqliteDB->isOpen());
+
+ // The IndexedDatabase spec defines the max key generator value as 2^53;
+ static uint64_t maxGeneratorValue = 0x20000000000000;
+
+ auto* transaction = m_transactions.get(transactionIdentifier);
+ if (!transaction || !transaction->inProgress()) {
+ LOG_ERROR("Attempt to generate key in database without an in-progress transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in database without an in-progress transaction") };
+ }
+ if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
+ LOG_ERROR("Attempt to generate key in a read-only transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in a read-only transaction") };
+ }
+
+ uint64_t currentValue;
+ auto error = uncheckedGetKeyGeneratorValue(objectStoreID, currentValue);
+ if (!error.isNull())
+ return error;
+
+ if (currentValue > maxGeneratorValue)
+ return { IDBDatabaseException::ConstraintError, "Cannot generate new key value over 2^53 for object store operation" };
+
+ generatedKey = currentValue + 1;
+ return uncheckedSetKeyGeneratorValue(objectStoreID, generatedKey);
}
+IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber)
+{
+ LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber");
+
+ ASSERT(m_sqliteDB);
+ ASSERT(m_sqliteDB->isOpen());
+
+ auto* transaction = m_transactions.get(transactionIdentifier);
+ if (!transaction || !transaction->inProgress()) {
+ LOG_ERROR("Attempt to revert key generator value in database without an in-progress transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in database without an in-progress transaction") };
+ }
+ if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
+ LOG_ERROR("Attempt to revert key generator value in a read-only transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in a read-only transaction") };
+ }
+
+ return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyNumber);
+}
+
+IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber)
+{
+ LOG(IndexedDB, "SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber");
+
+ ASSERT(m_sqliteDB);
+ ASSERT(m_sqliteDB->isOpen());
+
+ auto* transaction = m_transactions.get(transactionIdentifier);
+ if (!transaction || !transaction->inProgress()) {
+ LOG_ERROR("Attempt to update key generator value in database without an in-progress transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in database without an in-progress transaction") };
+ }
+ if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
+ LOG_ERROR("Attempt to update key generator value in a read-only transaction");
+ return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in a read-only transaction") };
+ }
+
+ uint64_t currentValue;
+ auto error = uncheckedGetKeyGeneratorValue(objectStoreID, currentValue);
+ if (!error.isNull())
+ return error;
+
+ if (newKeyNumber <= currentValue)
+ return { };
+
+ uint64_t newKeyInteger(newKeyNumber);
+ if (newKeyInteger <= uint64_t(newKeyNumber))
+ ++newKeyInteger;
+
+ ASSERT(newKeyInteger > uint64_t(newKeyNumber));
+
+ return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyInteger);
+}
+
IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result)
{
ASSERT(m_sqliteDB);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (195647 => 195648)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-01-27 02:16:57 UTC (rev 195647)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-01-27 02:25:58 UTC (rev 195648)
@@ -89,6 +89,8 @@
IDBError deleteRecord(SQLiteIDBTransaction&, int64_t objectStoreID, const IDBKeyData&);
IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData& keyValue, const IDBKeyData& indexKey);
IDBError uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData&, bool& hasRecord);
+ IDBError uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue);
+ IDBError uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value);
IDBDatabaseIdentifier m_identifier;
std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;