~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/read0read.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
 
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 as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file include/read0read.h
 
21
Cursor read
 
22
 
 
23
Created 2/16/1997 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
#ifndef read0read_h
 
27
#define read0read_h
 
28
 
 
29
#include "univ.i"
 
30
 
 
31
 
 
32
#include "ut0byte.h"
 
33
#include "ut0lst.h"
 
34
#include "trx0trx.h"
 
35
#include "read0types.h"
 
36
 
 
37
/*********************************************************************//**
 
38
Opens a read view where exactly the transactions serialized before this
 
39
point in time are seen in the view.
 
40
@return own: read view struct */
 
41
UNIV_INTERN
 
42
read_view_t*
 
43
read_view_open_now(
 
44
/*===============*/
 
45
        trx_id_t        cr_trx_id,      /*!< in: trx_id of creating
 
46
                                        transaction, or ut_dulint_zero
 
47
                                        used in purge */
 
48
        mem_heap_t*     heap);          /*!< in: memory heap from which
 
49
                                        allocated */
 
50
/*********************************************************************//**
 
51
Makes a copy of the oldest existing read view, or opens a new. The view
 
52
must be closed with ..._close.
 
53
@return own: read view struct */
 
54
UNIV_INTERN
 
55
read_view_t*
 
56
read_view_oldest_copy_or_open_new(
 
57
/*==============================*/
 
58
        trx_id_t        cr_trx_id,      /*!< in: trx_id of creating
 
59
                                        transaction, or ut_dulint_zero
 
60
                                        used in purge */
 
61
        mem_heap_t*     heap);          /*!< in: memory heap from which
 
62
                                        allocated */
 
63
/*********************************************************************//**
 
64
Closes a read view. */
 
65
UNIV_INTERN
 
66
void
 
67
read_view_close(
 
68
/*============*/
 
69
        read_view_t*    view);  /*!< in: read view */
 
70
/*********************************************************************//**
 
71
Closes a consistent read view for MySQL. This function is called at an SQL
 
72
statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */
 
73
UNIV_INTERN
 
74
void
 
75
read_view_close_for_mysql(
 
76
/*======================*/
 
77
        trx_t*  trx);   /*!< in: trx which has a read view */
 
78
/*********************************************************************//**
 
79
Checks if a read view sees the specified transaction.
 
80
@return TRUE if sees */
 
81
UNIV_INLINE
 
82
ibool
 
83
read_view_sees_trx_id(
 
84
/*==================*/
 
85
        const read_view_t*      view,   /*!< in: read view */
 
86
        trx_id_t                trx_id);/*!< in: trx id */
 
87
/*********************************************************************//**
 
88
Prints a read view to stderr. */
 
89
UNIV_INTERN
 
90
void
 
91
read_view_print(
 
92
/*============*/
 
93
        const read_view_t*      view);  /*!< in: read view */
 
94
/*********************************************************************//**
 
95
Create a consistent cursor view for mysql to be used in cursors. In this
 
96
consistent read view modifications done by the creating transaction or future
 
97
transactions are not visible. */
 
98
UNIV_INTERN
 
99
cursor_view_t*
 
100
read_cursor_view_create_for_mysql(
 
101
/*==============================*/
 
102
        trx_t*          cr_trx);/*!< in: trx where cursor view is created */
 
103
/*********************************************************************//**
 
104
Close a given consistent cursor view for mysql and restore global read view
 
105
back to a transaction read view. */
 
106
UNIV_INTERN
 
107
void
 
108
read_cursor_view_close_for_mysql(
 
109
/*=============================*/
 
110
        trx_t*          trx,            /*!< in: trx */
 
111
        cursor_view_t*  curview);       /*!< in: cursor view to be closed */
 
112
/*********************************************************************//**
 
113
This function sets a given consistent cursor view to a transaction
 
114
read view if given consistent cursor view is not NULL. Otherwise, function
 
115
restores a global read view to a transaction read view. */
 
116
UNIV_INTERN
 
117
void
 
118
read_cursor_set_for_mysql(
 
119
/*======================*/
 
120
        trx_t*          trx,    /*!< in: transaction where cursor is set */
 
121
        cursor_view_t*  curview);/*!< in: consistent cursor view to be set */
 
122
 
 
123
/** Read view lists the trx ids of those transactions for which a consistent
 
124
read should not see the modifications to the database. */
 
125
 
 
126
struct read_view_struct{
 
127
        ulint           type;   /*!< VIEW_NORMAL, VIEW_HIGH_GRANULARITY */
 
128
        undo_no_t       undo_no;/*!< ut_dulint_zero or if type is
 
129
                                VIEW_HIGH_GRANULARITY
 
130
                                transaction undo_no when this high-granularity
 
131
                                consistent read view was created */
 
132
        trx_id_t        low_limit_no;
 
133
                                /*!< The view does not need to see the undo
 
134
                                logs for transactions whose transaction number
 
135
                                is strictly smaller (<) than this value: they
 
136
                                can be removed in purge if not needed by other
 
137
                                views */
 
138
        trx_id_t        low_limit_id;
 
139
                                /*!< The read should not see any transaction
 
140
                                with trx id >= this value. In other words,
 
141
                                this is the "high water mark". */
 
142
        trx_id_t        up_limit_id;
 
143
                                /*!< The read should see all trx ids which
 
144
                                are strictly smaller (<) than this value.
 
145
                                In other words,
 
146
                                this is the "low water mark". */
 
147
        ulint           n_trx_ids;
 
148
                                /*!< Number of cells in the trx_ids array */
 
149
        trx_id_t*       trx_ids;/*!< Additional trx ids which the read should
 
150
                                not see: typically, these are the active
 
151
                                transactions at the time when the read is
 
152
                                serialized, except the reading transaction
 
153
                                itself; the trx ids in this array are in a
 
154
                                descending order. These trx_ids should be
 
155
                                between the "low" and "high" water marks,
 
156
                                that is, up_limit_id and low_limit_id. */
 
157
        trx_id_t        creator_trx_id;
 
158
                                /*!< trx id of creating transaction, or
 
159
                                ut_dulint_zero used in purge */
 
160
        UT_LIST_NODE_T(read_view_t) view_list;
 
161
                                /*!< List of read views in trx_sys */
 
162
};
 
163
 
 
164
/** Read view types @{ */
 
165
#define VIEW_NORMAL             1       /*!< Normal consistent read view
 
166
                                        where transaction does not see changes
 
167
                                        made by active transactions except
 
168
                                        creating transaction. */
 
169
#define VIEW_HIGH_GRANULARITY   2       /*!< High-granularity read view where
 
170
                                        transaction does not see changes
 
171
                                        made by active transactions and own
 
172
                                        changes after a point in time when this
 
173
                                        read view was created. */
 
174
/* @} */
 
175
 
 
176
/** Implement InnoDB framework to support consistent read views in
 
177
cursors. This struct holds both heap where consistent read view
 
178
is allocated and pointer to a read view. */
 
179
 
 
180
struct cursor_view_struct{
 
181
        mem_heap_t*     heap;
 
182
                                /*!< Memory heap for the cursor view */
 
183
        read_view_t*    read_view;
 
184
                                /*!< Consistent read view of the cursor*/
 
185
        ulint           n_mysql_tables_in_use;
 
186
                                /*!< number of Innobase tables used in the
 
187
                                processing of this cursor */
 
188
};
 
189
 
 
190
#ifndef UNIV_NONINL
 
191
#include "read0read.ic"
 
192
#endif
 
193
 
 
194
#endif