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

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/fut0lst.ic

  • 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) 1995, 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/fut0lst.ic
 
21
File-based list utilities
 
22
 
 
23
Created 11/28/1995 Heikki Tuuri
 
24
***********************************************************************/
 
25
 
 
26
#include "fut0fut.h"
 
27
#include "mtr0log.h"
 
28
#include "buf0buf.h"
 
29
 
 
30
/* We define the field offsets of a node for the list */
 
31
#define FLST_PREV       0       /* 6-byte address of the previous list element;
 
32
                                the page part of address is FIL_NULL, if no
 
33
                                previous element */
 
34
#define FLST_NEXT       FIL_ADDR_SIZE   /* 6-byte address of the next
 
35
                                list element; the page part of address
 
36
                                is FIL_NULL, if no next element */
 
37
 
 
38
/* We define the field offsets of a base node for the list */
 
39
#define FLST_LEN        0       /* 32-bit list length field */
 
40
#define FLST_FIRST      4       /* 6-byte address of the first element
 
41
                                of the list; undefined if empty list */
 
42
#define FLST_LAST       (4 + FIL_ADDR_SIZE) /* 6-byte address of the
 
43
                                last element of the list; undefined
 
44
                                if empty list */
 
45
 
 
46
/********************************************************************//**
 
47
Writes a file address. */
 
48
UNIV_INLINE
 
49
void
 
50
flst_write_addr(
 
51
/*============*/
 
52
        fil_faddr_t*    faddr,  /*!< in: pointer to file faddress */
 
53
        fil_addr_t      addr,   /*!< in: file address */
 
54
        mtr_t*          mtr)    /*!< in: mini-transaction handle */
 
55
{
 
56
        ut_ad(faddr && mtr);
 
57
        ut_ad(mtr_memo_contains_page(mtr, faddr, MTR_MEMO_PAGE_X_FIX));
 
58
        ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
 
59
        ut_a(ut_align_offset(faddr, UNIV_PAGE_SIZE) >= FIL_PAGE_DATA);
 
60
 
 
61
        mlog_write_ulint(faddr + FIL_ADDR_PAGE, addr.page, MLOG_4BYTES, mtr);
 
62
        mlog_write_ulint(faddr + FIL_ADDR_BYTE, addr.boffset,
 
63
                         MLOG_2BYTES, mtr);
 
64
}
 
65
 
 
66
/********************************************************************//**
 
67
Reads a file address.
 
68
@return file address */
 
69
UNIV_INLINE
 
70
fil_addr_t
 
71
flst_read_addr(
 
72
/*===========*/
 
73
        const fil_faddr_t*      faddr,  /*!< in: pointer to file faddress */
 
74
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
75
{
 
76
        fil_addr_t      addr;
 
77
 
 
78
        ut_ad(faddr && mtr);
 
79
 
 
80
        addr.page = mtr_read_ulint(faddr + FIL_ADDR_PAGE, MLOG_4BYTES, mtr);
 
81
        addr.boffset = mtr_read_ulint(faddr + FIL_ADDR_BYTE, MLOG_2BYTES,
 
82
                                      mtr);
 
83
        ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
 
84
        ut_a(ut_align_offset(faddr, UNIV_PAGE_SIZE) >= FIL_PAGE_DATA);
 
85
        return(addr);
 
86
}
 
87
 
 
88
/********************************************************************//**
 
89
Initializes a list base node. */
 
90
UNIV_INLINE
 
91
void
 
92
flst_init(
 
93
/*======*/
 
94
        flst_base_node_t*       base,   /*!< in: pointer to base node */
 
95
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
96
{
 
97
        ut_ad(mtr_memo_contains_page(mtr, base, MTR_MEMO_PAGE_X_FIX));
 
98
 
 
99
        mlog_write_ulint(base + FLST_LEN, 0, MLOG_4BYTES, mtr);
 
100
        flst_write_addr(base + FLST_FIRST, fil_addr_null, mtr);
 
101
        flst_write_addr(base + FLST_LAST, fil_addr_null, mtr);
 
102
}
 
103
 
 
104
/********************************************************************//**
 
105
Gets list length.
 
106
@return length */
 
107
UNIV_INLINE
 
108
ulint
 
109
flst_get_len(
 
110
/*=========*/
 
111
        const flst_base_node_t* base,   /*!< in: pointer to base node */
 
112
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
113
{
 
114
        return(mtr_read_ulint(base + FLST_LEN, MLOG_4BYTES, mtr));
 
115
}
 
116
 
 
117
/********************************************************************//**
 
118
Gets list first node address.
 
119
@return file address */
 
120
UNIV_INLINE
 
121
fil_addr_t
 
122
flst_get_first(
 
123
/*===========*/
 
124
        const flst_base_node_t* base,   /*!< in: pointer to base node */
 
125
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
126
{
 
127
        return(flst_read_addr(base + FLST_FIRST, mtr));
 
128
}
 
129
 
 
130
/********************************************************************//**
 
131
Gets list last node address.
 
132
@return file address */
 
133
UNIV_INLINE
 
134
fil_addr_t
 
135
flst_get_last(
 
136
/*==========*/
 
137
        const flst_base_node_t* base,   /*!< in: pointer to base node */
 
138
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
139
{
 
140
        return(flst_read_addr(base + FLST_LAST, mtr));
 
141
}
 
142
 
 
143
/********************************************************************//**
 
144
Gets list next node address.
 
145
@return file address */
 
146
UNIV_INLINE
 
147
fil_addr_t
 
148
flst_get_next_addr(
 
149
/*===============*/
 
150
        const flst_node_t*      node,   /*!< in: pointer to node */
 
151
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
152
{
 
153
        return(flst_read_addr(node + FLST_NEXT, mtr));
 
154
}
 
155
 
 
156
/********************************************************************//**
 
157
Gets list prev node address.
 
158
@return file address */
 
159
UNIV_INLINE
 
160
fil_addr_t
 
161
flst_get_prev_addr(
 
162
/*===============*/
 
163
        const flst_node_t*      node,   /*!< in: pointer to node */
 
164
        mtr_t*                  mtr)    /*!< in: mini-transaction handle */
 
165
{
 
166
        return(flst_read_addr(node + FLST_PREV, mtr));
 
167
}