~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
3
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/trx0purge.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Purge old versions
22
23
Created 3/26/1996 Heikki Tuuri
24
*******************************************************/
25
26
#ifndef trx0purge_h
27
#define trx0purge_h
28
29
#include "univ.i"
30
#include "trx0types.h"
31
#include "mtr0mtr.h"
32
#include "trx0sys.h"
33
#include "que0types.h"
34
#include "page0page.h"
35
#include "usr0sess.h"
36
#include "fil0fil.h"
37
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
38
/** The global data structure coordinating a purge */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
39
extern trx_purge_t*	purge_sys;
40
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
41
/** A dummy undo record used as a return value when we have a whole undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
42
which needs no purge */
43
extern trx_undo_rec_t	trx_purge_dummy_rec;
44
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
45
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
46
Calculates the file address of an undo log header when we have the file
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
47
address of its history list node.
48
@return	file address of the log */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
49
UNIV_INLINE
50
fil_addr_t
51
trx_purge_get_log_from_hist(
52
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
53
	fil_addr_t	node_addr);	/*!< in: file address of the history
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
54
					list node of the log */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
55
/*****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
56
Checks if trx_id is >= purge_view: then it is guaranteed that its update
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
57
undo log still exists in the system.
58
@return TRUE if is sure that it is preserved, also if the function
59
returns FALSE, it is possible that the undo log still exists in the
60
system */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
61
UNIV_INTERN
62
ibool
63
trx_purge_update_undo_must_exist(
64
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
65
	trx_id_t	trx_id);/*!< in: transaction id */
66
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
67
Creates the global purge system control structure and inits the history
68
mutex. */
69
UNIV_INTERN
70
void
71
trx_purge_sys_create(void);
72
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
73
/********************************************************************//**
1819.5.106 by stewart at flamingspork
[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
74
Frees the global purge system control structure. */
75
UNIV_INTERN
76
void
77
trx_purge_sys_close(void);
78
/*======================*/
79
/************************************************************************
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
80
Adds the update undo log as the first log in the history list. Removes the
81
update undo log segment from the rseg slot if it is too big for reuse. */
82
UNIV_INTERN
83
void
84
trx_purge_add_update_undo_to_history(
85
/*=================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
86
	trx_t*	trx,		/*!< in: transaction */
87
	page_t*	undo_page,	/*!< in: update undo log header page,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
88
				x-latched */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
89
	mtr_t*	mtr);		/*!< in: mtr */
90
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
91
Fetches the next undo log record from the history list to purge. It must be
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
92
released with the corresponding release function.
93
@return copy of an undo log record or pointer to trx_purge_dummy_rec,
94
if the whole undo log can skipped in purge; NULL if none left */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
95
UNIV_INTERN
96
trx_undo_rec_t*
97
trx_purge_fetch_next_rec(
98
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
99
	roll_ptr_t*	roll_ptr,/*!< out: roll pointer to undo record */
100
	trx_undo_inf_t** cell,	/*!< out: storage cell for the record in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
101
				purge array */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
102
	mem_heap_t*	heap);	/*!< in: memory heap where copied */
103
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
104
Releases a reserved purge undo record. */
105
UNIV_INTERN
106
void
107
trx_purge_rec_release(
108
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
109
	trx_undo_inf_t*	cell);	/*!< in: storage cell */
110
/*******************************************************************//**
111
This function runs a purge batch.
112
@return	number of undo log pages handled in the batch */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
113
UNIV_INTERN
114
ulint
1819.7.68 by Stewart Smith
Merge initial InnoDB+ import.
115
trx_purge(
116
/*======*/
117
	ulint	limit);		/*!< in: the maximum number of records to
118
				purge in one batch */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
119
/******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
120
Prints information of the purge system to stderr. */
121
UNIV_INTERN
122
void
123
trx_purge_sys_print(void);
124
/*======================*/
125
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
126
/** The control structure used in the purge operation */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
127
struct trx_purge_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
128
	ulint		state;		/*!< Purge system state */
129
	sess_t*		sess;		/*!< System session running the purge
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
130
					query */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
131
	trx_t*		trx;		/*!< System transaction running the purge
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
132
					query: this trx is not in the trx list
133
					of the trx system and it never ends */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
134
	que_t*		query;		/*!< The query graph which will do the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
135
					parallelized purge operation */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
136
	rw_lock_t	latch;		/*!< The latch protecting the purge view.
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
137
					A purge operation must acquire an
138
					x-latch here for the instant at which
139
					it changes the purge view: an undo
140
					log operation can prevent this by
141
					obtaining an s-latch here. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
142
	read_view_t*	view;		/*!< The purge will not remove undo logs
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
143
					which are >= this view (purge view) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
144
	mutex_t		mutex;		/*!< Mutex protecting the fields below */
145
	ulint		n_pages_handled;/*!< Approximate number of undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
146
					pages processed in purge */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
147
	ulint		handle_limit;	/*!< Target of how many pages to get
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
148
					processed in the current purge */
149
	/*------------------------------*/
150
	/* The following two fields form the 'purge pointer' which advances
151
	during a purge, and which is used in history list truncation */
152
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
153
	trx_id_t	purge_trx_no;	/*!< Purge has advanced past all
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
154
					transactions whose number is less
155
					than this */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
156
	undo_no_t	purge_undo_no;	/*!< Purge has advanced past all records
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
157
					whose undo number is less than this */
158
	/*-----------------------------*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
159
	ibool		next_stored;	/*!< TRUE if the info of the next record
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
160
					to purge is stored below: if yes, then
161
					the transaction number and the undo
162
					number of the record are stored in
163
					purge_trx_no and purge_undo_no above */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
164
	trx_rseg_t*	rseg;		/*!< Rollback segment for the next undo
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
165
					record to purge */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
166
	ulint		page_no;	/*!< Page number for the next undo
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
167
					record to purge, page number of the
168
					log header, if dummy record */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
169
	ulint		offset;		/*!< Page offset for the next undo
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
170
					record to purge, 0 if the dummy
171
					record */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
172
	ulint		hdr_page_no;	/*!< Header page of the undo log where
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
173
					the next record to purge belongs */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
174
	ulint		hdr_offset;	/*!< Header byte offset on the page */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
175
	/*-----------------------------*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
176
	trx_undo_arr_t*	arr;		/*!< Array of transaction numbers and
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
177
					undo numbers of the undo records
178
					currently under processing in purge */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
179
	mem_heap_t*	heap;		/*!< Temporary storage used during a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
180
					purge: can be emptied after purge
181
					completes */
182
};
183
184
#define TRX_PURGE_ON		1	/* purge operation is running */
185
#define TRX_STOP_PURGE		2	/* purge operation is stopped, or
186
					it should be stopped */
187
#ifndef UNIV_NONINL
188
#include "trx0purge.ic"
189
#endif
190
191
#endif