Title: [207209] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/LayoutTests/ChangeLog (207208 => 207209)


--- branches/safari-602-branch/LayoutTests/ChangeLog	2016-10-12 08:41:44 UTC (rev 207208)
+++ branches/safari-602-branch/LayoutTests/ChangeLog	2016-10-12 08:41:48 UTC (rev 207209)
@@ -1,5 +1,22 @@
 2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r206280. rdar://problem/28476953
+
+    2016-09-22  Brady Eidson  <beid...@apple.com>
+
+            IDBIndex.openCursor() matches indices on multiple object stores.
+            <rdar://problem/28434463> and https://bugs.webkit.org/show_bug.cgi?id=158833
+
+            Reviewed by Alex Christensen.
+
+            * storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-expected.txt: Added.
+            * storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private-expected.txt: Added.
+            * storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private.html: Added.
+            * storage/indexeddb/modern/multiple-objectstore-index-cursor-collision.html: Added.
+            * storage/indexeddb/modern/resources/multiple-objectstore-index-cursor-collision.js: Added.
+
+2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r205861. rdar://problem/28409523
 
     2016-09-12  Zalan Bujtas  <za...@apple.com>

Added: branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-expected.txt (0 => 207209)


--- branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-expected.txt	2016-10-12 08:41:48 UTC (rev 207209)
@@ -0,0 +1,21 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+db deleted
+Creating db
+Enumerating ObjectStore 'schools' by primary key
+key: 1, primaryKey: 1, value: {"name":"Stockholm University","city":"Stockholm","id":1}
+key: 2, primaryKey: 2, value: {"name":"Uppsala University","city":"Uppsala","id":2}
+key: 3, primaryKey: 3, value: {"name":"Chalmers","city":"Gothenburg","id":3}
+Enumerating index 'city' on 'schools'
+key: Gothenburg, primaryKey: 3, value: {"name":"Chalmers","city":"Gothenburg","id":3}
+key: Stockholm, primaryKey: 1, value: {"name":"Stockholm University","city":"Stockholm","id":1}
+key: Uppsala, primaryKey: 2, value: {"name":"Uppsala University","city":"Uppsala","id":2}
+Enumerating ObjectStore 'students' by primary key
+key: 1, primaryKey: 1, value: {"name":"Adam Anderson","id":1}
+key: 2, primaryKey: 2, value: {"name":"Bertil Bengtson","id":2}
+Enumerating index 'name' on 'students'
+key: Adam Anderson, primaryKey: 1, value: {"name":"Adam Anderson","id":1}
+key: Bertil Bengtson, primaryKey: 2, value: {"name":"Bertil Bengtson","id":2}
+Done.
+

Added: branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private-expected.txt (0 => 207209)


--- branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private-expected.txt	2016-10-12 08:41:48 UTC (rev 207209)
@@ -0,0 +1,21 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+db deleted
+Creating db
+Enumerating ObjectStore 'schools' by primary key
+key: 1, primaryKey: 1, value: {"name":"Stockholm University","city":"Stockholm","id":1}
+key: 2, primaryKey: 2, value: {"name":"Uppsala University","city":"Uppsala","id":2}
+key: 3, primaryKey: 3, value: {"name":"Chalmers","city":"Gothenburg","id":3}
+Enumerating index 'city' on 'schools'
+key: Gothenburg, primaryKey: 3, value: {"name":"Chalmers","city":"Gothenburg","id":3}
+key: Stockholm, primaryKey: 1, value: {"name":"Stockholm University","city":"Stockholm","id":1}
+key: Uppsala, primaryKey: 2, value: {"name":"Uppsala University","city":"Uppsala","id":2}
+Enumerating ObjectStore 'students' by primary key
+key: 1, primaryKey: 1, value: {"name":"Adam Anderson","id":1}
+key: 2, primaryKey: 2, value: {"name":"Bertil Bengtson","id":2}
+Enumerating index 'name' on 'students'
+key: Adam Anderson, primaryKey: 1, value: {"name":"Adam Anderson","id":1}
+key: Bertil Bengtson, primaryKey: 2, value: {"name":"Bertil Bengtson","id":2}
+Done.
+

Added: branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private.html (0 => 207209)


--- branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private.html	2016-10-12 08:41:48 UTC (rev 207209)
@@ -0,0 +1,12 @@
+<html>
+<head>
+<script>
+enablePrivateBrowsing = true;
+</script>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>

Added: branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision.html (0 => 207209)


--- branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/multiple-objectstore-index-cursor-collision.html	2016-10-12 08:41:48 UTC (rev 207209)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>

Added: branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/resources/multiple-objectstore-index-cursor-collision.js (0 => 207209)


--- branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/resources/multiple-objectstore-index-cursor-collision.js	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/storage/indexeddb/modern/resources/multiple-objectstore-index-cursor-collision.js	2016-10-12 08:41:48 UTC (rev 207209)
@@ -0,0 +1,48 @@
+const log = txt => document.writeln(`${txt}<br/>`);
+log("Deleting db");
+indexedDB.deleteDatabase("db")._onsuccess_ = ()=> {
+    log("db deleted");
+    let req = indexedDB.open("db", 1);
+    req._onupgradeneeded_ = e => {
+        log ("Creating db");
+        let db = req.transaction.db;
+        let schools = db.createObjectStore('schools', { keyPath: 'id', autoIncrement: true });
+        schools.createIndex ('city', 'city');
+        schools.add({name: 'Stockholm University', city: 'Stockholm'});
+        schools.add({name: 'Uppsala University', city: 'Uppsala'});
+        schools.add({name: 'Chalmers', city: 'Gothenburg'});
+        let students = db.createObjectStore('students', { keyPath: 'id', autoIncrement: true });
+        students.createIndex ('name', 'name');
+        students.add({name: 'Adam Anderson'});
+        students.add({name: 'Bertil Bengtson'});
+    }
+    req._onsuccess_ = ()=> {
+        let db = req.result;
+        let tx = db.transaction(['schools', 'students'], 'readonly');
+        dump(tx.objectStore('schools'), ()=> {
+            dump(tx.objectStore('schools').index('city'), ()=> {
+                dump(tx.objectStore('students'), ()=>{
+                    dump(tx.objectStore('students').index('name'), ()=>{
+                        log("Done.");
+						finishJSTest();
+                    })
+                });
+            });
+        });
+    }
+}
+
+function dump (idx, done) {
+    log (idx instanceof IDBObjectStore ?
+        `Enumerating ObjectStore '${idx.name}' by primary key` :
+        `Enumerating index '${idx.name}' on '${idx.objectStore.name}'`);
+    idx.openCursor()._onsuccess_ = e => {
+        let cursor = e.target.result; 
+        if (cursor) {
+            log(`key: ${cursor.key}, primaryKey: ${cursor.primaryKey}, value: ${JSON.stringify(cursor.value)}`);
+            cursor.continue();
+        } else {
+            done();
+        }
+    }
+}

Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (207208 => 207209)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-12 08:41:44 UTC (rev 207208)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-12 08:41:48 UTC (rev 207209)
@@ -1,5 +1,25 @@
 2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r206280. rdar://problem/28476953
+
+    2016-09-22  Brady Eidson  <beid...@apple.com>
+
+            IDBIndex.openCursor() matches indices on multiple object stores.
+            <rdar://problem/28434463> and https://bugs.webkit.org/show_bug.cgi?id=158833
+
+            Reviewed by Alex Christensen.
+
+            Tests: storage/indexeddb/modern/multiple-objectstore-index-cursor-collision-private.html
+                   storage/indexeddb/modern/multiple-objectstore-index-cursor-collision.html
+
+            * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+            (WebCore::IDBServer::buildIndexStatement): Need to include the object store id in the statement for
+              index cursors, otherwise there will be collisions amongst multiple object stores that happen to
+              share primary keys.
+            (WebCore::IDBServer::SQLiteIDBCursor::bindArguments):
+
+2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r205861. rdar://problem/28409523
 
     2016-09-12  Zalan Bujtas  <za...@apple.com>

Modified: branches/safari-602-branch/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (207208 => 207209)


--- branches/safari-602-branch/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-10-12 08:41:44 UTC (rev 207208)
+++ branches/safari-602-branch/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-10-12 08:41:48 UTC (rev 207209)
@@ -112,7 +112,7 @@
 {
     StringBuilder builder;
 
-    builder.appendLiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND key ");
+    builder.appendLiteral("SELECT rowid, key, value FROM IndexRecords WHERE indexID = ? AND objectStoreID = ? AND key ");
     if (!keyRange.lowerKey.isNull() && !keyRange.lowerOpen)
         builder.appendLiteral(">=");
     else
@@ -260,19 +260,26 @@
 {
     LOG(IndexedDB, "Cursor is binding lower key '%s' and upper key '%s'", m_currentLowerKey.loggingString().utf8().data(), m_currentUpperKey.loggingString().utf8().data());
 
-    if (m_statement->bindInt64(1, m_boundID) != SQLITE_OK) {
+    int currentBindArgument = 1;
+
+    if (m_statement->bindInt64(currentBindArgument++, m_boundID) != SQLITE_OK) {
         LOG_ERROR("Could not bind id argument (bound ID)");
         return false;
     }
 
+    if (m_indexID != IDBIndexInfo::InvalidId && m_statement->bindInt64(currentBindArgument++, m_objectStoreID) != SQLITE_OK) {
+        LOG_ERROR("Could not bind object store id argument for an index cursor");
+        return false;
+    }
+
     RefPtr<SharedBuffer> buffer = serializeIDBKeyData(m_currentLowerKey);
-    if (m_statement->bindBlob(2, buffer->data(), buffer->size()) != SQLITE_OK) {
+    if (m_statement->bindBlob(currentBindArgument++, buffer->data(), buffer->size()) != SQLITE_OK) {
         LOG_ERROR("Could not create cursor statement (lower key)");
         return false;
     }
 
     buffer = serializeIDBKeyData(m_currentUpperKey);
-    if (m_statement->bindBlob(3, buffer->data(), buffer->size()) != SQLITE_OK) {
+    if (m_statement->bindBlob(currentBindArgument++, buffer->data(), buffer->size()) != SQLITE_OK) {
         LOG_ERROR("Could not create cursor statement (upper key)");
         return false;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to