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

« back to all changes in this revision

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