⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 106705 in webkit


Ignore:
Timestamp:
Feb 3, 2012, 4:16:45 PM (15 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: Key generators not rolled back if insertion fails or is aborted
https://bugs.webkit.org/show_bug.cgi?id=77060

Reviewed by Tony Chang.

Source/WebCore:

Test: storage/indexeddb/key-generator.html

  • storage/IDBObjectStoreBackendImpl.cpp:

(WebCore::IDBObjectStoreBackendImpl::put): Add abort task to reset cache.
(WebCore::IDBObjectStoreBackendImpl::revertAutoIncrementKeyCache):
(WebCore):
(WebCore::IDBObjectStoreBackendImpl::putInternal): Reset cache on error.

  • storage/IDBObjectStoreBackendImpl.h:

(IDBObjectStoreBackendImpl):

LayoutTests:

  • storage/indexeddb/key-generator-expected.txt: Added.
  • storage/indexeddb/key-generator.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106704 r106705  
     12012-02-03  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Key generators not rolled back if insertion fails or is aborted
     4        https://bugs.webkit.org/show_bug.cgi?id=77060
     5
     6        Reviewed by Tony Chang.
     7
     8        * storage/indexeddb/key-generator-expected.txt: Added.
     9        * storage/indexeddb/key-generator.html: Added.
     10
    1112012-02-03  Tony Chang  <tony@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r106704 r106705  
     12012-02-03  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Key generators not rolled back if insertion fails or is aborted
     4        https://bugs.webkit.org/show_bug.cgi?id=77060
     5
     6        Reviewed by Tony Chang.
     7
     8        Test: storage/indexeddb/key-generator.html
     9
     10        * storage/IDBObjectStoreBackendImpl.cpp:
     11        (WebCore::IDBObjectStoreBackendImpl::put): Add abort task to reset cache.
     12        (WebCore::IDBObjectStoreBackendImpl::revertAutoIncrementKeyCache):
     13        (WebCore):
     14        (WebCore::IDBObjectStoreBackendImpl::putInternal): Reset cache on error.
     15        * storage/IDBObjectStoreBackendImpl.h:
     16        (IDBObjectStoreBackendImpl):
     17
    1182012-02-03  Tony Chang  <tony@chromium.org>
    219
  • trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp

    r106387 r106705  
    179179    }
    180180
    181     if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction)))
    182         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     181    if (!transaction->scheduleTask(
     182            createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction),
     183            // FIXME: One of these per put() is overkill, since it's simply a cache invalidation.
     184            createCallbackTask(&IDBObjectStoreBackendImpl::revertAutoIncrementKeyCache, objectStore)))
     185        ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     186}
     187
     188void IDBObjectStoreBackendImpl::revertAutoIncrementKeyCache(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
     189{
     190    objectStore->resetAutoIncrementKeyCache();
    183191}
    184192
     
    205213                    RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(autoIncKey, value, objectStore->m_keyPath);
    206214                    if (!valueAfterInjection) {
     215                        objectStore->resetAutoIncrementKeyCache();
    207216                        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The generated key could not be inserted into the object using the keyPath."));
    208217                        return;
     
    222231    RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->m_backingStore->createInvalidRecordIdentifier();
    223232    if (putMode == AddOnly && objectStore->m_backingStore->keyExistsInObjectStore(objectStore->m_databaseId, objectStore->id(), *key, recordIdentifier.get())) {
     233        objectStore->resetAutoIncrementKeyCache();
    224234        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Key already exists in the object store."));
    225235        return;
     
    238248
    239249        if ((!index->multiEntry() || indexKey->type() != IDBKey::ArrayType) && !index->addingKeyAllowed(indexKey.get(), key.get())) {
     250            objectStore->resetAutoIncrementKeyCache();
    240251            callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "One of the derived (from a keyPath) keys for an index does not satisfy its uniqueness requirements."));
    241252            return;
    242253        }
    243254
    244        if (index->multiEntry() && indexKey->type() == IDBKey::ArrayType) {
     255        if (index->multiEntry() && indexKey->type() == IDBKey::ArrayType) {
    245256           for (size_t j = 0; j < indexKey->array().size(); ++j) {
    246257                if (!index->addingKeyAllowed(indexKey->array()[j].get(), key.get())) {
     258                    objectStore->resetAutoIncrementKeyCache();
    247259                    callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "One of the derived (from a keyPath) keys for an index does not satisfy its uniqueness requirements."));
    248260                    return;
  • trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.h

    r106387 r106705  
    101101    static void removeIndexFromMap(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBIndexBackendImpl>);
    102102    static void addIndexToMap(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBIndexBackendImpl>);
     103    static void revertAutoIncrementKeyCache(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>);
    103104
    104105    RefPtr<IDBBackingStore> m_backingStore;
Note: See TracChangeset for help on using the changeset viewer.