Changeset 163849 in webkit


Ignore:
Timestamp:
Feb 10, 2014 6:29:22 PM (10 years ago)
Author:
beidson@apple.com
Message:

IDB: storage/indexeddb/mozilla/indexes.html fails
<rdar://problem/16031590> and https://bugs.webkit.org/show_bug.cgi?id=128563

Reviewed by Tim Horton.

Source/WebCore:

Tested by storage/indexeddb/mozilla/indexes.html (and probably others)

  • Modules/indexeddb/IDBGetResult.h:

(WebCore::IDBGetResult::IDBGetResult): Add a constructor that takes an IDBKeyData argument.

  • Modules/indexeddb/IDBRequest.cpp:

(WebCore::IDBRequest::onSuccess): If there’s no keyPath then skip the injection step.

Source/WebKit2:

  • DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:

(WebKit::UniqueIDBDatabase::getRecordFromBackingStore): Pass the cursor type to the backing store.

  • DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
  • DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:

(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getIndexRecord): If it’s a key-only cursor,

return only the key result.

  • DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
  • DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:

(WebKit::getIndexStatement): Fix index statement selection so ascending, unique cursors sort correctly.

LayoutTests:

  • platform/mac-wk2/TestExpectations: Add the test (still skipped for now due to unrelated reasons).
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163840 r163849  
     12014-02-10  Brady Eidson  <beidson@apple.com>
     2
     3        IDB: storage/indexeddb/mozilla/indexes.html fails
     4        <rdar://problem/16031590> and https://bugs.webkit.org/show_bug.cgi?id=128563
     5
     6        Reviewed by Tim Horton.
     7
     8        * platform/mac-wk2/TestExpectations: Add the test (still skipped for now due to unrelated reasons).
     9
    1102014-02-09  Dean Jackson  <dino@apple.com>
    211
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r163817 r163849  
    481481# storage/indexeddb/mozilla/cursors.html [ Pass ]
    482482# storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Pass ]
     483# storage/indexeddb/mozilla/indexes.html [ Pass ]
    483484# storage/indexeddb/mozilla/object-cursors.html [ Pass ]
    484485# storage/indexeddb/mozilla/object-store-remove-values.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r163847 r163849  
     12014-02-10  Brady Eidson  <beidson@apple.com>
     2
     3        IDB: storage/indexeddb/mozilla/indexes.html fails
     4        <rdar://problem/16031590> and https://bugs.webkit.org/show_bug.cgi?id=128563
     5
     6        Reviewed by Tim Horton.
     7
     8        Tested by storage/indexeddb/mozilla/indexes.html (and probably others)
     9
     10        * Modules/indexeddb/IDBGetResult.h:
     11        (WebCore::IDBGetResult::IDBGetResult): Add a constructor that takes an IDBKeyData argument.
     12
     13        * Modules/indexeddb/IDBRequest.cpp:
     14        (WebCore::IDBRequest::onSuccess): If there’s no keyPath then skip the injection step.
     15
    1162014-02-10  Benjamin Poulain  <benjamin@webkit.org>
    217
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h

    r162633 r163849  
    5151    }
    5252
     53    IDBGetResult(const IDBKeyData& keyData)
     54        : keyData(keyData)
     55    {
     56    }
     57
    5358    IDBGetResult(PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey> key, const IDBKeyPath& path)
    5459        : valueBuffer(buffer)
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r163627 r163849  
    364364
    365365    RefPtr<IDBKey> primaryKey = prpPrimaryKey;
     366
     367    if (!keyPath.isNull()) {
    366368#ifndef NDEBUG
    367     RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(requestState()->exec(), value, keyPath);
    368     ASSERT(!expectedKey || expectedKey->isEqual(primaryKey.get()));
     369        RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(requestState()->exec(), value, keyPath);
     370        ASSERT(!expectedKey || expectedKey->isEqual(primaryKey.get()));
    369371#endif
    370     bool injected = injectIDBKeyIntoScriptValue(requestState(), primaryKey, value, keyPath);
    371     ASSERT_UNUSED(injected, injected);
     372        bool injected = injectIDBKeyIntoScriptValue(requestState(), primaryKey, value, keyPath);
     373        ASSERT_UNUSED(injected, injected);
     374    }
     375
    372376    onSuccessInternal(value);
    373377}
  • trunk/Source/WebKit2/ChangeLog

    r163848 r163849  
     12014-02-10  Brady Eidson  <beidson@apple.com>
     2
     3        IDB: storage/indexeddb/mozilla/indexes.html fails
     4        <rdar://problem/16031590> and https://bugs.webkit.org/show_bug.cgi?id=128563
     5
     6        Reviewed by Tim Horton.
     7
     8        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
     9        (WebKit::UniqueIDBDatabase::getRecordFromBackingStore): Pass the cursor type to the backing store.
     10
     11        * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
     12        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
     13        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getIndexRecord): If it’s a key-only cursor,
     14          return only the key result.
     15        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
     16
     17        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
     18        (WebKit::getIndexStatement): Fix index statement selection so ascending, unique cursors sort correctly.
     19
    1202014-02-10  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp

    r163817 r163849  
    925925
    926926    IDBGetResult result;
    927     if (!m_backingStore->getIndexRecord(transaction, objectStoreMetadata.id, indexID, keyRangeData, result)) {
     927    if (!m_backingStore->getIndexRecord(transaction, objectStoreMetadata.id, indexID, keyRangeData, cursorType, result)) {
    928928        postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("Failed to get index record from backing store")));
    929929        return;
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h

    r163662 r163849  
    7272    virtual bool putRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyData&, const uint8_t* valueBuffer, size_t valueSize) = 0;
    7373    virtual bool putIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData&, const WebCore::IDBKeyData& indexKey) = 0;
    74     virtual bool getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IDBGetResult&) = 0;
     74    virtual bool getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IndexedDB::CursorType, WebCore::IDBGetResult&) = 0;
    7575    virtual bool deleteRange(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRangeData&) = 0;
    7676    virtual bool deleteRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyData&) = 0;
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp

    r163741 r163849  
    7373
    7474    if (indexStatements.isEmpty()) {
    75         indexStatements.reserveInitialCapacity(16);
     75        indexStatements.reserveInitialCapacity(12);
    7676
    7777        // Lower missing/open, upper missing/open.
    7878        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key, value;"));
    79         indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key, value DESC;"));
    8079        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key DESC, value DESC;"));
    8180        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key DESC, value;"));
     
    8382        // Lower missing/open, upper closed.
    8483        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key, value;"));
    85         indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key, value DESC;"));
    8684        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key DESC, value DESC;"));
    8785        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key DESC, value;"));
     
    8987        // Lower closed, upper missing/open.
    9088        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key, value;"));
    91         indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key, value DESC;"));
    9289        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key DESC, value DESC;"));
    9390        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key DESC, value;"));
     
    9592        // Lower closed, upper closed.
    9693        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key, value;"));
    97         indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key, value DESC;"));
    9894        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key DESC, value DESC;"));
    9995        indexStatements.uncheckedAppend(ASCIILiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key DESC, value;"));
     
    10399
    104100    if (hasLowerKey && !isLowerOpen)
    105         i += 8;
     101        i += 6;
    106102
    107103    if (hasUpperKey && !isUpperOpen)
    108         i += 4;
    109 
    110     if (descending)
    111         i += 2;
    112 
    113     if (unique)
    114         i += 1;
     104        i += 3;
     105
     106    if (descending) {
     107        if (!unique)
     108            i += 1;
     109        else
     110            i += 2;
     111    }
    115112
    116113    return indexStatements[i];
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp

    r163818 r163849  
    910910}
    911911
    912 bool UniqueIDBDatabaseBackingStoreSQLite::getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const IDBKeyRangeData& keyRangeData, IDBGetResult& result)
     912bool UniqueIDBDatabaseBackingStoreSQLite::getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const IDBKeyRangeData& keyRangeData, IndexedDB::CursorType cursorType, IDBGetResult& result)
    913913{
    914914    ASSERT(!isMainThread());
     
    922922    }
    923923
    924     SQLiteIDBCursor* cursor = transaction->openCursor(objectStoreID, indexID, IndexedDB::CursorDirection::Next, IndexedDB::CursorType::KeyAndValue, IDBDatabaseBackend::NormalTask, keyRangeData);
     924    SQLiteIDBCursor* cursor = transaction->openCursor(objectStoreID, indexID, IndexedDB::CursorDirection::Next, cursorType, IDBDatabaseBackend::NormalTask, keyRangeData);
    925925
    926926    if (!cursor) {
     
    932932    m_cursors.set(cursor->identifier(), cursor);
    933933
    934     result = IDBGetResult(SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()));
    935     result.keyData = cursor->currentPrimaryKey();
     934    if (cursorType == IndexedDB::CursorType::KeyOnly)
     935        result = IDBGetResult(cursor->currentPrimaryKey());
     936    else {
     937        result = IDBGetResult(SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()));
     938        result.keyData = cursor->currentPrimaryKey();
     939    }
    936940
    937941    // Closing the cursor will destroy the cursor object and remove it from our cursor set.
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h

    r163662 r163849  
    8181    virtual bool putRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyData&, const uint8_t* valueBuffer, size_t valueSize) override;
    8282    virtual bool putIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData& keyValue, const WebCore::IDBKeyData& indexKey) override;
    83     virtual bool getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IDBGetResult&) override;
     83    virtual bool getIndexRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IndexedDB::CursorType, WebCore::IDBGetResult&) override;
    8484    virtual bool deleteRange(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRangeData&) override;
    8585    virtual bool deleteRecord(const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyData&) override;
Note: See TracChangeset for help on using the changeset viewer.