1
/**********************************************************************
2
File-based list utilities
6
Created 11/28/1995 Heikki Tuuri
7
***********************************************************************/
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
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 */
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
29
/************************************************************************
30
Writes a file address. */
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 */
40
ut_ad(mtr_memo_contains(mtr, buf_block_align(faddr),
41
MTR_MEMO_PAGE_X_FIX));
43
mlog_write_ulint(faddr + FIL_ADDR_PAGE, addr.page, MLOG_4BYTES, mtr);
44
mlog_write_ulint(faddr + FIL_ADDR_BYTE, addr.boffset,
48
/************************************************************************
49
Reads a file address. */
54
/* out: file address */
55
fil_faddr_t* faddr, /* in: pointer to file faddress */
56
mtr_t* mtr) /* in: mini-transaction handle */
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,
68
/************************************************************************
69
Initializes a list base node. */
74
flst_base_node_t* base, /* in: pointer to base node */
75
mtr_t* mtr) /* in: mini-transaction handle */
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);
84
/************************************************************************
91
flst_base_node_t* base, /* in: pointer to base node */
92
mtr_t* mtr) /* in: mini-transaction handle */
94
return(mtr_read_ulint(base + FLST_LEN, MLOG_4BYTES, mtr));
97
/************************************************************************
98
Gets list first node address. */
103
/* out: file address */
104
flst_base_node_t* base, /* in: pointer to base node */
105
mtr_t* mtr) /* in: mini-transaction handle */
107
return(flst_read_addr(base + FLST_FIRST, mtr));
110
/************************************************************************
111
Gets list last node address. */
116
/* out: file address */
117
flst_base_node_t* base, /* in: pointer to base node */
118
mtr_t* mtr) /* in: mini-transaction handle */
120
return(flst_read_addr(base + FLST_LAST, mtr));
123
/************************************************************************
124
Gets list next node address. */
129
/* out: file address */
130
flst_node_t* node, /* in: pointer to node */
131
mtr_t* mtr) /* in: mini-transaction handle */
133
return(flst_read_addr(node + FLST_NEXT, mtr));
136
/************************************************************************
137
Gets list prev node address. */
142
/* out: file address */
143
flst_node_t* node, /* in: pointer to node */
144
mtr_t* mtr) /* in: mini-transaction handle */
146
return(flst_read_addr(node + FLST_PREV, mtr));