| 1856 | |
| 1857 | |
| 1858 | bool MergeTreeData::renameTempPartAndAdd(MutableDataPartPtr & part, SimpleIncrement * increment, Transaction * out_transaction, MergeTreeDeduplicationLog * deduplication_log) |
| 1859 | { |
| 1860 | if (out_transaction && &out_transaction->data != this) |
| 1861 | throw Exception("MergeTreeData::Transaction for one table cannot be used with another. It is a bug.", |
| 1862 | ErrorCodes::LOGICAL_ERROR); |
| 1863 | |
| 1864 | DataPartsVector covered_parts; |
| 1865 | { |
| 1866 | auto lock = lockParts(); |
| 1867 | if (!renameTempPartAndReplace(part, increment, out_transaction, lock, &covered_parts, deduplication_log)) |
| 1868 | return false; |
| 1869 | } |
| 1870 | if (!covered_parts.empty()) |
| 1871 | throw Exception("Added part " + part->name + " covers " + toString(covered_parts.size()) |
| 1872 | + " existing part(s) (including " + covered_parts[0]->name + ")", ErrorCodes::LOGICAL_ERROR); |
| 1873 | |
| 1874 | return true; |
| 1875 | } |
| 1876 | |
| 1877 | |
| 1878 | bool MergeTreeData::renameTempPartAndReplace( |