| 1 | #include "duckdb/transaction/rollback_state.hpp" | 
|---|---|
| 2 | #include "duckdb/transaction/append_info.hpp" | 
| 3 | #include "duckdb/transaction/delete_info.hpp" | 
| 4 | #include "duckdb/transaction/update_info.hpp" | 
| 5 | |
| 6 | #include "duckdb/storage/table/chunk_info.hpp" | 
| 7 | |
| 8 | #include "duckdb/catalog/catalog_entry.hpp" | 
| 9 | #include "duckdb/catalog/catalog_set.hpp" | 
| 10 | #include "duckdb/storage/data_table.hpp" | 
| 11 | #include "duckdb/storage/table/update_segment.hpp" | 
| 12 | |
| 13 | namespace duckdb { | 
| 14 | |
| 15 | void RollbackState::RollbackEntry(UndoFlags type, data_ptr_t data) { | 
| 16 | switch (type) { | 
| 17 | case UndoFlags::CATALOG_ENTRY: { | 
| 18 | // undo this catalog entry | 
| 19 | auto catalog_entry = Load<CatalogEntry *>(ptr: data); | 
| 20 | D_ASSERT(catalog_entry->set); | 
| 21 | catalog_entry->set->Undo(entry&: *catalog_entry); | 
| 22 | break; | 
| 23 | } | 
| 24 | case UndoFlags::INSERT_TUPLE: { | 
| 25 | auto info = reinterpret_cast<AppendInfo *>(data); | 
| 26 | // revert the append in the base table | 
| 27 | info->table->RevertAppend(start_row: info->start_row, count: info->count); | 
| 28 | break; | 
| 29 | } | 
| 30 | case UndoFlags::DELETE_TUPLE: { | 
| 31 | auto info = reinterpret_cast<DeleteInfo *>(data); | 
| 32 | // reset the deleted flag on rollback | 
| 33 | info->vinfo->CommitDelete(commit_id: NOT_DELETED_ID, rows: info->rows, count: info->count); | 
| 34 | break; | 
| 35 | } | 
| 36 | case UndoFlags::UPDATE_TUPLE: { | 
| 37 | auto info = reinterpret_cast<UpdateInfo *>(data); | 
| 38 | info->segment->RollbackUpdate(info&: *info); | 
| 39 | break; | 
| 40 | } | 
| 41 | default: // LCOV_EXCL_START | 
| 42 | D_ASSERT(type == UndoFlags::EMPTY_ENTRY); | 
| 43 | break; | 
| 44 | } // LCOV_EXCL_STOP | 
| 45 | } | 
| 46 | |
| 47 | } // namespace duckdb | 
| 48 | 
