Changeset 195765 in webkit


Ignore:
Timestamp:
Jan 28, 2016 11:20:25 AM (8 years ago)
Author:
beidson@apple.com
Message:

Modern IDB: Index uniqueness broken in the SQLite backend.
https://bugs.webkit.org/show_bug.cgi?id=153596

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (Many failing tests now pass, others improve).

  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexKey):
(WebCore::IDBServer::SQLiteIDBBackingStore::updateOneIndexForAddRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::updateIndexesForAddRecord): Deleted.

  • Modules/indexeddb/server/SQLiteIDBBackingStore.h:

LayoutTests:

  • platform/mac-wk1/TestExpectations:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195752 r195765  
     12016-01-28  Brady Eidson  <beidson@apple.com>
     2
     3        Modern IDB: Index uniqueness broken in the SQLite backend.
     4        https://bugs.webkit.org/show_bug.cgi?id=153596
     5
     6        Reviewed by Alex Christensen.
     7
     8        * platform/mac-wk1/TestExpectations:
     9
    1102016-01-28  Zalan Bujtas  <zalan@apple.com>
    211
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r195709 r195765  
    459459storage/indexeddb/get-keyrange.html [ Failure ]
    460460storage/indexeddb/index-duplicate-keypaths.html [ Failure ]
    461 storage/indexeddb/index-multientry.html [ Failure ]
    462 storage/indexeddb/index-population.html [ Failure ]
    463 storage/indexeddb/index-unique.html [ Failure ]
    464461storage/indexeddb/key-generator.html [ Failure ]
    465 storage/indexeddb/lazy-index-population.html [ Failure ]
    466 storage/indexeddb/lazy-index-types.html [ Failure ]
    467462storage/indexeddb/modern/cursor-7.html [ Failure ]
    468 storage/indexeddb/modern/deleteindex-1.html [ Failure ]
    469 storage/indexeddb/modern/deleteindex-2.html [ Failure ]
    470463storage/indexeddb/modern/get-keyrange.html [ Failure ]
    471464storage/indexeddb/modern/idbobjectstore-delete-1.html [ Failure ]
    472465storage/indexeddb/modern/index-3.html [ Failure ]
    473 storage/indexeddb/modern/index-4.html [ Failure ]
    474466storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
    475467storage/indexeddb/mozilla/cursors.html [ Failure ]
    476 storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Failure ]
    477 storage/indexeddb/mozilla/indexes.html [ Failure ]
    478468storage/indexeddb/objectstore-autoincrement.html [ Failure ]
    479 storage/indexeddb/objectstore-basics.html [ Failure ]
    480 storage/indexeddb/opencursor-key.html [ Failure ]
    481469
    482470# SQLite backend tests that timeout
  • trunk/Source/WebCore/ChangeLog

    r195764 r195765  
     12016-01-28  Brady Eidson  <beidson@apple.com>
     2
     3        Modern IDB: Index uniqueness broken in the SQLite backend.
     4        https://bugs.webkit.org/show_bug.cgi?id=153596
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (Many failing tests now pass, others improve).
     9
     10        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     11        (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
     12        (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord):
     13        (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexKey):
     14        (WebCore::IDBServer::SQLiteIDBBackingStore::updateOneIndexForAddRecord):
     15        (WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord):
     16        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
     17        (WebCore::IDBServer::SQLiteIDBBackingStore::updateIndexesForAddRecord): Deleted.
     18        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
     19
    1202016-01-08  Jer Noble  <jer.noble@apple.com>
    221
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r195697 r195765  
    712712IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
    713713{
     714    LOG(IndexedDB, "SQLiteIDBBackingStore::createIndex - ObjectStore %" PRIu64 ", Index %" PRIu64, info.objectStoreIdentifier(), info.identifier());
    714715    ASSERT(m_sqliteDB);
    715716    ASSERT(m_sqliteDB->isOpen());
     
    753754    }
    754755
    755     JSLockHolder locker(vm());
    756 
    757756    while (!cursor->currentKey().isNull()) {
    758757        auto& key = cursor->currentKey();
    759         auto& valueBuffer = cursor->currentValueBuffer();
    760 
    761         auto value = deserializeIDBValueBuffer(m_globalObject->globalExec(), Vector<uint8_t>(valueBuffer), true);
    762 
    763         IndexKey indexKey;
    764         generateIndexKeyForValue(*m_globalObject->globalExec(), info, value.jsValue(), indexKey);
    765 
    766         if (!info.multiEntry()) {
    767             IDBError error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey.asOneKey());
    768             if (!error.isNull()) {
    769                 LOG_ERROR("Unable to put index record for newly created index");
    770                 return error;
    771             }
    772         }
    773 
    774         Vector<IDBKeyData> indexKeys = indexKey.multiEntry();
    775 
    776         if (info.unique()) {
    777             bool hasRecord;
    778             IDBError error;
    779             for (auto& indexKey : indexKeys) {
    780                 error = uncheckedHasIndexRecord(info.identifier(), indexKey, hasRecord);
    781                 if (hasRecord)
    782                     return IDBError(IDBDatabaseException::ConstraintError);
    783                 if (!error.isNull())
    784                     return error;
    785             }
    786         }
    787 
    788         for (auto& indexKey : indexKeys) {
    789             IDBError error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey);
    790             if (!error.isNull()) {
    791                 LOG_ERROR("Unable to put index record for newly created index");
    792                 return error;
    793             }
     758        auto valueBuffer = ThreadSafeDataBuffer::copyVector(cursor->currentValueBuffer());
     759
     760        IDBError error = updateOneIndexForAddRecord(info, key, valueBuffer);
     761        if (!error.isNull()) {
     762            // FIXME: Remove this newly added index.
     763            return error;
    794764        }
    795765
     
    803773}
    804774
    805 IDBError SQLiteIDBBackingStore::uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData& indexKey, bool& hasRecord)
     775IDBError SQLiteIDBBackingStore::uncheckedHasIndexRecord(const IDBIndexInfo& info, const IDBKeyData& indexKey, bool& hasRecord)
    806776{
    807777    hasRecord = false;
     
    813783    }
    814784
    815     SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT rowid FROM IndexRecords WHERE indexID = ? AND key = CAST(? AS TEXT);"));
     785    SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT rowid FROM IndexRecords WHERE indexID = ? AND objectStoreID = ? AND key = CAST(? AS TEXT);"));
    816786    if (sql.prepare() != SQLITE_OK
    817         || sql.bindInt64(1, indexID) != SQLITE_OK
    818         || sql.bindBlob(2, indexKeyBuffer->data(), indexKeyBuffer->size()) != SQLITE_OK) {
     787        || sql.bindInt64(1, info.identifier()) != SQLITE_OK
     788        || sql.bindInt64(2, info.objectStoreIdentifier()) != SQLITE_OK
     789        || sql.bindBlob(3, indexKeyBuffer->data(), indexKeyBuffer->size()) != SQLITE_OK) {
    819790        LOG_ERROR("Error checking for index record in database");
    820791        return { IDBDatabaseException::UnknownError, ASCIILiteral("Error checking for index record in database") };
     
    837808IDBError SQLiteIDBBackingStore::uncheckedPutIndexKey(const IDBIndexInfo& info, const IDBKeyData& key, const IndexKey& indexKey)
    838809{
    839     if (!info.multiEntry()) {
    840         auto error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey.asOneKey());
    841         if (!error.isNull())
    842             LOG_ERROR("Unable to put index record for newly created index");
    843 
    844         return error;
    845     }
    846 
    847     Vector<IDBKeyData> indexKeys = indexKey.multiEntry();
     810    LOG(IndexedDB, "SQLiteIDBBackingStore::uncheckedPutIndexKey - (%" PRIu64 ") %s, %s", info.identifier(), key.loggingString().utf8().data(), indexKey.asOneKey().loggingString().utf8().data());
     811
     812    Vector<IDBKeyData> indexKeys;
     813    if (info.multiEntry())
     814        indexKeys = indexKey.multiEntry();
     815    else
     816        indexKeys.append(indexKey.asOneKey());
    848817
    849818    if (info.unique()) {
     
    851820        IDBError error;
    852821        for (auto& indexKey : indexKeys) {
    853             error = uncheckedHasIndexRecord(info.identifier(), indexKey, hasRecord);
     822            error = uncheckedHasIndexRecord(info, indexKey, hasRecord);
    854823            if (!error.isNull())
    855824                return error;
     
    10661035}
    10671036
    1068 IDBError SQLiteIDBBackingStore::updateIndexesForAddRecord(const IDBObjectStoreInfo& info, const IDBKeyData& key, const ThreadSafeDataBuffer& value)
     1037IDBError SQLiteIDBBackingStore::updateOneIndexForAddRecord(const IDBIndexInfo& info, const IDBKeyData& key, const ThreadSafeDataBuffer& value)
     1038{
     1039    JSLockHolder locker(vm());
     1040
     1041    auto jsValue = deserializeIDBValueDataToJSValue(*globalObject().globalExec(), value);
     1042    if (jsValue.isUndefinedOrNull())
     1043        return { };
     1044
     1045    IndexKey indexKey;
     1046    generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue, indexKey);
     1047
     1048    if (indexKey.isNull())
     1049        return { };
     1050
     1051    return uncheckedPutIndexKey(info, key, indexKey);
     1052}
     1053
     1054IDBError SQLiteIDBBackingStore::updateAllIndexesForAddRecord(const IDBObjectStoreInfo& info, const IDBKeyData& key, const ThreadSafeDataBuffer& value)
    10691055{
    10701056    JSLockHolder locker(vm());
     
    11311117    }
    11321118
    1133     auto error = updateIndexesForAddRecord(objectStoreInfo, keyData, value);
     1119    auto error = updateAllIndexesForAddRecord(objectStoreInfo, keyData, value);
    11341120
    11351121    // FIXME: If there was an error indexing this record, remove it.
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h

    r195689 r195765  
    8989
    9090    IDBError deleteRecord(SQLiteIDBTransaction&, int64_t objectStoreID, const IDBKeyData&);
     91    IDBError uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue);
     92    IDBError uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value);
     93
     94    IDBError updateAllIndexesForAddRecord(const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
     95    IDBError updateOneIndexForAddRecord(const IDBIndexInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
    9196    IDBError uncheckedPutIndexKey(const IDBIndexInfo&, const IDBKeyData& keyValue, const IndexKey&);
    9297    IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData& keyValue, const IDBKeyData& indexKey);
    93     IDBError uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData&, bool& hasRecord);
    94     IDBError uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue);
    95     IDBError uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value);
    96     IDBError updateIndexesForAddRecord(const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
     98    IDBError uncheckedHasIndexRecord(const IDBIndexInfo&, const IDBKeyData&, bool& hasRecord);
    9799
    98100    JSC::VM& vm();
Note: See TracChangeset for help on using the changeset viewer.