MySQL 8.4.2
Source Code Documentation
row0vers.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1997, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 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
48class 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*/
60trx_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 */
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 */
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 */
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
123page; 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;
129memory for possible intermediate versions is allocated and freed locally within
130the function
131@param[out] old_vers Rec, old version, or null if the record does not exist in
132the 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
134view */
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
Read view lists the trx ids of those transactions for which a consistent read should not see the modi...
Definition: read0types.h:48
SQL data field and tuple.
dberr_t
Definition: db0err.h:39
Data dictionary memory object creation.
Data dictionary global types.
Undo logging small changes to BLOBs.
Mini-transaction buffer.
Query graph global types.
Record manager global types.
byte rec_t
Definition: rem0types.h:41
trx_t * row_vers_impl_x_locked(const rec_t *rec, const dict_index_t *index, const ulint *offsets)
Finds out if an active transaction has inserted or modified a secondary index record.
Definition: row0vers.cc:528
bool row_vers_old_has_index_entry(bool also_curr, const rec_t *rec, mtr_t *mtr, dict_index_t *index, const dtuple_t *ientry, roll_ptr_t roll_ptr, trx_id_t trx_id)
Finds out if a version of the record, where the version >= the current purge view,...
Definition: row0vers.cc:975
void row_vers_build_for_semi_consistent_read(const rec_t *rec, mtr_t *mtr, dict_index_t *index, ulint **offsets, mem_heap_t **offset_heap, mem_heap_t *in_heap, const rec_t **old_vers, const dtuple_t **vrow)
Constructs the last committed version of a clustered index record, which should be seen by a semi-con...
Definition: row0vers.cc:1360
dberr_t row_vers_build_for_consistent_read(const rec_t *rec, mtr_t *mtr, dict_index_t *index, ulint **offsets, ReadView *view, mem_heap_t **offset_heap, mem_heap_t *in_heap, rec_t **old_vers, const dtuple_t **vrow, lob::undo_vers_t *lob_undo)
Constructs the version of a clustered index record which a consistent read should see.
Definition: row0vers.cc:1250
bool row_vers_must_preserve_del_marked(trx_id_t trx_id, const table_name_t &name, mtr_t *mtr)
Finds out if we must preserve a delete marked earlier version of a clustered index record,...
Definition: row0vers.cc:584
Row versions.
case opt name
Definition: sslopt-case.h:29
Data structure for an index.
Definition: dict0mem.h:1046
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:682
The list of modifications to be applied on LOBs to get older versions.
Definition: lob0undo.h:146
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
Table name wrapper for pretty-printing.
Definition: dict0mem.h:470
Definition: trx0trx.h:684
Transaction system global type definitions.
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:140
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406