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 | |
14 | namespace duckdb { |
15 | class CatalogEntry; |
16 | class DataChunk; |
17 | class WriteAheadLog; |
18 | class ClientContext; |
19 | |
20 | struct DataTableInfo; |
21 | struct DeleteInfo; |
22 | struct UpdateInfo; |
23 | |
24 | class CommitState { |
25 | public: |
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 | |
38 | private: |
39 | ClientContext &context; |
40 | |
41 | public: |
42 | template <bool HAS_LOG> |
43 | void CommitEntry(UndoFlags type, data_ptr_t data); |
44 | void RevertCommit(UndoFlags type, data_ptr_t data); |
45 | |
46 | private: |
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 |