Title: [162682] trunk/Source
Revision
162682
Author
beid...@apple.com
Date
2014-01-23 19:52:30 -0800 (Thu, 23 Jan 2014)

Log Message

IDB: Implement SQLite backing store 'get' support
https://bugs.webkit.org/show_bug.cgi?id=127502

Reviewed by Tim Horton.

Source/WebCore:

Get a KeyRange from a KeyRangeData:
* Modules/indexeddb/IDBKeyRangeData.cpp:
(WebCore::IDBKeyRangeData::maybeCreateIDBKeyRange):
* Modules/indexeddb/IDBKeyRangeData.h:

Add collation function support to SQLiteDatabase:
* platform/sql/SQLiteDatabase.cpp:
(WebCore::destroyCollationFunction):
(WebCore::callCollationFunction):
(WebCore::SQLiteDatabase::setCollationFunction):
(WebCore::SQLiteDatabase::removeCollationFunction):
* platform/sql/SQLiteDatabase.h:

* WebCore.exp.in:

Source/WebKit2:

This makes get of a single IDBKey work, and lays the groundwork for getting an IDBKeyRange.

* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::getRecordFromBackingStore):
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:

* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata): Add custom collation
  to the Records table.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata): Install the custom collator.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRecordFromObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRangeRecordFromObjectStore):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::collate): Collation function to be filled in later.
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162681 => 162682)


--- trunk/Source/WebCore/ChangeLog	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/ChangeLog	2014-01-24 03:52:30 UTC (rev 162682)
@@ -1,3 +1,25 @@
+2014-01-23  Brady Eidson  <beid...@apple.com>
+
+        IDB: Implement SQLite backing store 'get' support
+        https://bugs.webkit.org/show_bug.cgi?id=127502
+
+        Reviewed by Tim Horton.
+
+        Get a KeyRange from a KeyRangeData:
+        * Modules/indexeddb/IDBKeyRangeData.cpp:
+        (WebCore::IDBKeyRangeData::maybeCreateIDBKeyRange):
+        * Modules/indexeddb/IDBKeyRangeData.h:
+
+        Add collation function support to SQLiteDatabase:
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::destroyCollationFunction):
+        (WebCore::callCollationFunction):
+        (WebCore::SQLiteDatabase::setCollationFunction):
+        (WebCore::SQLiteDatabase::removeCollationFunction):
+        * platform/sql/SQLiteDatabase.h:
+
+        * WebCore.exp.in:
+
 2014-01-23  Jon Honeycutt  <jhoneyc...@apple.com>
 
         Assertion failure in WebCore::PseudoElement::didRecalcStyle()

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp (162681 => 162682)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp	2014-01-24 03:52:30 UTC (rev 162682)
@@ -43,6 +43,14 @@
     return result;
 }
 
+PassRefPtr<IDBKeyRange> IDBKeyRangeData::maybeCreateIDBKeyRange() const
+{
+    if (isNull)
+        return nullptr;
+
+    return IDBKeyRange::create(lowerKey.maybeCreateIDBKey(), upperKey.maybeCreateIDBKey(), lowerOpen ? IDBKeyRange::LowerBoundOpen : IDBKeyRange::LowerBoundClosed, upperOpen ? IDBKeyRange::UpperBoundOpen : IDBKeyRange::UpperBoundClosed);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h (162681 => 162682)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h	2014-01-24 03:52:30 UTC (rev 162682)
@@ -57,6 +57,8 @@
 
     IDBKeyRangeData isolatedCopy() const;
 
+    PassRefPtr<IDBKeyRange> maybeCreateIDBKeyRange() const;
+
     bool isNull;
 
     IDBKeyData lowerKey;

Modified: trunk/Source/WebCore/WebCore.exp.in (162681 => 162682)


--- trunk/Source/WebCore/WebCore.exp.in	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-01-24 03:52:30 UTC (rev 162682)
@@ -84,6 +84,7 @@
 __ZN7WebCore10RenderView7hitTestERKNS_14HitTestRequestERNS_13HitTestResultE
 __ZN7WebCore15SQLiteStatement13getColumnBlobEiRi
 __ZN7WebCore15SQLiteStatement14getColumnInt64Ei
+__ZN7WebCore15SQLiteStatement21getColumnBlobAsVectorEiRN3WTF6VectorIcLm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore10ScrollView16setParentVisibleEb
 __ZN7WebCore10ScrollView17setUseFixedLayoutEb
 __ZN7WebCore10ScrollView18setFixedLayoutSizeERKNS_7IntSizeE
@@ -374,6 +375,7 @@
 __ZN7WebCore14ResourceLoader6cancelEv
 __ZN7WebCore14SQLiteDatabase11tableExistsERKN3WTF6StringE
 __ZN7WebCore14SQLiteDatabase12lastErrorMsgEv
+__ZN7WebCore14SQLiteDatabase20setCollationFunctionERKN3WTF6StringENSt3__18functionIFiiPKviS8_EEE
 __ZN7WebCore14SQLiteDatabase14executeCommandERKN3WTF6StringE
 __ZN7WebCore14SQLiteDatabase4openERKN3WTF6StringEb
 __ZN7WebCore14SQLiteDatabase5closeEv
@@ -3081,6 +3083,8 @@
 #if ENABLE(INDEXED_DATABASE)
 __ZNK7WebCore10IDBKeyData17maybeCreateIDBKeyEv
 __ZNK7WebCore10IDBKeyPath6encodeERNS_12KeyedEncoderE
+__ZNK7WebCore11IDBKeyRange9isOnlyKeyEv
+__ZNK7WebCore15IDBKeyRangeData22maybeCreateIDBKeyRangeEv
 __ZNK7WebCore6IDBKey6encodeERNS_12KeyedEncoderE
 __ZNK7WebCore6IDBKey7isValidEv
 __ZN7WebCore10IDBKeyDataC1EPNS_6IDBKeyE

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (162681 => 162682)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2014-01-24 03:52:30 UTC (rev 162682)
@@ -506,4 +506,27 @@
     }
 }
 
+static void destroyCollationFunction(void* arg)
+{
+    auto f = static_cast<std::function<int(int, const void*, int, const void*)>*>(arg);
+    delete f;
+}
+
+static int callCollationFunction(void* arg, int aLength, const void* a, int bLength, const void* b)
+{
+    auto f = static_cast<std::function<int(int, const void*, int, const void*)>*>(arg);
+    return (*f)(aLength, a, bLength, b);
+}
+
+void SQLiteDatabase::setCollationFunction(const String& collationName, std::function<int(int, const void*, int, const void*)> collationFunction)
+{
+    auto functionObject = new std::function<int(int, const void*, int, const void*)>(collationFunction);
+    sqlite3_create_collation_v2(m_db, collationName.utf8().data(), SQLITE_UTF8, functionObject, callCollationFunction, destroyCollationFunction);
+}
+
+void SQLiteDatabase::removeCollationFunction(const String& collationName)
+{
+    sqlite3_create_collation_v2(m_db, collationName.utf8().data(), SQLITE_UTF8, nullptr, nullptr, nullptr);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.h (162681 => 162682)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2014-01-24 03:52:30 UTC (rev 162682)
@@ -27,6 +27,7 @@
 #ifndef SQLiteDatabase_h
 #define SQLiteDatabase_h
 
+#include <functional>
 #include <wtf/Threading.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -130,6 +131,9 @@
     enum AutoVacuumPragma { AutoVacuumNone = 0, AutoVacuumFull = 1, AutoVacuumIncremental = 2 };
     bool turnOnIncrementalAutoVacuum();
 
+    void setCollationFunction(const String& collationName, std::function<int(int, const void*, int, const void*)>);
+    void removeCollationFunction(const String& collationName);
+
     // Set this flag to allow access from multiple threads.  Not all multi-threaded accesses are safe!
     // See http://www.sqlite.org/cvstrac/wiki?p=MultiThreading for more info.
 #ifndef NDEBUG

Modified: trunk/Source/WebKit2/ChangeLog (162681 => 162682)


--- trunk/Source/WebKit2/ChangeLog	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebKit2/ChangeLog	2014-01-24 03:52:30 UTC (rev 162682)
@@ -1,3 +1,25 @@
+2014-01-23  Brady Eidson  <beid...@apple.com>
+
+        IDB: Implement SQLite backing store 'get' support
+        https://bugs.webkit.org/show_bug.cgi?id=127502
+
+        Reviewed by Tim Horton.
+
+        This makes get of a single IDBKey work, and lays the groundwork for getting an IDBKeyRange.
+
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::getRecordFromBackingStore):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
+
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata): Add custom collation
+          to the Records table.
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata): Install the custom collator.
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRecordFromObjectStore):
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getKeyRangeRecordFromObjectStore):
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::collate): Collation function to be filled in later.
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
+
 2014-01-23  Jon Honeycutt  <jhoneyc...@apple.com>
 
         Assertion failure in WebCore::PseudoElement::didRecalcStyle()

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp (162681 => 162682)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp	2014-01-24 03:52:30 UTC (rev 162682)
@@ -577,11 +577,45 @@
     request->completeRequest(keyData, errorCode, errorMessage);
 }
 
-void UniqueIDBDatabase::getRecordFromBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IndexedDB::CursorType)
+void UniqueIDBDatabase::getRecordFromBackingStore(uint64_t requestID, const IDBTransactionIdentifier& transaction, const WebCore::IDBObjectStoreMetadata& objectStoreMetadata, int64_t indexID, const WebCore::IDBKeyRangeData& keyRangeData, WebCore::IndexedDB::CursorType cursorType)
 {
-    // FIXME: Implement (https://bugs.webkit.org/show_bug.cgi?id=127502)
+    ASSERT(!isMainThread());
+    ASSERT(m_backingStore);
 
-    postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("'get' support not yet implemented")));
+    RefPtr<IDBKeyRange> keyRange = keyRangeData.maybeCreateIDBKeyRange();
+    ASSERT(keyRange);
+    if (!keyRange) {
+        postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("Invalid IDBKeyRange requested from backing store")));
+        return;
+    }
+
+    if (indexID == IDBIndexMetadata::InvalidId) {
+        // IDBObjectStore get record
+        RefPtr<SharedBuffer> result;
+
+        if (keyRange->isOnlyKey()) {
+            if (!m_backingStore->getKeyRecordFromObjectStore(transaction, objectStoreMetadata.id, *keyRange->lower(), result))
+                postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("Failed to get key record from object store in backing store")));
+            else
+                postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(result.release()), 0, String(StringImpl::empty())));
+
+            return;
+        }
+
+        RefPtr<IDBKey> resultKey;
+
+        if (!m_backingStore->getKeyRangeRecordFromObjectStore(transaction, objectStoreMetadata.id, *keyRange, result, resultKey))
+            postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("Failed to get key range record from object store in backing store")));
+        else
+            postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(result.release(), resultKey.release(), IDBKeyPath()), 0, String(StringImpl::empty())));
+
+        return;
+    }
+
+    // IDBIndex get record
+
+    // FIXME: Implement index gets (<rdar://problem/15779642>)
+    postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didGetRecordFromBackingStore, requestID, IDBGetResult(), IDBDatabaseException::UnknownError, ASCIILiteral("'get' from indexes not supported yet")));
 }
 
 void UniqueIDBDatabase::didGetRecordFromBackingStore(uint64_t requestID, const IDBGetResult& result, uint32_t errorCode, const String& errorMessage)

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h (162681 => 162682)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h	2014-01-24 03:52:30 UTC (rev 162682)
@@ -33,6 +33,8 @@
 
 namespace WebCore {
 class IDBKey;
+class IDBKeyRange;
+class SharedBuffer;
 
 struct IDBDatabaseMetadata;
 struct IDBObjectStoreMetadata;
@@ -63,7 +65,8 @@
     virtual bool putRecord(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, const uint8_t* valueBuffer, size_t valueSize) = 0;
     virtual bool updateKeyGenerator(const IDBTransactionIdentifier&, int64_t objectStoreId, const WebCore::IDBKey&, bool checkCurrent) = 0;
 
-
+    virtual bool getKeyRecordFromObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, RefPtr<WebCore::SharedBuffer>& result) = 0;
+    virtual bool getKeyRangeRecordFromObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKeyRange&, RefPtr<WebCore::SharedBuffer>& result, RefPtr<WebCore::IDBKey>& resultKey) = 0;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp (162681 => 162682)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp	2014-01-24 03:52:30 UTC (rev 162682)
@@ -34,8 +34,10 @@
 #include <WebCore/FileSystem.h>
 #include <WebCore/IDBDatabaseMetadata.h>
 #include <WebCore/IDBKeyData.h>
+#include <WebCore/IDBKeyRange.h>
 #include <WebCore/SQLiteDatabase.h>
 #include <WebCore/SQLiteStatement.h>
+#include <WebCore/SharedBuffer.h>
 #include <wtf/MainThread.h>
 
 using namespace WebCore;
@@ -90,7 +92,7 @@
         return nullptr;
     }
 
-    if (!m_sqliteDB->executeCommand("CREATE TABLE Records (objectStoreID INTEGER NOT NULL ON CONFLICT FAIL, key BLOB NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL);")) {
+    if (!m_sqliteDB->executeCommand("CREATE TABLE Records (objectStoreID INTEGER NOT NULL ON CONFLICT FAIL, key BLOB COLLATE IDBKEY NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL);")) {
         LOG_ERROR("Could not create Records table in database (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
         m_sqliteDB = nullptr;
         return nullptr;
@@ -247,6 +249,11 @@
     if (!m_sqliteDB)
         return nullptr;
 
+    RefPtr<UniqueIDBDatabaseBackingStoreSQLite> protector(this);
+    m_sqliteDB->setCollationFunction("IDBKEY", [this](int aLength, const void* a, int bLength, const void* b) {
+        return collate(aLength, a, bLength, b);
+    });
+
     std::unique_ptr<IDBDatabaseMetadata> metadata = extractExistingMetadata();
     if (!metadata)
         metadata = createAndPopulateInitialMetadata();
@@ -476,7 +483,112 @@
     return false;
 }
 
+bool UniqueIDBDatabaseBackingStoreSQLite::getKeyRecordFromObjectStore(const IDBTransactionIdentifier& identifier, int64_t objectStoreID, const WebCore::IDBKey& key, RefPtr<WebCore::SharedBuffer>& result)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
 
+    SQLiteIDBTransaction* transaction = m_transactions.get(identifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to put a record into database without an established, in-progress transaction");
+        return false;
+    }
+
+    RefPtr<SharedBuffer> keyBuffer = serializeIDBKey(key);
+    if (!keyBuffer) {
+        LOG_ERROR("Unable to serialize IDBKey to be stored in the database");
+        return false;
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT value FROM Records WHERE objectStoreID = ? AND key = ?;"));
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.bindBlob(2, keyBuffer->data(), keyBuffer->size()) != SQLResultOk) {
+            LOG_ERROR("Could not get record from object store %lli from Records table (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+
+        int sqlResult = sql.step();
+        if (sqlResult == SQLResultOk || sqlResult == SQLResultDone) {
+            // There was no record for the key in the database.
+            return true;
+        }
+        if (sqlResult != SQLResultRow) {
+            // There was an error fetching the record from the database.
+            LOG_ERROR("Could not get record from object store %lli from Records table (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+
+        Vector<char> buffer;
+        sql.getColumnBlobAsVector(0, buffer);
+        result = SharedBuffer::create(static_cast<const char*>(buffer.data()), buffer.size());
+    }
+
+    return true;
+}
+
+bool UniqueIDBDatabaseBackingStoreSQLite::getKeyRangeRecordFromObjectStore(const IDBTransactionIdentifier& identifier, int64_t objectStoreID, const WebCore::IDBKeyRange& keyRange, RefPtr<WebCore::SharedBuffer>& result, RefPtr<WebCore::IDBKey>& resultKey)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    SQLiteIDBTransaction* transaction = m_transactions.get(identifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to put a record into database without an established, in-progress transaction");
+        return false;
+    }
+
+    RefPtr<SharedBuffer> lowerBuffer = serializeIDBKey(*keyRange.lower());
+    if (!lowerBuffer) {
+        LOG_ERROR("Unable to serialize IDBKey to be stored in the database");
+        return false;
+    }
+
+    RefPtr<SharedBuffer> upperBuffer = serializeIDBKey(*keyRange.upper());
+    if (!upperBuffer) {
+        LOG_ERROR("Unable to serialize IDBKey to be stored in the database");
+        return false;
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT value FROM Records WHERE objectStoreID = ? AND key >= ? AND key <= ? ORDER BY key;"));
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.bindBlob(2, lowerBuffer->data(), lowerBuffer->size()) != SQLResultOk
+            || sql.bindBlob(3, upperBuffer->data(), upperBuffer->size()) != SQLResultOk) {
+            LOG_ERROR("Could not get key range record from object store %lli from Records table (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+
+        int sqlResult = sql.step();
+
+        if (sqlResult == SQLResultOk || sqlResult == SQLResultDone) {
+            // There was no record for the key in the database.
+            return true;
+        }
+        if (sqlResult != SQLResultRow) {
+            // There was an error fetching the record from the database.
+            LOG_ERROR("Could not get record from object store %lli from Records table (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+
+        Vector<char> buffer;
+        sql.getColumnBlobAsVector(0, buffer);
+        result = SharedBuffer::create(static_cast<const char*>(buffer.data()), buffer.size());
+    }
+
+    return true;
+}
+
+int UniqueIDBDatabaseBackingStoreSQLite::collate(int aLength, const void* a, int bLength, const void* b)
+{
+    // FIXME: Implement
+    return 0;
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h (162681 => 162682)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h	2014-01-24 03:41:22 UTC (rev 162681)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h	2014-01-24 03:52:30 UTC (rev 162682)
@@ -69,6 +69,9 @@
     virtual bool putRecord(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, const uint8_t* valueBuffer, size_t valueSize) override;
     virtual bool updateKeyGenerator(const IDBTransactionIdentifier&, int64_t objectStoreId, const WebCore::IDBKey&, bool checkCurrent) override;
 
+    virtual bool getKeyRecordFromObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, RefPtr<WebCore::SharedBuffer>& result) override;
+    virtual bool getKeyRangeRecordFromObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKeyRange&, RefPtr<WebCore::SharedBuffer>& result, RefPtr<WebCore::IDBKey>& resultKey) override;
+
 private:
     UniqueIDBDatabaseBackingStoreSQLite(const UniqueIDBDatabaseIdentifier&, const String& databaseDirectory);
 
@@ -76,6 +79,8 @@
     std::unique_ptr<WebCore::IDBDatabaseMetadata> extractExistingMetadata();
     std::unique_ptr<WebCore::IDBDatabaseMetadata> createAndPopulateInitialMetadata();
 
+    int collate(int aLength, const void* a, int bLength, const void* b);
+
     UniqueIDBDatabaseIdentifier m_identifier;
     String m_absoluteDatabaseDirectory;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to