1/*****************************************************************************
2
3Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2017, 2018, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file include/row0vers.h
22Row versions
23
24Created 2/6/1997 Heikki Tuuri
25*******************************************************/
26
27#ifndef row0vers_h
28#define row0vers_h
29
30#include "univ.i"
31#include "data0data.h"
32#include "dict0types.h"
33#include "trx0types.h"
34#include "que0types.h"
35#include "rem0types.h"
36#include "mtr0mtr.h"
37#include "dict0mem.h"
38
39// Forward declaration
40class ReadView;
41
42/** Determine if an active transaction has inserted or modified a secondary
43index record.
44@param[in,out] caller_trx trx of current thread
45@param[in] rec secondary index record
46@param[in] index secondary index
47@param[in] offsets rec_get_offsets(rec, index)
48@return the active transaction; trx->release_reference() must be invoked
49@retval NULL if the record was committed */
50trx_t*
51row_vers_impl_x_locked(
52 trx_t* caller_trx,
53 const rec_t* rec,
54 dict_index_t* index,
55 const ulint* offsets);
56
57/*****************************************************************//**
58Finds out if a version of the record, where the version >= the current
59purge view, should have ientry as its secondary index entry. We check
60if there is any not delete marked version of the record where the trx
61id >= purge view, and the secondary index entry == ientry; exactly in
62this case we return TRUE.
63@return TRUE if earlier version should have */
64ibool
65row_vers_old_has_index_entry(
66/*=========================*/
67 ibool also_curr,/*!< in: TRUE if also rec is included in the
68 versions to search; otherwise only versions
69 prior to it are searched */
70 const rec_t* rec, /*!< in: record in the clustered index; the
71 caller must have a latch on the page */
72 mtr_t* mtr, /*!< in: mtr holding the latch on rec; it will
73 also hold the latch on purge_view */
74 dict_index_t* index, /*!< in: the secondary index */
75 const dtuple_t* ientry, /*!< in: the secondary index entry */
76 roll_ptr_t roll_ptr,/*!< in: roll_ptr for the purge record */
77 trx_id_t trx_id);/*!< in: transaction ID on the purging record */
78
79/*****************************************************************//**
80Constructs the version of a clustered index record which a consistent
81read should see. We assume that the trx id stored in rec is such that
82the consistent read should not see rec in its present version.
83@return DB_SUCCESS or DB_MISSING_HISTORY */
84dberr_t
85row_vers_build_for_consistent_read(
86/*===============================*/
87 const rec_t* rec, /*!< in: record in a clustered index; the
88 caller must have a latch on the page; this
89 latch locks the top of the stack of versions
90 of this records */
91 mtr_t* mtr, /*!< in: mtr holding the latch on rec; it will
92 also hold the latch on purge_view */
93 dict_index_t* index, /*!< in: the clustered index */
94 ulint** offsets,/*!< in/out: offsets returned by
95 rec_get_offsets(rec, index) */
96 ReadView* view, /*!< in: the consistent read view */
97 mem_heap_t** offset_heap,/*!< in/out: memory heap from which
98 the offsets are allocated */
99 mem_heap_t* in_heap,/*!< in: memory heap from which the memory for
100 *old_vers is allocated; memory for possible
101 intermediate versions is allocated and freed
102 locally within the function */
103 rec_t** old_vers,/*!< out, own: old version, or NULL
104 if the history is missing or the record
105 does not exist in the view, that is,
106 it was freshly inserted afterwards */
107 const dtuple_t**vrow); /*!< out: reports virtual column info if any */
108
109/*****************************************************************//**
110Constructs the last committed version of a clustered index record,
111which should be seen by a semi-consistent read. */
112void
113row_vers_build_for_semi_consistent_read(
114/*====================================*/
115 trx_t* caller_trx,/*!<in/out: trx of current thread */
116 const rec_t* rec, /*!< in: record in a clustered index; the
117 caller must have a latch on the page; this
118 latch locks the top of the stack of versions
119 of this records */
120 mtr_t* mtr, /*!< in: mtr holding the latch on rec */
121 dict_index_t* index, /*!< in: the clustered index */
122 ulint** offsets,/*!< in/out: offsets returned by
123 rec_get_offsets(rec, index) */
124 mem_heap_t** offset_heap,/*!< in/out: memory heap from which
125 the offsets are allocated */
126 mem_heap_t* in_heap,/*!< in: memory heap from which the memory for
127 *old_vers is allocated; memory for possible
128 intermediate versions is allocated and freed
129 locally within the function */
130 const rec_t** old_vers,/*!< out: rec, old version, or NULL if the
131 record does not exist in the view, that is,
132 it was freshly inserted afterwards */
133 const dtuple_t**vrow); /*!< out: holds virtual column info if any
134 is updated in the view */
135
136#endif
137