<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[195689] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195689">195689</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-01-27 13:57:22 -0800 (Wed, 27 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Modern IDB: SQLite backend doesn't update index records as object records are added.
https://bugs.webkit.org/show_bug.cgi?id=153548
Reviewed by Alex Christensen.
Source/WebCore:
No new tests (4 more tests pass, others improve).
* Modules/indexeddb/server/IDBBackingStore.h:
* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::initializeVM):
(WebCore::IDBServer::SQLiteIDBBackingStore::vm):
(WebCore::IDBServer::SQLiteIDBBackingStore::globalObject):
(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexKey):
(WebCore::IDBServer::SQLiteIDBBackingStore::updateIndexesForAddRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
* Modules/indexeddb/shared/IDBObjectStoreInfo.h:
LayoutTests:
* platform/mac-wk1/TestExpectations:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedIDBObjectStoreInfoh">trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/LayoutTests/ChangeLog        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -1,5 +1,14 @@
</span><span class="cx"> 2016-01-27 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><ins>+ Modern IDB: SQLite backend doesn't update index records as object records are added.
+ https://bugs.webkit.org/show_bug.cgi?id=153548
+
+ Reviewed by Alex Christensen.
+
+ * platform/mac-wk1/TestExpectations:
+
+2016-01-27 Brady Eidson <beidson@apple.com>
+
</ins><span class="cx"> LayoutTest fast/loader/stateobjects/replacestate-frequency-iframe.html is flaky on El Cap, always times out on Yosemite.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=153551
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -464,11 +464,8 @@
</span><span class="cx"> storage/indexeddb/cursor-inconsistency.html [ Failure ]
</span><span class="cx"> storage/indexeddb/cursor-index-delete.html [ Failure ]
</span><span class="cx"> storage/indexeddb/cursor-key-order.html [ Failure ]
</span><del>-storage/indexeddb/cursor-overloads.html [ Failure ]
</del><span class="cx"> storage/indexeddb/cursor-prev-no-duplicate.html [ Failure ]
</span><span class="cx"> storage/indexeddb/cursor-primary-key-order.html [ Failure ]
</span><del>-storage/indexeddb/cursor-properties.html [ Failure ]
-storage/indexeddb/cursor-reverse-bug.html [ Failure ]
</del><span class="cx"> storage/indexeddb/cursor-skip-deleted.html [ Failure ]
</span><span class="cx"> storage/indexeddb/cursor-update.html [ Failure ]
</span><span class="cx"> storage/indexeddb/cursor-value.html [ Failure ]
</span><span class="lines">@@ -515,7 +512,6 @@
</span><span class="cx"> storage/indexeddb/modern/objectstore-cursor-advance-failures.html [ Failure ]
</span><span class="cx"> storage/indexeddb/modern/objectstore-cursor-continue-failures.html [ Failure ]
</span><span class="cx"> storage/indexeddb/modern/request-readystate.html [ Failure ]
</span><del>-storage/indexeddb/mozilla/autoincrement-indexes.html [ Failure ]
</del><span class="cx"> storage/indexeddb/mozilla/clear.html [ Failure ]
</span><span class="cx"> storage/indexeddb/mozilla/cursor-mutation-objectstore-only.html [ Failure ]
</span><span class="cx"> storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/ChangeLog        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-01-27 Brady Eidson <beidson@apple.com>
+
+ Modern IDB: SQLite backend doesn't update index records as object records are added.
+ https://bugs.webkit.org/show_bug.cgi?id=153548
+
+ Reviewed by Alex Christensen.
+
+ No new tests (4 more tests pass, others improve).
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::initializeVM):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::vm):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::globalObject):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexKey):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::updateIndexesForAddRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+
+ * Modules/indexeddb/shared/IDBObjectStoreInfo.h:
+
</ins><span class="cx"> 2016-01-27 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> Add API to access closed shadowRoot in InjectedBundle
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;
</span><span class="cx"> virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
</span><span class="cx"> virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
</span><del>- virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
</del><ins>+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
</ins><span class="cx"> virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
</span><span class="cx"> virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
</span><span class="cx"> virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -266,17 +266,17 @@
</span><span class="cx"> return IDBError();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
</del><ins>+IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
</ins><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
</span><span class="cx">
</span><del>- ASSERT(objectStoreIdentifier);
</del><ins>+ ASSERT(objectStoreInfo.identifier());
</ins><span class="cx">
</span><span class="cx"> auto transaction = m_transactions.get(transactionIdentifier);
</span><span class="cx"> if (!transaction)
</span><span class="cx"> return IDBError(IDBDatabaseException::UnknownError, ASCIILiteral("No backing store transaction found to put record"));
</span><span class="cx">
</span><del>- MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
</del><ins>+ MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreInfo.identifier());
</ins><span class="cx"> if (!objectStore)
</span><span class="cx"> return IDBError(IDBDatabaseException::UnknownError, ASCIILiteral("No backing store object store found to put record"));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) override final;
</span><span class="cx"> virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) override final;
</span><span class="cx"> virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) override final;
</span><del>- virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
</del><ins>+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
</ins><span class="cx"> virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) override final;
</span><span class="cx"> virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) override final;
</span><span class="cx"> virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "IDBDatabaseException.h"
</span><span class="cx"> #include "IDBGetResult.h"
</span><span class="cx"> #include "IDBKeyData.h"
</span><ins>+#include "IDBObjectStoreInfo.h"
</ins><span class="cx"> #include "IDBSerialization.h"
</span><span class="cx"> #include "IDBTransactionInfo.h"
</span><span class="cx"> #include "IndexKey.h"
</span><span class="lines">@@ -126,6 +127,30 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+void SQLiteIDBBackingStore::initializeVM()
+{
+ if (!m_vm) {
+ ASSERT(!m_globalObject);
+ m_vm = VM::create();
+
+ JSLockHolder locker(m_vm.get());
+ m_globalObject.set(*m_vm, JSGlobalObject::create(*m_vm, JSGlobalObject::createStructure(*m_vm, jsNull())));
+ }
+}
+
+VM& SQLiteIDBBackingStore::vm()
+{
+ initializeVM();
+ return *m_vm;
+}
+
+JSGlobalObject& SQLiteIDBBackingStore::globalObject()
+{
+ initializeVM();
+ return **m_globalObject;
+}
+
</ins><span class="cx"> static bool createOrMigrateRecordsTableIfNecessary(SQLiteDatabase& database)
</span><span class="cx"> {
</span><span class="cx"> String currentSchema;
</span><span class="lines">@@ -727,16 +752,8 @@
</span><span class="cx"> return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to populate indexes in database") };
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!m_vm) {
- ASSERT(!m_globalObject);
- m_vm = VM::create();
- }
</del><ins>+ JSLockHolder locker(vm());
</ins><span class="cx">
</span><del>- JSLockHolder locker(m_vm.get());
-
- if (!m_globalObject)
- m_globalObject.set(*m_vm, JSGlobalObject::create(*m_vm, JSGlobalObject::createStructure(*m_vm, jsNull())));
-
</del><span class="cx"> while (!cursor->currentKey().isNull()) {
</span><span class="cx"> auto& key = cursor->currentKey();
</span><span class="cx"> auto& valueBuffer = cursor->currentValueBuffer();
</span><span class="lines">@@ -817,7 +834,41 @@
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+IDBError SQLiteIDBBackingStore::uncheckedPutIndexKey(const IDBIndexInfo& info, const IDBKeyData& key, const IndexKey& indexKey)
+{
+ if (!info.multiEntry()) {
+ auto error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey.asOneKey());
+ if (!error.isNull()) {
+ LOG_ERROR("Unable to put index record for newly created index");
+ return error;
+ }
+ }
</ins><span class="cx">
</span><ins>+ Vector<IDBKeyData> indexKeys = indexKey.multiEntry();
+
+ if (info.unique()) {
+ bool hasRecord;
+ IDBError error;
+ for (auto& indexKey : indexKeys) {
+ error = uncheckedHasIndexRecord(info.identifier(), indexKey, hasRecord);
+ if (!error.isNull())
+ return error;
+ if (hasRecord)
+ return IDBError(IDBDatabaseException::ConstraintError);
+ }
+ }
+
+ for (auto& indexKey : indexKeys) {
+ auto error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey);
+ if (!error.isNull()) {
+ LOG_ERROR("Unable to put index record for newly created index");
+ return error;
+ }
+ }
+
+ return { };
+}
+
</ins><span class="cx"> IDBError SQLiteIDBBackingStore::uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData& keyValue, const WebCore::IDBKeyData& indexKey)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<SharedBuffer> indexKeyBuffer = serializeIDBKeyData(indexKey);
</span><span class="lines">@@ -1012,10 +1063,40 @@
</span><span class="cx"> return { IDBDatabaseException::UnknownError, ASCIILiteral("Currently unable to delete all records in a multi-key range") };
</span><span class="cx"> }
</span><span class="cx">
</span><del>-IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
</del><ins>+IDBError SQLiteIDBBackingStore::updateIndexesForAddRecord(const IDBObjectStoreInfo& info, const IDBKeyData& key, const ThreadSafeDataBuffer& value)
</ins><span class="cx"> {
</span><del>- LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreID);
</del><ins>+ JSLockHolder locker(vm());
</ins><span class="cx">
</span><ins>+ auto jsValue = deserializeIDBValueDataToJSValue(*globalObject().globalExec(), value);
+ if (jsValue.isUndefinedOrNull())
+ return { };
+
+ IDBError error;
+ Vector<std::pair<uint64_t, IndexKey>> changedIndexRecords;
+
+ for (auto& index : info.indexMap().values()) {
+ IndexKey indexKey;
+ generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey);
+
+ if (indexKey.isNull())
+ continue;
+
+ error = uncheckedPutIndexKey(index, key, indexKey);
+ if (!error.isNull())
+ break;
+
+ changedIndexRecords.append(std::make_pair(index.identifier(), indexKey));
+ }
+
+ // FIXME: If any of the index puts failed, revert the ones that went through (changedIndexRecords).
+
+ return error;
+}
+
+IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+{
+ LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
+
</ins><span class="cx"> ASSERT(m_sqliteDB);
</span><span class="cx"> ASSERT(m_sqliteDB->isOpen());
</span><span class="cx"> ASSERT(value.data());
</span><span class="lines">@@ -1038,16 +1119,20 @@
</span><span class="cx"> {
</span><span class="cx"> SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO Records VALUES (?, CAST(? AS TEXT), ?);"));
</span><span class="cx"> if (sql.prepare() != SQLITE_OK
</span><del>- || sql.bindInt64(1, objectStoreID) != SQLITE_OK
</del><ins>+ || sql.bindInt64(1, objectStoreInfo.identifier()) != SQLITE_OK
</ins><span class="cx"> || sql.bindBlob(2, keyBuffer->data(), keyBuffer->size()) != SQLITE_OK
</span><span class="cx"> || sql.bindBlob(3, value.data()->data(), value.data()->size()) != SQLITE_OK
</span><span class="cx"> || sql.step() != SQLITE_DONE) {
</span><del>- LOG_ERROR("Could not put record for object store %" PRIi64 " in Records table (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
</del><ins>+ LOG_ERROR("Could not put record for object store %" PRIi64 " in Records table (%i) - %s", objectStoreInfo.identifier(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
</ins><span class="cx"> return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to store record in object store") };
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return { };
</del><ins>+ auto error = updateIndexesForAddRecord(objectStoreInfo, keyData, value);
+
+ // FIXME: If there was an error indexing this record, remove it.
+
+ return error;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, ThreadSafeDataBuffer& resultValue)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class IndexKey;
</ins><span class="cx"> class SQLiteDatabase;
</span><span class="cx">
</span><span class="cx"> namespace IDBServer {
</span><span class="lines">@@ -62,7 +63,7 @@
</span><span class="cx"> virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) override final;
</span><span class="cx"> virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) override final;
</span><span class="cx"> virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) override final;
</span><del>- virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
</del><ins>+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
</ins><span class="cx"> virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) override final;
</span><span class="cx"> virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) override final;
</span><span class="cx"> virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;
</span><span class="lines">@@ -87,11 +88,17 @@
</span><span class="cx"> std::unique_ptr<IDBDatabaseInfo> extractExistingDatabaseInfo();
</span><span class="cx">
</span><span class="cx"> IDBError deleteRecord(SQLiteIDBTransaction&, int64_t objectStoreID, const IDBKeyData&);
</span><ins>+ IDBError uncheckedPutIndexKey(const IDBIndexInfo&, const IDBKeyData& keyValue, const IndexKey&);
</ins><span class="cx"> IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData& keyValue, const IDBKeyData& indexKey);
</span><span class="cx"> IDBError uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData&, bool& hasRecord);
</span><span class="cx"> IDBError uncheckedGetKeyGeneratorValue(int64_t objectStoreID, uint64_t& outValue);
</span><span class="cx"> IDBError uncheckedSetKeyGeneratorValue(int64_t objectStoreID, uint64_t value);
</span><ins>+ IDBError updateIndexesForAddRecord(const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
</ins><span class="cx">
</span><ins>+ JSC::VM& vm();
+ JSC::JSGlobalObject& globalObject();
+ void initializeVM();
+
</ins><span class="cx"> IDBDatabaseIdentifier m_identifier;
</span><span class="cx"> std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -791,7 +791,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- error = m_backingStore->addRecord(transactionIdentifier, objectStoreIdentifier, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue);
</del><ins>+ error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue);
</ins><span class="cx"> if (!error.isNull()) {
</span><span class="cx"> m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedIDBObjectStoreInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h (195688 => 195689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h        2016-01-27 20:47:44 UTC (rev 195688)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h        2016-01-27 21:57:22 UTC (rev 195689)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> IDBIndexInfo* infoForExistingIndex(const String& name);
</span><span class="cx">
</span><span class="cx"> Vector<String> indexNames() const;
</span><ins>+ const HashMap<uint64_t, IDBIndexInfo>& indexMap() const { return m_indexMap; }
</ins><span class="cx">
</span><span class="cx"> void deleteIndex(const String& indexName);
</span><span class="cx"> void deleteIndex(uint64_t indexIdentifier);
</span></span></pre>
</div>
</div>
</body>
</html>