Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6b45d5d99db753d2bc2c3c470b1164bd1839c527
https://github.com/WebKit/WebKit/commit/6b45d5d99db753d2bc2c3c470b1164bd1839c527
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-21 (Tue, 21 Jul 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.html
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.js
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.serviceworker-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.serviceworker.html
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.sharedworker-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.sharedworker.html
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.worker-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.worker.html
A
LayoutTests/storage/indexeddb/put-record-unique-index-constraint-is-atomic-private-expected.txt
A
LayoutTests/storage/indexeddb/put-record-unique-index-constraint-is-atomic-private.html
A
LayoutTests/storage/indexeddb/resources/put-record-unique-index-constraint-is-atomic.js
M Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h
M Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
M Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h
M Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp
M Source/WebCore/Modules/indexeddb/server/MemoryIndex.h
M Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp
M Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h
M Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
M Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
M Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Log Message:
-----------
IndexedDB: put() that fails a unique index constraint deletes the record it
would have overwritten
https://bugs.webkit.org/show_bug.cgi?id=318659
rdar://181513905
Reviewed by Sihui Liu.
A put() that violates a unique index constraint was not atomic:
putOrAddAfterSpaceCheck()
deleted any existing record with the same primary key before adding the new
one, so a failed
put() left the store with neither the old nor the new record. Fix by folding the
check-then-overwrite sequence into a single new backing store method,
overwriteRecord(),
matching the spec's storage algorithm: verify the record would not violate a
unique index
before mutating anything, then remove any existing record with the same key and
store the
new key/value with its index entries.
In SQLiteIDBBackingStore, merge uncheckedHasIndexRecord() and
uncheckedHasIndexRecordForOtherPrimaryKey() into
uncheckedGetExistingPrimaryKeyForIndexKey(),
so both call sites share one query instead of two nearly-identical ones.
Tests:
imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.js
storage/indexeddb/put-record-unique-index-constraint-is-atomic-private.html
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.js:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.serviceworker-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.serviceworker.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.sharedworker-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.sharedworker.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.worker-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-put-unique-index-constraint-is-atomic.any.worker.html:
Added.
*
LayoutTests/storage/indexeddb/put-record-unique-index-constraint-is-atomic-private-expected.txt:
Added.
*
LayoutTests/storage/indexeddb/put-record-unique-index-constraint-is-atomic-private.html:
Added.
*
LayoutTests/storage/indexeddb/resources/put-record-unique-index-constraint-is-atomic.js:
Added.
* Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h:
* Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::overwriteRecord):
* Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h:
* Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp:
(WebCore::IDBServer::MemoryIndex::hasRecordForOtherPrimaryKey):
* Source/WebCore/Modules/indexeddb/server/MemoryIndex.h:
* Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::overwriteRecord):
(WebCore::IDBServer::MemoryObjectStore::checkIndexConstraintsForPut):
* Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h:
* Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetExistingPrimaryKeyForIndexKey):
(WebCore::IDBServer::SQLiteIDBBackingStore::overwriteRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::checkIndexConstraintsForPut):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexKey):
* Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h:
* Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::putOrAddAfterSpaceCheck):
Canonical link: https://commits.webkit.org/317632@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications