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

Function InsertOneWithTransactionCore

pg_documentdb/src/commands/insert.c:1214–1240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212
1213
1214static uint64
1215InsertOneWithTransactionCore(uint64 collectionId, const char *shardTableName,
1216 int64 shardKeyValue, text *transactionId,
1217 pgbson *objectId, pgbson *document)
1218{
1219 RetryableWriteResult writeResult;
1220
1221 /*
1222 * If a retry record exists, delete it since only a single retry is allowed.
1223 */
1224 if (DeleteRetryRecord(collectionId, shardKeyValue, transactionId, &writeResult))
1225 { }
1226 else
1227 {
1228 /* no retry record exists, insert the document */
1229 InsertDocument(collectionId, shardTableName, shardKeyValue, objectId, document);
1230
1231 /* we always insert 1 row */
1232 bool rowsAffected = true;
1233
1234 /* remember that transaction performed the insert */
1235 InsertRetryRecord(collectionId, shardKeyValue, transactionId, objectId,
1236 rowsAffected, NULL);
1237 }
1238
1239 return 1;
1240}
1241
1242
1243Datum

Callers 1

command_insert_workerFunction · 0.85

Calls 3

DeleteRetryRecordFunction · 0.85
InsertDocumentFunction · 0.85
InsertRetryRecordFunction · 0.85

Tested by

no test coverage detected