| 117 | } |
| 118 | |
| 119 | void MergeTreeTransaction::addNewPartAndRemoveCovered(const StoragePtr & storage, const DataPartPtr & new_part, const DataPartsVector & covered_parts, MergeTreeTransaction * txn) |
| 120 | { |
| 121 | TransactionID tid = txn ? txn->tid : Tx::NonTransactionalTID; |
| 122 | TransactionInfoContext transaction_context{storage->getStorageID(), new_part->name}; |
| 123 | tryWriteEventToSystemLog(new_part->version->getLogger(), TransactionsInfoLogElement::ADD_PART, tid, transaction_context); |
| 124 | transaction_context.covering_part = std::move(transaction_context.part_name); |
| 125 | new_part->assertHasVersionMetadata(txn); |
| 126 | |
| 127 | if (txn) |
| 128 | { |
| 129 | txn->addNewPart(storage, new_part); |
| 130 | for (const auto & covered : covered_parts) |
| 131 | { |
| 132 | transaction_context.part_name = covered->name; |
| 133 | txn->removeOldPart(storage, covered, transaction_context); |
| 134 | } |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | for (const auto & covered : covered_parts) |
| 139 | { |
| 140 | transaction_context.part_name = covered->name; |
| 141 | covered->version->setAndStoreNonTransactionalRemovalTID(transaction_context); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void MergeTreeTransaction::addNewPart(const StoragePtr & storage, const DataPartPtr & new_part) |
| 147 | { |
nothing calls this directly
no test coverage detected