~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/fut0lst.ic

  • Committer: Monty Taylor
  • Date: 2010-04-22 02:46:23 UTC
  • mto: (1497.3.4 enable-dtrace)
  • mto: This revision was merged to the branch mainline in revision 1527.
  • Revision ID: mordred@inaugust.com-20100422024623-4urw8fi8eraci08p
Don't overwrite the pandora_vc_revinfo file if we don't have new
authoratative information.

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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 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
 
}