1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/transaction/update_info.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/constants.hpp" |
12 | #include "duckdb/common/types/vector.hpp" |
13 | #include "duckdb/common/types/validity_mask.hpp" |
14 | #include "duckdb/common/atomic.hpp" |
15 | |
16 | namespace duckdb { |
17 | class UpdateSegment; |
18 | struct DataTableInfo; |
19 | |
20 | struct UpdateInfo { |
21 | //! The update segment that this update info affects |
22 | UpdateSegment *segment; |
23 | //! The column index of which column we are updating |
24 | idx_t column_index; |
25 | //! The version number |
26 | atomic<transaction_t> version_number; |
27 | //! The vector index within the uncompressed segment |
28 | idx_t vector_index; |
29 | //! The amount of updated tuples |
30 | sel_t N; |
31 | //! The maximum amount of tuples that can fit into this UpdateInfo |
32 | sel_t max; |
33 | //! The row ids of the tuples that have been updated. This should always be kept sorted! |
34 | sel_t *tuples; |
35 | //! The data of the tuples |
36 | data_ptr_t tuple_data; |
37 | //! The previous update info (or nullptr if it is the base) |
38 | UpdateInfo *prev; |
39 | //! The next update info in the chain (or nullptr if it is the last) |
40 | UpdateInfo *next; |
41 | |
42 | //! Loop over the update chain and execute the specified callback on all UpdateInfo's that are relevant for that |
43 | //! transaction in-order of newest to oldest |
44 | template <class T> |
45 | static void UpdatesForTransaction(UpdateInfo *current, transaction_t start_time, transaction_t transaction_id, |
46 | T &&callback) { |
47 | while (current) { |
48 | if (current->version_number > start_time && current->version_number != transaction_id) { |
49 | // these tuples were either committed AFTER this transaction started or are not committed yet, use |
50 | // tuples stored in this version |
51 | callback(current); |
52 | } |
53 | current = current->next; |
54 | } |
55 | } |
56 | |
57 | Value GetValue(idx_t index); |
58 | string ToString(); |
59 | void Print(); |
60 | void Verify(); |
61 | }; |
62 | |
63 | } // namespace duckdb |
64 |