~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to innobase/include/row0row.h

  • Committer: monty at mysql
  • Date: 2001-02-17 12:19:19 UTC
  • mto: (554.1.1)
  • mto: This revision was merged to the branch mainline in revision 556.
  • Revision ID: sp1r-monty@donna.mysql.com-20010217121919-07904
Added Innobase to source distribution

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
General row routines
 
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
 
6
Created 4/20/1996 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef row0row_h
 
10
#define row0row_h
 
11
 
 
12
#include "univ.i"
 
13
#include "data0data.h"
 
14
#include "dict0types.h"
 
15
#include "trx0types.h"
 
16
#include "que0types.h"
 
17
#include "mtr0mtr.h"    
 
18
#include "rem0types.h"
 
19
#include "read0types.h"
 
20
#include "btr0types.h"
 
21
 
 
22
/*************************************************************************
 
23
Reads the trx id field from a clustered index record. */
 
24
UNIV_INLINE
 
25
dulint
 
26
row_get_rec_trx_id(
 
27
/*===============*/
 
28
                                /* out: value of the field */
 
29
        rec_t*          rec,    /* in: record */
 
30
        dict_index_t*   index); /* in: clustered index */
 
31
/*************************************************************************
 
32
Reads the roll pointer field from a clustered index record. */
 
33
UNIV_INLINE
 
34
dulint
 
35
row_get_rec_roll_ptr(
 
36
/*=================*/
 
37
                                /* out: value of the field */
 
38
        rec_t*          rec,    /* in: record */
 
39
        dict_index_t*   index); /* in: clustered index */
 
40
/*************************************************************************
 
41
Writes the trx id field to a clustered index record. */
 
42
UNIV_INLINE
 
43
void
 
44
row_set_rec_trx_id(
 
45
/*===============*/
 
46
        rec_t*          rec,    /* in: record */
 
47
        dict_index_t*   index,  /* in: clustered index */
 
48
        dulint          trx_id);        /* in: value of the field */
 
49
/*************************************************************************
 
50
Sets the roll pointer field in a clustered index record. */
 
51
UNIV_INLINE
 
52
void
 
53
row_set_rec_roll_ptr(
 
54
/*=================*/
 
55
        rec_t*          rec,    /* in: record */
 
56
        dict_index_t*   index,  /* in: clustered index */
 
57
        dulint          roll_ptr);/* in: value of the field */
 
58
/*********************************************************************
 
59
When an insert to a table is performed, this function builds the entry which
 
60
has to be inserted to an index on the table. */
 
61
 
 
62
dtuple_t*
 
63
row_build_index_entry(
 
64
/*==================*/
 
65
                                /* out: index entry which should be inserted */
 
66
        dtuple_t*       row,    /* in: row which should be inserted to the
 
67
                                table */
 
68
        dict_index_t*   index,  /* in: index on the table */
 
69
        mem_heap_t*     heap);  /* in: memory heap from which the memory for
 
70
                                the index entry is allocated */
 
71
/*********************************************************************
 
72
Builds an index entry from a row. */
 
73
 
 
74
void
 
75
row_build_index_entry_to_tuple(
 
76
/*===========================*/
 
77
        dtuple_t*       entry,  /* in/out: index entry; the dtuple must have
 
78
                                enough fields for the index! */
 
79
        dtuple_t*       row,    /* in: row */
 
80
        dict_index_t*   index); /* in: index on the table */
 
81
/***********************************************************************
 
82
An inverse function to dict_row_build_index_entry. Builds a row from a
 
83
record in a clustered index. */
 
84
 
 
85
dtuple_t*
 
86
row_build(
 
87
/*======*/
 
88
                                /* out, own: row built; see the NOTE below! */
 
89
        ulint           type,   /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
 
90
                                the former copies also the data fields to
 
91
                                heap as the latter only places pointers to
 
92
                                data fields on the index page, and thus is
 
93
                                more efficient */
 
94
        dict_index_t*   index,  /* in: clustered index */
 
95
        rec_t*          rec,    /* in: record in the clustered index;
 
96
                                NOTE: in the case ROW_COPY_POINTERS
 
97
                                the data fields in the row will point
 
98
                                directly into this record, therefore,
 
99
                                the buffer page of this record must be
 
100
                                at least s-latched and the latch held
 
101
                                as long as the row dtuple is used! */
 
102
        mem_heap_t*     heap);  /* in: memory heap from which the memory
 
103
                                needed is allocated */
 
104
/***********************************************************************
 
105
An inverse function to dict_row_build_index_entry. Builds a row from a
 
106
record in a clustered index. */
 
107
 
 
108
void
 
109
row_build_to_tuple(
 
110
/*===============*/
 
111
        dtuple_t*       row,    /* in/out: row built; see the NOTE below! */
 
112
        dict_index_t*   index,  /* in: clustered index */
 
113
        rec_t*          rec);   /* in: record in the clustered index;
 
114
                                NOTE: the data fields in the row will point
 
115
                                directly into this record, therefore,
 
116
                                the buffer page of this record must be
 
117
                                at least s-latched and the latch held
 
118
                                as long as the row dtuple is used! */
 
119
/***********************************************************************
 
120
Converts an index record to a typed data tuple. */
 
121
 
 
122
dtuple_t*
 
123
row_rec_to_index_entry(
 
124
/*===================*/
 
125
                                /* out, own: index entry built; see the
 
126
                                NOTE below! */
 
127
        ulint           type,   /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
 
128
                                the former copies also the data fields to
 
129
                                heap as the latter only places pointers to
 
130
                                data fields on the index page */
 
131
        dict_index_t*   index,  /* in: index */
 
132
        rec_t*          rec,    /* in: record in the index;
 
133
                                NOTE: in the case ROW_COPY_POINTERS
 
134
                                the data fields in the row will point
 
135
                                directly into this record, therefore,
 
136
                                the buffer page of this record must be
 
137
                                at least s-latched and the latch held
 
138
                                as long as the dtuple is used! */
 
139
        mem_heap_t*     heap);  /* in: memory heap from which the memory
 
140
                                needed is allocated */
 
141
/***********************************************************************
 
142
Builds from a secondary index record a row reference with which we can
 
143
search the clustered index record. */
 
144
 
 
145
dtuple_t*
 
146
row_build_row_ref(
 
147
/*==============*/
 
148
                                /* out, own: row reference built; see the
 
149
                                NOTE below! */
 
150
        ulint           type,   /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
 
151
                                the former copies also the data fields to
 
152
                                heap, whereas the latter only places pointers
 
153
                                to data fields on the index page */
 
154
        dict_index_t*   index,  /* in: index */
 
155
        rec_t*          rec,    /* in: record in the index;
 
156
                                NOTE: in the case ROW_COPY_POINTERS
 
157
                                the data fields in the row will point
 
158
                                directly into this record, therefore,
 
159
                                the buffer page of this record must be
 
160
                                at least s-latched and the latch held
 
161
                                as long as the row reference is used! */
 
162
        mem_heap_t*     heap);  /* in: memory heap from which the memory
 
163
                                needed is allocated */
 
164
/***********************************************************************
 
165
Builds from a secondary index record a row reference with which we can
 
166
search the clustered index record. */
 
167
 
 
168
void
 
169
row_build_row_ref_in_tuple(
 
170
/*=======================*/
 
171
        dtuple_t*       ref,    /* in/out: row reference built; see the
 
172
                                NOTE below! */
 
173
        dict_index_t*   index,  /* in: index */
 
174
        rec_t*          rec);   /* in: record in the index;
 
175
                                NOTE: the data fields in ref will point
 
176
                                directly into this record, therefore,
 
177
                                the buffer page of this record must be
 
178
                                at least s-latched and the latch held
 
179
                                as long as the row reference is used! */
 
180
/***********************************************************************
 
181
From a row build a row reference with which we can search the clustered
 
182
index record. */
 
183
 
 
184
void
 
185
row_build_row_ref_from_row(
 
186
/*=======================*/
 
187
        dtuple_t*       ref,    /* in/out: row reference built; see the
 
188
                                NOTE below! ref must have the right number
 
189
                                of fields! */
 
190
        dict_table_t*   table,  /* in: table */
 
191
        dtuple_t*       row);   /* in: row
 
192
                                NOTE: the data fields in ref will point
 
193
                                directly into data of this row */
 
194
/***********************************************************************
 
195
Builds from a secondary index record a row reference with which we can
 
196
search the clustered index record. */
 
197
UNIV_INLINE
 
198
void
 
199
row_build_row_ref_fast(
 
200
/*===================*/
 
201
        dtuple_t*       ref,    /* in: typed data tuple where the reference
 
202
                                is built */
 
203
        ulint*          map,    /* in: array of field numbers in rec telling
 
204
                                how ref should be built from the fields of
 
205
                                rec */
 
206
        rec_t*          rec);   /* in: record in the index; must be preserved
 
207
                                while ref is used, as we do not copy field
 
208
                                values to heap */
 
209
/*******************************************************************
 
210
Searches the clustered index record for a row, if we have the row
 
211
reference. */
 
212
 
 
213
ibool
 
214
row_search_on_row_ref(
 
215
/*==================*/
 
216
                                /* out: TRUE if found */
 
217
        btr_pcur_t*     pcur,   /* in/out: persistent cursor, which must
 
218
                                be closed by the caller */
 
219
        ulint           mode,   /* in: BTR_MODIFY_LEAF, ... */
 
220
        dict_table_t*   table,  /* in: table */
 
221
        dtuple_t*       ref,    /* in: row reference */
 
222
        mtr_t*          mtr);   /* in: mtr */
 
223
/*************************************************************************
 
224
Fetches the clustered index record for a secondary index record. The latches
 
225
on the secondary index record are preserved. */
 
226
 
 
227
rec_t*
 
228
row_get_clust_rec(
 
229
/*==============*/
 
230
                                /* out: record or NULL, if no record found */
 
231
        ulint           mode,   /* in: BTR_MODIFY_LEAF, ... */
 
232
        rec_t*          rec,    /* in: record in a secondary index */
 
233
        dict_index_t*   index,  /* in: secondary index */
 
234
        dict_index_t**  clust_index,/* out: clustered index */
 
235
        mtr_t*          mtr);   /* in: mtr */
 
236
/*******************************************************************
 
237
Searches an index record. */
 
238
 
 
239
ibool
 
240
row_search_index_entry(
 
241
/*===================*/
 
242
                                /* out: TRUE if found */
 
243
        dict_index_t*   index,  /* in: index */
 
244
        dtuple_t*       entry,  /* in: index entry */
 
245
        ulint           mode,   /* in: BTR_MODIFY_LEAF, ... */
 
246
        btr_pcur_t*     pcur,   /* in/out: persistent cursor, which must
 
247
                                be closed by the caller */
 
248
        mtr_t*          mtr);   /* in: mtr */
 
249
 
 
250
        
 
251
#define ROW_COPY_DATA           1
 
252
#define ROW_COPY_POINTERS       2
 
253
 
 
254
/* The allowed latching order of index records is the following:
 
255
(1) a secondary index record ->
 
256
(2) the clustered index record ->
 
257
(3) rollback segment data for the clustered index record.
 
258
 
 
259
No new latches may be obtained while the kernel mutex is reserved.
 
260
However, the kernel mutex can be reserved while latches are owned. */
 
261
 
 
262
#ifndef UNIV_NONINL
 
263
#include "row0row.ic"
 
264
#endif
 
265
 
 
266
#endif