| 1490 | |
| 1491 | |
| 1492 | static void |
| 1493 | ProcessBatchUpdateCore(MongoCollection *collection, List *updates, text *transactionId, |
| 1494 | BatchUpdateResult *batchResult, bool isOrdered, |
| 1495 | bool forceInlineWrites, ExprEvalState *stateForSchemaValidation, |
| 1496 | WriteMode writeMode) |
| 1497 | { |
| 1498 | batchResult->ok = 1; |
| 1499 | batchResult->rowsMatched = 0; |
| 1500 | batchResult->rowsModified = 0; |
| 1501 | batchResult->writeErrors = NIL; |
| 1502 | batchResult->upserted = NIL; |
| 1503 | |
| 1504 | text *subTransactionId = transactionId; |
| 1505 | |
| 1506 | if (list_length(updates) == 1) |
| 1507 | { |
| 1508 | int updateIndex = 0; |
| 1509 | if (writeMode == WriteMode_Txn_Proc && transactionId == NULL) |
| 1510 | { |
| 1511 | DoSingleUpdate(collection, linitial(updates), subTransactionId, |
| 1512 | batchResult, updateIndex, forceInlineWrites, |
| 1513 | stateForSchemaValidation); |
| 1514 | return; |
| 1515 | } |
| 1516 | |
| 1517 | ereport(DEBUG1, (errmsg("Using single update with subtransaction"))); |
| 1518 | DoSingleUpdateWithSubTxn(collection, linitial(updates), subTransactionId, |
| 1519 | batchResult, updateIndex, forceInlineWrites, |
| 1520 | stateForSchemaValidation); |
| 1521 | return; |
| 1522 | } |
| 1523 | else |
| 1524 | { |
| 1525 | /* |
| 1526 | * We cannot pass the same transactionId to ProcessUpdate when there are |
| 1527 | * multiple updates, since they would be considered retries of each |
| 1528 | * other. We pass NULL for now to disable retryable writes. |
| 1529 | */ |
| 1530 | subTransactionId = NULL; |
| 1531 | } |
| 1532 | |
| 1533 | int updateIndex = 0; |
| 1534 | int nextBatchAttemptIndex = -1; |
| 1535 | bool hasBatchUpdateFailed = false; |
| 1536 | |
| 1537 | ListCell *updateCell = NULL; |
| 1538 | while (updateIndex < list_length(updates)) |
| 1539 | { |
| 1540 | CHECK_FOR_INTERRUPTS(); |
| 1541 | if (writeMode == WriteMode_Bulk_Proc && updateIndex > 0) |
| 1542 | { |
| 1543 | /* For each iteration of the loop, commit prior work */ |
| 1544 | bool setSnapshot = false; |
| 1545 | Oid shardTableOid = InvalidOid; |
| 1546 | CommitWriteProcedureAndReacquireCollectionLock(collection, shardTableOid, |
| 1547 | setSnapshot); |
| 1548 | } |
| 1549 |
no test coverage detected