Changeset 70093 in webkit


Ignore:
Timestamp:
Oct 19, 2010 3:10:16 PM (14 years ago)
Author:
jorlow@chromium.org
Message:

2010-10-19 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Nate Chapin.

Fix multiple index support in IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=47919

Modify an existing test to verify behavior and add another test for
something I thought might have been related (but wasn't, but it still
seems like a good test).

  • storage/indexeddb/index-basics-expected.txt:
  • storage/indexeddb/index-basics.html:
  • storage/indexeddb/queued-commands-expected.txt: Added.
  • storage/indexeddb/queued-commands.html: Added.

2010-10-19 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Nate Chapin.

Fix multiple index support in IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=47919

Fix 2 bugs that caused the IndexData of all but the last index to be
properly updated:

  • The objectStoreDataId is NOT unique if there are multiple indexes. So remove the constraint.
  • Do not delete all existing entries with that objectStoreDataId before adding an entry for each index. Only do it once at the beginning.

Test: storage/indexeddb/queued-commands.html

+ index-basics.html modified

  • storage/IDBFactoryBackendImpl.cpp: (WebCore::createTables):
  • storage/IDBObjectStoreBackendImpl.cpp: (WebCore::deleteIndexData): (WebCore::putIndexData): (WebCore::IDBObjectStoreBackendImpl::putInternal):
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70087 r70093  
     12010-10-19  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Fix multiple index support in IndexedDB
     6        https://bugs.webkit.org/show_bug.cgi?id=47919
     7
     8        Modify an existing test to verify behavior and add another test for
     9        something I thought might have been related (but wasn't, but it still
     10        seems like a good test).
     11
     12        * storage/indexeddb/index-basics-expected.txt:
     13        * storage/indexeddb/index-basics.html:
     14        * storage/indexeddb/queued-commands-expected.txt: Added.
     15        * storage/indexeddb/queued-commands.html: Added.
     16
    1172010-10-19  James Robinson  <jamesr@chromium.org>
    218
  • trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt

    r69540 r70093  
    4545db.createObjectStore('storeName', null)
    4646store.createIndex('indexName', 'x')
     47store.createIndex('indexName2', 'y', false)
    4748PASS 'name' in indexObject is true
    4849PASS indexObject.name is "indexName"
     
    109110
    110111PASS event.result is "key"
     112indexObject2.getKey('zzz')
     113PASS 'onsuccess' in result is true
     114PASS 'onerror' in result is true
     115PASS 'readyState' in result is true
     116An event should fire shortly...
     117
     118Success event fired:
     119PASS 'result' in event is true
     120PASS 'code' in event is false
     121PASS 'message' in event is false
     122PASS 'source' in event is true
     123PASS event.source != null is true
     124PASS 'onsuccess' in event.target is true
     125PASS 'onerror' in event.target is true
     126PASS 'readyState' in event.target is true
     127PASS event.target.readyState is event.target.DONE
     128
     129PASS event.result is "key"
    111130indexObject.get('value')
    112131PASS 'onsuccess' in result is true
  • trunk/LayoutTests/storage/indexeddb/index-basics.html

    r69540 r70093  
    4949    window.store = evalAndLog("db.createObjectStore('storeName', null)");
    5050    window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
     51    window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', false)");
    5152    addData();
    5253}
     
    9899    shouldBeEqualToString("event.result", "key");
    99100
     101    result = evalAndLog("indexObject2.getKey('zzz')");
     102    verifyResult(result);
     103    result.onsuccess = getObjectData2;
     104    result.onerror = unexpectedErrorCallback;
     105}
     106
     107function getObjectData2()
     108{
     109    verifySuccessEvent(event);
     110    shouldBeEqualToString("event.result", "key");
     111
    100112    result = evalAndLog("indexObject.get('value')");
    101113    verifyResult(result);
  • trunk/WebCore/ChangeLog

    r70089 r70093  
     12010-10-19  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Fix multiple index support in IndexedDB
     6        https://bugs.webkit.org/show_bug.cgi?id=47919
     7
     8        Fix 2 bugs that caused the IndexData of all but the last index to be
     9        properly updated:
     10        * The objectStoreDataId is NOT unique if there are multiple indexes. So
     11          remove the constraint.
     12        * Do not delete all existing entries with that objectStoreDataId before
     13          adding an entry for each index. Only do it once at the beginning.
     14
     15        Test: storage/indexeddb/queued-commands.html
     16            + index-basics.html modified
     17
     18        * storage/IDBFactoryBackendImpl.cpp:
     19        (WebCore::createTables):
     20        * storage/IDBObjectStoreBackendImpl.cpp:
     21        (WebCore::deleteIndexData):
     22        (WebCore::putIndexData):
     23        (WebCore::IDBObjectStoreBackendImpl::putInternal):
     24
    1252010-10-19  Martin Robinson  <mrobinson@igalia.com>
    226
  • trunk/WebCore/storage/IDBFactoryBackendImpl.cpp

    r69421 r70093  
    100100
    101101        "DROP TABLE IF EXISTS IndexData",
    102         "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL UNIQUE REFERENCES ObjectStoreData(id))",
     102        "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL REFERENCES ObjectStoreData(id))",
    103103        "DROP INDEX IF EXISTS IndexData_composit",
    104104        "CREATE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
  • trunk/WebCore/storage/IDBObjectStoreBackendImpl.cpp

    r69721 r70093  
    155155}
    156156
    157 static int putIndexData(SQLiteDatabase& db, IDBKey* key, int64_t indexId, int64_t objectStoreDataId)
     157static bool deleteIndexData(SQLiteDatabase& db, int64_t objectStoreDataId)
    158158{
    159159    SQLiteStatement deleteQuery(db, "DELETE FROM IndexData WHERE objectStoreDataId = ?");
     
    161161        return false;
    162162    deleteQuery.bindInt64(1, objectStoreDataId);
    163     if (deleteQuery.step() != SQLResultDone)
    164         return false;
    165 
     163
     164    return deleteQuery.step() == SQLResultDone;
     165}
     166
     167static bool putIndexData(SQLiteDatabase& db, IDBKey* key, int64_t indexId, int64_t objectStoreDataId)
     168{
    166169    SQLiteStatement putQuery(db, "INSERT INTO IndexData (keyString, keyDate, keyNumber, indexId, objectStoreDataId) VALUES (?, ?, ?, ?, ?)");
    167170    if (putQuery.prepare() != SQLResultOk)
     
    191194    RefPtr<SerializedScriptValue> value = prpValue;
    192195    RefPtr<IDBKey> key = prpKey;
     196
     197    // FIXME: Support auto-increment.
    193198
    194199    if (!objectStore->m_keyPath.isNull()) {
     
    242247    }
    243248
     249    if (!deleteIndexData(objectStore->sqliteDatabase(), dataRowId)) {
     250        // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors.
     251        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage."));
     252        transaction->abort();
     253        return;
     254    }
     255
    244256    int i = 0;
    245257    for (IndexMap::iterator it = objectStore->m_indexes.begin(); it != objectStore->m_indexes.end(); ++it, ++i) {
Note: See TracChangeset for help on using the changeset viewer.