1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/transaction/commit_state.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/transaction/undo_buffer.hpp"
12#include "duckdb/common/vector_size.hpp"
13
14namespace duckdb {
15class CatalogEntry;
16class DataChunk;
17class WriteAheadLog;
18class ClientContext;
19
20struct DataTableInfo;
21struct DeleteInfo;
22struct UpdateInfo;
23
24class CommitState {
25public:
26 explicit CommitState(ClientContext &context, transaction_t commit_id, optional_ptr<WriteAheadLog> log = nullptr);
27
28 optional_ptr<WriteAheadLog> log;
29 transaction_t commit_id;
30 UndoFlags current_op;
31
32 optional_ptr<DataTableInfo> current_table_info;
33 idx_t row_identifiers[STANDARD_VECTOR_SIZE];
34
35 unique_ptr<DataChunk> delete_chunk;
36 unique_ptr<DataChunk> update_chunk;
37
38private:
39 ClientContext &context;
40
41public:
42 template <bool HAS_LOG>
43 void CommitEntry(UndoFlags type, data_ptr_t data);
44 void RevertCommit(UndoFlags type, data_ptr_t data);
45
46private:
47 void SwitchTable(DataTableInfo *table, UndoFlags new_op);
48
49 void WriteCatalogEntry(CatalogEntry &entry, data_ptr_t extra_data);
50 void WriteDelete(DeleteInfo &info);
51 void WriteUpdate(UpdateInfo &info);
52
53 void AppendRowId(row_t rowid);
54};
55
56} // namespace duckdb
57