Blob type cannot be stored correctly in IDB when IDBObjectStore has autoIncrement...
[WebKit-https.git] / Source / WebCore / Modules / indexeddb / server / UniqueIDBDatabase.cpp
index 9ae4922..9077e58 100644 (file)
@@ -1251,35 +1251,6 @@ void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBRe
         }
     }
 
-    // 3.4.1.2 Object Store Storage Operation
-    // If ObjectStore has a key path and the key is autogenerated, then inject the key into the value
-    // using steps to assign a key to a value using a key path.
-    ThreadSafeDataBuffer injectedRecordValue;
-    if (usedKeyIsGenerated && objectStoreInfo->keyPath()) {
-        VM& vm = databaseThreadVM();
-        JSLockHolder locker(vm);
-        auto scope = DECLARE_THROW_SCOPE(vm);
-
-        auto value = deserializeIDBValueToJSValue(databaseThreadExecState(), originalRecordValue.data());
-        if (value.isUndefined()) {
-            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to deserialize record value for record key injection"_s), usedKey));
-            return;
-        }
-
-        if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value, objectStoreInfo->keyPath().value())) {
-            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to inject record key into record value"_s), usedKey));
-            return;
-        }
-
-        auto serializedValue = SerializedScriptValue::create(databaseThreadExecState(), value);
-        if (UNLIKELY(scope.exception())) {
-            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to serialize record value after injecting record key"_s), usedKey));
-            return;
-        }
-
-        injectedRecordValue = ThreadSafeDataBuffer::copyVector(serializedValue->data());
-    }
-
     // 3.4.1 Object Store Storage Operation
     // ...If a record already exists in store ...
     // then remove the record from store using the steps for deleting records from an object store...
@@ -1290,10 +1261,7 @@ void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBRe
         return;
     }
 
-    if (injectedRecordValue.data())
-        error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, { injectedRecordValue, originalRecordValue.blobURLs(), originalRecordValue.sessionID(), originalRecordValue.blobFilePaths() });
-    else
-        error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue);
+    error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue);
 
     if (!error.isNull()) {
         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));