Debian Codegraph @

storage/innobase/include/row0vers.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 1997, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 /** @file include/row0vers.h
29 Row versions
30
31 Created 2/6/1997 Heikki Tuuri
32 *******************************************************/
33
34 #ifndef row0vers_h
35 #define row0vers_h
36
37 #include "data0data.h"
38 #include "dict0mem.h"
39 #include "dict0types.h"
40 #include "lob0undo.h"
41 #include "mtr0mtr.h"
42 #include "que0types.h"
43 #include "rem0types.h"
44 #include "trx0types.h"
45 #include "univ.i"
46
47 // Forward declaration
48 class ReadView;
49
50 /** Finds out if an active transaction has inserted or modified a secondary
51 index record.
52 @param[in] rec record in a secondary index
53 @param[in] index the secondary index
54 @param[in] offsets rec_get_offsets(rec, index)
55 @return 0 if committed, else the active transaction id;
56 NOTE that this function can return false positives but never false
57 negatives. The caller must confirm all positive results by checking if the trx
58 is still active.
59 */
60 trx_t *row_vers_impl_x_locked(const rec_t *rec, const dict_index_t *index,
61 const ulint *offsets);
62
63 /** Finds out if we must preserve a delete marked earlier version of a clustered
64 index record, because it is >= the purge view.
65 @param[in] trx_id Transaction id in the version
66 @param[in] name Table name
67 @param[in,out] mtr Mini-transaction holding the latch on the
68 clustered index record; it will also hold
69 the latch on purge_view
70 @return true if earlier version should be preserved */
71 bool row_vers_must_preserve_del_marked(trx_id_t trx_id,
72 const table_name_t &name, mtr_t *mtr);
73
74 /** Finds out if a version of the record, where the version >= the current
75 purge view, should have ientry as its secondary index entry. We check
76 if there is any not delete marked version of the record where the trx
77 id >= purge view, and the secondary index entry == ientry; exactly in
78 this case we return true.
79 @return true if earlier version should have */
80 bool row_vers_old_has_index_entry(
81 bool also_curr, /*!< in: true if also rec is included in the
82 versions to search; otherwise only versions
83 prior to it are searched */
84 const rec_t *rec, /*!< in: record in the clustered index; the
85 caller must have a latch on the page */
86 mtr_t *mtr, /*!< in: mtr holding the latch on rec; it will
87 also hold the latch on purge_view */
88 dict_index_t *index, /*!< in: the secondary index */
89 const dtuple_t *ientry, /*!< in: the secondary index entry */
90 roll_ptr_t roll_ptr, /*!< in: roll_ptr for the purge record */
91 trx_id_t trx_id); /*!< in: transaction ID on the purging record */
92
93 /** Constructs the version of a clustered index record which a consistent
94 read should see. We assume that the trx id stored in rec is such that
95 the consistent read should not see rec in its present version.
96 @param[in] rec record in a clustered index; the caller must have a latch
97 on the page; this latch locks the top of the stack of
98 versions of this records
99 @param[in] mtr mtr holding the latch on rec; it will also hold the latch
100 on purge_view
101 @param[in] index the clustered index
102 @param[in] offsets offsets returned by rec_get_offsets(rec, index)
103 @param[in] view the consistent read view
104 @param[in,out] offset_heap memory heap from which the offsets are
105 allocated
106 @param[in] in_heap memory heap from which the memory for *old_vers is
107 allocated; memory for possible intermediate versions
108 is allocated and freed locally within the function
109 @param[out] old_vers old version, or NULL if the history is missing or
110 the record does not exist in the view, that is, it
111 was freshly inserted afterwards.
112 @param[out] vrow reports virtual column info if any
113 @param[in] lob_undo undo log to be applied to blobs.
114 @return DB_SUCCESS or DB_MISSING_HISTORY */
115 dberr_t row_vers_build_for_consistent_read(
116 const rec_t *rec, mtr_t *mtr, dict_index_t *index, ulint **offsets,
117 ReadView *view, mem_heap_t **offset_heap, mem_heap_t *in_heap,
118 rec_t **old_vers, const dtuple_t **vrow, lob::undo_vers_t *lob_undo);
119
120 /** Constructs the last committed version of a clustered index record,
121 which should be seen by a semi-consistent read.
122 @param[in] rec Record in a clustered index; the caller must have a latch on the
123 page; this latch locks the top of the stack of versions of this records
124 @param[in] mtr Mini-transaction holding the latch on rec
125 @param[in] index The clustered index
126 @param[in,out] offsets Offsets returned by rec_get_offsets(rec, index)
127 @param[in,out] offset_heap Memory heap from which the offsets are allocated
128 @param[in] in_heap Memory heap from which the memory for *old_vers is allocated;
129 memory for possible intermediate versions is allocated and freed locally within
130 the function
131 @param[out] old_vers Rec, old version, or null if the record does not exist in
132 the view, that is, it was freshly inserted afterwards
133 @param[out] vrow Virtual row, old version, or null if it is not updated in the
134 view */
135 void row_vers_build_for_semi_consistent_read(
136 const rec_t *rec, mtr_t *mtr, dict_index_t *index, ulint **offsets,
137 mem_heap_t **offset_heap, mem_heap_t *in_heap, const rec_t **old_vers,
138 const dtuple_t **vrow);
139
140 #include "row0vers.ic"
141
142 #endif