1
/*****************************************************************************
3
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/trx0rseg.ic
23
Created 3/26/1996 Heikki Tuuri
24
*******************************************************/
29
/******************************************************************//**
30
Gets a rollback segment header.
31
@return rollback segment header, page x-latched */
36
ulint space, /*!< in: space where placed */
37
ulint zip_size, /*!< in: compressed page size in bytes
38
or 0 for uncompressed pages */
39
ulint page_no, /*!< in: page number of the header */
40
mtr_t* mtr) /*!< in: mtr */
45
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
46
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER);
48
header = TRX_RSEG + buf_block_get_frame(block);
53
/******************************************************************//**
54
Gets a newly created rollback segment header.
55
@return rollback segment header, page x-latched */
60
ulint space, /*!< in: space where placed */
61
ulint zip_size, /*!< in: compressed page size in bytes
62
or 0 for uncompressed pages */
63
ulint page_no, /*!< in: page number of the header */
64
mtr_t* mtr) /*!< in: mtr */
69
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
70
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
72
header = TRX_RSEG + buf_block_get_frame(block);
77
/***************************************************************//**
78
Gets the file page number of the nth undo log slot.
79
@return page number of the undo log segment */
82
trx_rsegf_get_nth_undo(
83
/*===================*/
84
trx_rsegf_t* rsegf, /*!< in: rollback segment header */
85
ulint n, /*!< in: index of slot */
86
mtr_t* mtr) /*!< in: mtr */
88
if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) {
90
"InnoDB: Error: trying to get slot %lu of rseg\n",
95
return(mtr_read_ulint(rsegf + TRX_RSEG_UNDO_SLOTS
96
+ n * TRX_RSEG_SLOT_SIZE, MLOG_4BYTES, mtr));
99
/***************************************************************//**
100
Sets the file page number of the nth undo log slot. */
103
trx_rsegf_set_nth_undo(
104
/*===================*/
105
trx_rsegf_t* rsegf, /*!< in: rollback segment header */
106
ulint n, /*!< in: index of slot */
107
ulint page_no,/*!< in: page number of the undo log segment */
108
mtr_t* mtr) /*!< in: mtr */
110
if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) {
112
"InnoDB: Error: trying to set slot %lu of rseg\n",
117
mlog_write_ulint(rsegf + TRX_RSEG_UNDO_SLOTS + n * TRX_RSEG_SLOT_SIZE,
118
page_no, MLOG_4BYTES, mtr);
121
/****************************************************************//**
122
Looks for a free slot for an undo log segment.
123
@return slot index or ULINT_UNDEFINED if not found */
126
trx_rsegf_undo_find_free(
127
/*=====================*/
128
trx_rsegf_t* rsegf, /*!< in: rollback segment header */
129
mtr_t* mtr) /*!< in: mtr */
134
for (i = 0; i < TRX_RSEG_N_SLOTS; i++) {
136
page_no = trx_rsegf_get_nth_undo(rsegf, i, mtr);
138
if (page_no == FIL_NULL) {
144
return(ULINT_UNDEFINED);