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