MCPcopy Create free account
hub / github.com/documentdb/documentdb / DoInsertForUpdate

Function DoInsertForUpdate

pg_documentdb/src/commands/update.c:704–719  ·  view source on GitHub ↗

* Does an insert or upsert for an update. If the original query was for an object_id * Does an InsertOrReplace. Otherwise does an Insert to fail if there's an object_id * constraint that fails. */

Source from the content-addressed store, hash-verified

702 * constraint that fails.
703 */
704static inline void
705DoInsertForUpdate(MongoCollection *collection, uint64_t shardKeyHash, pgbson *objectId,
706 pgbson *newDocument, bool hasOnlyObjectIdFilter,
707 const bson_value_t *updateSpecValue)
708{
709 if (hasOnlyObjectIdFilter)
710 {
711 InsertOrReplaceDocument(collection->collectionId, collection->shardTableName,
712 shardKeyHash, objectId, newDocument, updateSpecValue);
713 }
714 else
715 {
716 InsertDocument(collection->collectionId, collection->shardTableName,
717 shardKeyHash, objectId, newDocument);
718 }
719}
720
721
722/*

Callers 3

UpdateOneFunction · 0.85
UpdateOneInternalFunction · 0.85
UpsertDocumentFunction · 0.85

Calls 2

InsertOrReplaceDocumentFunction · 0.85
InsertDocumentFunction · 0.85

Tested by

no test coverage detected