~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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
 
 
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
 
 
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
 
 
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
 
 
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
 
 
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
 
 
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
 
 
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
 
 
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
        ibool   can_be_too_old; /* TRUE if the system has had to purge old
 
115
                                versions which this read view should be able
 
116
                                to access: the read view can bump into the
 
117
                                DB_MISSING_HISTORY error */
 
118
        dulint  low_limit_no;   /* The view does not need to see the undo
 
119
                                logs for transactions whose transaction number
 
120
                                is strictly smaller (<) than this value: they
 
121
                                can be removed in purge if not needed by other
 
122
                                views */
 
123
        dulint  low_limit_id;   /* The read should not see any transaction
 
124
                                with trx id >= this value */
 
125
        dulint  up_limit_id;    /* The read should see all trx ids which
 
126
                                are strictly smaller (<) than this value */
 
127
        ulint   n_trx_ids;      /* Number of cells in the trx_ids array */
 
128
        dulint* trx_ids;        /* Additional trx ids which the read should
 
129
                                not see: typically, these are the active
 
130
                                transactions at the time when the read is
 
131
                                serialized, except the reading transaction
 
132
                                itself; the trx ids in this array are in a
 
133
                                descending order */
 
134
        dulint  creator_trx_id; /* trx id of creating transaction, or
 
135
                                (0, 0) used in purge */
 
136
        UT_LIST_NODE_T(read_view_t) view_list;
 
137
                                /* List of read views in trx_sys */
 
138
};
 
139
 
 
140
/* Read view types */
 
141
#define VIEW_NORMAL             1       /* Normal consistent read view
 
142
                                        where transaction does not see changes
 
143
                                        made by active transactions except
 
144
                                        creating transaction. */
 
145
#define VIEW_HIGH_GRANULARITY   2       /* High-granularity read view where
 
146
                                        transaction does not see changes
 
147
                                        made by active transactions and own
 
148
                                        changes after a point in time when this
 
149
                                        read view was created. */
 
150
 
 
151
/* Implement InnoDB framework to support consistent read views in
 
152
cursors. This struct holds both heap where consistent read view
 
153
is allocated and pointer to a read view. */
 
154
 
 
155
struct cursor_view_struct{
 
156
        mem_heap_t*     heap;
 
157
                                /* Memory heap for the cursor view */
 
158
        read_view_t*    read_view;
 
159
                                /* Consistent read view of the cursor*/
 
160
        ulint           n_mysql_tables_in_use;
 
161
                                /* number of Innobase tables used in the
 
162
                                processing of this cursor */
 
163
};
 
164
 
 
165
#ifndef UNIV_NONINL
 
166
#include "read0read.ic"
 
167
#endif
 
168
 
 
169
#endif