~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Tags: innodb-plugin-1.0.1
Imported 1.0.1 with clean - with no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Cursor read
 
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
 
6
Created 2/16/1997 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef read0read_h
 
10
#define read0read_h
 
11
 
 
12
#include "univ.i"
 
13
 
 
14
 
 
15
#include "ut0byte.h"
 
16
#include "ut0lst.h"
 
17
#include "trx0trx.h"
 
18
#include "read0types.h"
 
19
 
 
20
/*************************************************************************
 
21
Opens a read view where exactly the transactions serialized before this
 
22
point in time are seen in the view. */
 
23
UNIV_INTERN
 
24
read_view_t*
 
25
read_view_open_now(
 
26
/*===============*/
 
27
                                        /* out, own: read view struct */
 
28
        dulint          cr_trx_id,      /* in: trx_id of creating
 
29
                                        transaction, or (0, 0) used in
 
30
                                        purge */
 
31
        mem_heap_t*     heap);          /* in: memory heap from which
 
32
                                        allocated */
 
33
/*************************************************************************
 
34
Makes a copy of the oldest existing read view, or opens a new. The view
 
35
must be closed with ..._close. */
 
36
UNIV_INTERN
 
37
read_view_t*
 
38
read_view_oldest_copy_or_open_new(
 
39
/*==============================*/
 
40
                                        /* out, own: read view struct */
 
41
        dulint          cr_trx_id,      /* in: trx_id of creating
 
42
                                        transaction, or (0, 0) used in
 
43
                                        purge */
 
44
        mem_heap_t*     heap);          /* in: memory heap from which
 
45
                                        allocated */
 
46
/*************************************************************************
 
47
Closes a read view. */
 
48
UNIV_INTERN
 
49
void
 
50
read_view_close(
 
51
/*============*/
 
52
        read_view_t*    view);  /* in: read view */
 
53
/*************************************************************************
 
54
Closes a consistent read view for MySQL. This function is called at an SQL
 
55
statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */
 
56
UNIV_INTERN
 
57
void
 
58
read_view_close_for_mysql(
 
59
/*======================*/
 
60
        trx_t*  trx);   /* in: trx which has a read view */
 
61
/*************************************************************************
 
62
Checks if a read view sees the specified transaction. */
 
63
UNIV_INLINE
 
64
ibool
 
65
read_view_sees_trx_id(
 
66
/*==================*/
 
67
                                /* out: TRUE if sees */
 
68
        read_view_t*    view,   /* in: read view */
 
69
        dulint          trx_id);/* in: trx id */
 
70
/*************************************************************************
 
71
Prints a read view to stderr. */
 
72
UNIV_INTERN
 
73
void
 
74
read_view_print(
 
75
/*============*/
 
76
        read_view_t*    view);  /* in: read view */
 
77
/*************************************************************************
 
78
Create a consistent cursor view for mysql to be used in cursors. In this
 
79
consistent read view modifications done by the creating transaction or future
 
80
transactions are not visible. */
 
81
UNIV_INTERN
 
82
cursor_view_t*
 
83
read_cursor_view_create_for_mysql(
 
84
/*==============================*/
 
85
        trx_t*          cr_trx);/* in: trx where cursor view is created */
 
86
/*************************************************************************
 
87
Close a given consistent cursor view for mysql and restore global read view
 
88
back to a transaction read view. */
 
89
UNIV_INTERN
 
90
void
 
91
read_cursor_view_close_for_mysql(
 
92
/*=============================*/
 
93
        trx_t*          trx,            /* in: trx */
 
94
        cursor_view_t*  curview);       /* in: cursor view to be closed */
 
95
/*************************************************************************
 
96
This function sets a given consistent cursor view to a transaction
 
97
read view if given consistent cursor view is not NULL. Otherwise, function
 
98
restores a global read view to a transaction read view. */
 
99
UNIV_INTERN
 
100
void
 
101
read_cursor_set_for_mysql(
 
102
/*======================*/
 
103
        trx_t*          trx,    /* in: transaction where cursor is set */
 
104
        cursor_view_t*  curview);/* in: consistent cursor view to be set */
 
105
 
 
106
/* Read view lists the trx ids of those transactions for which a consistent
 
107
read should not see the modifications to the database. */
 
108
 
 
109
struct read_view_struct{
 
110
        ulint   type;           /* VIEW_NORMAL, VIEW_HIGH_GRANULARITY */
 
111
        dulint  undo_no;        /* (0, 0) or if type is VIEW_HIGH_GRANULARITY
 
112
                                transaction undo_no when this high-granularity
 
113
                                consistent read view was created */
 
114
        dulint  low_limit_no;   /* The view does not need to see the undo
 
115
                                logs for transactions whose transaction number
 
116
                                is strictly smaller (<) than this value: they
 
117
                                can be removed in purge if not needed by other
 
118
                                views */
 
119
        dulint  low_limit_id;   /* The read should not see any transaction
 
120
                                with trx id >= this value */
 
121
        dulint  up_limit_id;    /* The read should see all trx ids which
 
122
                                are strictly smaller (<) than this value */
 
123
        ulint   n_trx_ids;      /* Number of cells in the trx_ids array */
 
124
        dulint* trx_ids;        /* Additional trx ids which the read should
 
125
                                not see: typically, these are the active
 
126
                                transactions at the time when the read is
 
127
                                serialized, except the reading transaction
 
128
                                itself; the trx ids in this array are in a
 
129
                                descending order */
 
130
        dulint  creator_trx_id; /* trx id of creating transaction, or
 
131
                                (0, 0) used in purge */
 
132
        UT_LIST_NODE_T(read_view_t) view_list;
 
133
                                /* List of read views in trx_sys */
 
134
};
 
135
 
 
136
/* Read view types */
 
137
#define VIEW_NORMAL             1       /* Normal consistent read view
 
138
                                        where transaction does not see changes
 
139
                                        made by active transactions except
 
140
                                        creating transaction. */
 
141
#define VIEW_HIGH_GRANULARITY   2       /* High-granularity read view where
 
142
                                        transaction does not see changes
 
143
                                        made by active transactions and own
 
144
                                        changes after a point in time when this
 
145
                                        read view was created. */
 
146
 
 
147
/* Implement InnoDB framework to support consistent read views in
 
148
cursors. This struct holds both heap where consistent read view
 
149
is allocated and pointer to a read view. */
 
150
 
 
151
struct cursor_view_struct{
 
152
        mem_heap_t*     heap;
 
153
                                /* Memory heap for the cursor view */
 
154
        read_view_t*    read_view;
 
155
                                /* Consistent read view of the cursor*/
 
156
        ulint           n_mysql_tables_in_use;
 
157
                                /* number of Innobase tables used in the
 
158
                                processing of this cursor */
 
159
};
 
160
 
 
161
#ifndef UNIV_NONINL
 
162
#include "read0read.ic"
 
163
#endif
 
164
 
 
165
#endif