Changeset 195648 in webkit
- Timestamp:
- Jan 26, 2016 6:25:58 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195646 r195648 1 2016-01-26 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Key generator support for SQLite backend. 4 https://bugs.webkit.org/show_bug.cgi?id=153427 5 6 Reviewed by Alex Christensen. 7 8 * platform/mac-wk1/TestExpectations: 9 1 10 2016-01-26 Simon Fraser <simon.fraser@apple.com> 2 11 -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r195598 r195648 471 471 storage/indexeddb/cursor-reverse-bug.html [ Failure ] 472 472 storage/indexeddb/cursor-skip-deleted.html [ Failure ] 473 storage/indexeddb/cursor-update-value-argument-required.html [ Failure ]474 473 storage/indexeddb/cursor-update.html [ Failure ] 475 474 storage/indexeddb/cursor-value.html [ Failure ] … … 490 489 storage/indexeddb/key-sort-order-date.html [ Failure ] 491 490 storage/indexeddb/keypath-arrays.html [ Failure ] 492 storage/indexeddb/keypath-edges.html [ Failure ]493 491 storage/indexeddb/keypath-fetch-key.html [ Failure ] 494 492 storage/indexeddb/keypath-intrinsic-properties.html [ Failure ] 495 493 storage/indexeddb/lazy-index-population.html [ Failure ] 496 494 storage/indexeddb/lazy-index-types.html [ Failure ] 497 storage/indexeddb/modern/autoincrement-abort.html [ Failure ]498 495 storage/indexeddb/modern/cursor-1.html [ Failure ] 499 496 storage/indexeddb/modern/cursor-2.html [ Failure ] … … 507 504 storage/indexeddb/modern/deleteindex-2.html [ Failure ] 508 505 storage/indexeddb/modern/get-keyrange.html [ Failure ] 509 storage/indexeddb/modern/idbobjectstore-clear-1.html [ Failure ]510 storage/indexeddb/modern/idbobjectstore-clear-2.html [ Failure ]511 506 storage/indexeddb/modern/idbobjectstore-delete-1.html [ Failure ] 512 507 storage/indexeddb/modern/index-1.html [ Failure ] … … 527 522 storage/indexeddb/mozilla/cursor-update-updates-indexes.html [ Failure ] 528 523 storage/indexeddb/mozilla/cursors.html [ Failure ] 529 storage/indexeddb/mozilla/delete-result.html [ Failure ]530 storage/indexeddb/mozilla/event-source.html [ Failure ]531 524 storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Failure ] 532 525 storage/indexeddb/mozilla/indexes.html [ Failure ] 533 storage/indexeddb/mozilla/key-requirements.html [ Failure ]534 526 storage/indexeddb/mozilla/object-cursors.html [ Failure ] 535 storage/indexeddb/mozilla/object-store-inline-autoincrement-key-added-on-put.html [ Failure ]536 storage/indexeddb/mozilla/object-store-remove-values.html [ Failure ]537 storage/indexeddb/mozilla/odd-result-order.html [ Failure ]538 storage/indexeddb/mozilla/put-get-values.html [ Failure ]539 storage/indexeddb/mozilla/readwrite-transactions.html [ Failure ]540 527 storage/indexeddb/mozilla/remove-objectstore.html [ Failure ] 541 528 storage/indexeddb/mutating-cursor.html [ Failure ] -
trunk/Source/WebCore/ChangeLog
r195646 r195648 1 2016-01-26 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Key generator support for SQLite backend. 4 https://bugs.webkit.org/show_bug.cgi?id=153427 5 6 Reviewed by Alex Christensen. 7 8 No new tests (Existing failing tests now pass, others improved). 9 10 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 11 (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetKeyGeneratorValue): 12 (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue): 13 (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber): 14 (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber): 15 (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber): 16 * Modules/indexeddb/server/SQLiteIDBBackingStore.h: 17 1 18 2016-01-26 Simon Fraser <simon.fraser@apple.com> 2 19 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r195541 r195648 1181 1181 } 1182 1182 1183 IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier&, uint64_t, uint64_t&) 1184 { 1185 return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") }; 1186 } 1187 1188 IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier&, uint64_t, uint64_t) 1189 { 1190 return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") }; 1191 } 1192 1193 IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier&, uint64_t, double) 1194 { 1195 return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") }; 1183 IDBError SQLiteIDBBackingStore::uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue) 1184 { 1185 SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT currentKey FROM KeyGenerators WHERE objectStoreID = ?;")); 1186 if (sql.prepare() != SQLITE_OK 1187 || sql.bindInt64(1, objectStoreID) != SQLITE_OK) { 1188 LOG_ERROR("Could not retrieve currentKey from KeyGenerators table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg()); 1189 return { IDBDatabaseException::UnknownError, ASCIILiteral("Error getting current key generator value from database") }; 1190 } 1191 int result = sql.step(); 1192 if (result != SQLITE_ROW) { 1193 LOG_ERROR("Could not retreive key generator value for object store, but it should be there."); 1194 return { IDBDatabaseException::UnknownError, ASCIILiteral("Error finding current key generator value in database") }; 1195 } 1196 1197 int64_t value = sql.getColumnInt64(0); 1198 if (value < 0) 1199 return { IDBDatabaseException::ConstraintError, "Current key generator value from database is invalid" }; 1200 1201 outValue = value; 1202 return { }; 1203 } 1204 1205 IDBError SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value) 1206 { 1207 SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO KeyGenerators VALUES (?, ?);")); 1208 if (sql.prepare() != SQLITE_OK 1209 || sql.bindInt64(1, objectStoreID) != SQLITE_OK 1210 || sql.bindInt64(2, value) != SQLITE_OK 1211 || sql.step() != SQLITE_DONE) { 1212 LOG_ERROR("Could not update key generator value (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg()); 1213 return { IDBDatabaseException::ConstraintError, "Error storing new key generator value in database" }; 1214 } 1215 1216 return { }; 1217 } 1218 1219 IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey) 1220 { 1221 LOG(IndexedDB, "SQLiteIDBBackingStore::generateKeyNumber"); 1222 1223 ASSERT(m_sqliteDB); 1224 ASSERT(m_sqliteDB->isOpen()); 1225 1226 // The IndexedDatabase spec defines the max key generator value as 2^53; 1227 static uint64_t maxGeneratorValue = 0x20000000000000; 1228 1229 auto* transaction = m_transactions.get(transactionIdentifier); 1230 if (!transaction || !transaction->inProgress()) { 1231 LOG_ERROR("Attempt to generate key in database without an in-progress transaction"); 1232 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in database without an in-progress transaction") }; 1233 } 1234 if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) { 1235 LOG_ERROR("Attempt to generate key in a read-only transaction"); 1236 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in a read-only transaction") }; 1237 } 1238 1239 uint64_t currentValue; 1240 auto error = uncheckedGetKeyGeneratorValue(objectStoreID, currentValue); 1241 if (!error.isNull()) 1242 return error; 1243 1244 if (currentValue > maxGeneratorValue) 1245 return { IDBDatabaseException::ConstraintError, "Cannot generate new key value over 2^53 for object store operation" }; 1246 1247 generatedKey = currentValue + 1; 1248 return uncheckedSetKeyGeneratorValue(objectStoreID, generatedKey); 1249 } 1250 1251 IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber) 1252 { 1253 LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber"); 1254 1255 ASSERT(m_sqliteDB); 1256 ASSERT(m_sqliteDB->isOpen()); 1257 1258 auto* transaction = m_transactions.get(transactionIdentifier); 1259 if (!transaction || !transaction->inProgress()) { 1260 LOG_ERROR("Attempt to revert key generator value in database without an in-progress transaction"); 1261 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in database without an in-progress transaction") }; 1262 } 1263 if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) { 1264 LOG_ERROR("Attempt to revert key generator value in a read-only transaction"); 1265 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in a read-only transaction") }; 1266 } 1267 1268 return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyNumber); 1269 } 1270 1271 IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber) 1272 { 1273 LOG(IndexedDB, "SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber"); 1274 1275 ASSERT(m_sqliteDB); 1276 ASSERT(m_sqliteDB->isOpen()); 1277 1278 auto* transaction = m_transactions.get(transactionIdentifier); 1279 if (!transaction || !transaction->inProgress()) { 1280 LOG_ERROR("Attempt to update key generator value in database without an in-progress transaction"); 1281 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in database without an in-progress transaction") }; 1282 } 1283 if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) { 1284 LOG_ERROR("Attempt to update key generator value in a read-only transaction"); 1285 return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in a read-only transaction") }; 1286 } 1287 1288 uint64_t currentValue; 1289 auto error = uncheckedGetKeyGeneratorValue(objectStoreID, currentValue); 1290 if (!error.isNull()) 1291 return error; 1292 1293 if (newKeyNumber <= currentValue) 1294 return { }; 1295 1296 uint64_t newKeyInteger(newKeyNumber); 1297 if (newKeyInteger <= uint64_t(newKeyNumber)) 1298 ++newKeyInteger; 1299 1300 ASSERT(newKeyInteger > uint64_t(newKeyNumber)); 1301 1302 return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyInteger); 1196 1303 } 1197 1304 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
r195527 r195648 90 90 IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData& keyValue, const IDBKeyData& indexKey); 91 91 IDBError uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData&, bool& hasRecord); 92 IDBError uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue); 93 IDBError uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value); 92 94 93 95 IDBDatabaseIdentifier m_identifier;
Note: See TracChangeset
for help on using the changeset viewer.