641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
1 |
/************************************************************************
|
2 |
Record manager
|
|
3 |
||
4 |
(c) 1994-1996 Innobase Oy
|
|
5 |
||
6 |
Created 5/30/1994 Heikki Tuuri
|
|
7 |
*************************************************************************/
|
|
8 |
||
9 |
#ifndef rem0rec_h
|
|
10 |
#define rem0rec_h
|
|
11 |
||
12 |
#include "univ.i" |
|
13 |
#include "data0data.h" |
|
14 |
#include "rem0types.h" |
|
15 |
#include "mtr0types.h" |
|
16 |
#include "page0types.h" |
|
17 |
||
18 |
/* Info bit denoting the predefined minimum record: this bit is set
|
|
19 |
if and only if the record is the first user record on a non-leaf
|
|
20 |
B-tree page that is the leftmost page on its level
|
|
21 |
(PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
|
|
22 |
#define REC_INFO_MIN_REC_FLAG 0x10UL
|
|
23 |
/* The deleted flag in info bits */
|
|
24 |
#define REC_INFO_DELETED_FLAG 0x20UL /* when bit is set to 1, it means the |
|
25 |
record has been delete marked */
|
|
26 |
||
27 |
/* Number of extra bytes in an old-style record,
|
|
28 |
in addition to the data and the offsets */
|
|
29 |
#define REC_N_OLD_EXTRA_BYTES 6
|
|
30 |
/* Number of extra bytes in a new-style record,
|
|
31 |
in addition to the data and the offsets */
|
|
32 |
#define REC_N_NEW_EXTRA_BYTES 5
|
|
33 |
||
34 |
/* Record status values */
|
|
35 |
#define REC_STATUS_ORDINARY 0
|
|
36 |
#define REC_STATUS_NODE_PTR 1
|
|
37 |
#define REC_STATUS_INFIMUM 2
|
|
38 |
#define REC_STATUS_SUPREMUM 3
|
|
39 |
||
40 |
/* The following four constants are needed in page0zip.c in order to
|
|
41 |
efficiently compress and decompress pages. */
|
|
42 |
||
43 |
/* The offset of heap_no in a compact record */
|
|
44 |
#define REC_NEW_HEAP_NO 4
|
|
45 |
/* The shift of heap_no in a compact record.
|
|
46 |
The status is stored in the low-order bits. */
|
|
47 |
#define REC_HEAP_NO_SHIFT 3
|
|
48 |
||
49 |
/* Length of a B-tree node pointer, in bytes */
|
|
50 |
#define REC_NODE_PTR_SIZE 4
|
|
51 |
||
52 |
#ifdef UNIV_DEBUG
|
|
53 |
/* Length of the rec_get_offsets() header */
|
|
54 |
# define REC_OFFS_HEADER_SIZE 4
|
|
55 |
#else /* UNIV_DEBUG */ |
|
56 |
/* Length of the rec_get_offsets() header */
|
|
57 |
# define REC_OFFS_HEADER_SIZE 2
|
|
58 |
#endif /* UNIV_DEBUG */ |
|
59 |
||
60 |
/* Number of elements that should be initially allocated for the
|
|
61 |
offsets[] array, first passed to rec_get_offsets() */
|
|
62 |
#define REC_OFFS_NORMAL_SIZE 100
|
|
63 |
#define REC_OFFS_SMALL_SIZE 10
|
|
64 |
||
65 |
/**********************************************************
|
|
66 |
The following function is used to get the pointer of the next chained record
|
|
67 |
on the same page. */
|
|
68 |
UNIV_INLINE
|
|
69 |
const rec_t* |
|
70 |
rec_get_next_ptr_const( |
|
71 |
/*===================*/
|
|
72 |
/* out: pointer to the next chained record, or
|
|
73 |
NULL if none */
|
|
74 |
const rec_t* rec, /* in: physical record */ |
|
75 |
ulint comp); /* in: nonzero=compact page format */ |
|
76 |
/**********************************************************
|
|
77 |
The following function is used to get the pointer of the next chained record
|
|
78 |
on the same page. */
|
|
79 |
UNIV_INLINE
|
|
80 |
rec_t* |
|
81 |
rec_get_next_ptr( |
|
82 |
/*=============*/
|
|
83 |
/* out: pointer to the next chained record, or
|
|
84 |
NULL if none */
|
|
85 |
rec_t* rec, /* in: physical record */ |
|
86 |
ulint comp); /* in: nonzero=compact page format */ |
|
87 |
/**********************************************************
|
|
88 |
The following function is used to get the offset of the
|
|
89 |
next chained record on the same page. */
|
|
90 |
UNIV_INLINE
|
|
91 |
ulint
|
|
92 |
rec_get_next_offs( |
|
93 |
/*==============*/
|
|
94 |
/* out: the page offset of the next
|
|
95 |
chained record, or 0 if none */
|
|
96 |
const rec_t* rec, /* in: physical record */ |
|
97 |
ulint comp); /* in: nonzero=compact page format */ |
|
98 |
/**********************************************************
|
|
99 |
The following function is used to set the next record offset field
|
|
100 |
of an old-style record. */
|
|
101 |
UNIV_INLINE
|
|
102 |
void
|
|
103 |
rec_set_next_offs_old( |
|
104 |
/*==================*/
|
|
105 |
rec_t* rec, /* in: old-style physical record */ |
|
106 |
ulint next); /* in: offset of the next record */ |
|
107 |
/**********************************************************
|
|
108 |
The following function is used to set the next record offset field
|
|
109 |
of a new-style record. */
|
|
110 |
UNIV_INLINE
|
|
111 |
void
|
|
112 |
rec_set_next_offs_new( |
|
113 |
/*==================*/
|
|
114 |
rec_t* rec, /* in/out: new-style physical record */ |
|
115 |
ulint next); /* in: offset of the next record */ |
|
116 |
/**********************************************************
|
|
117 |
The following function is used to get the number of fields
|
|
118 |
in an old-style record. */
|
|
119 |
UNIV_INLINE
|
|
120 |
ulint
|
|
121 |
rec_get_n_fields_old( |
|
122 |
/*=================*/
|
|
123 |
/* out: number of data fields */
|
|
124 |
const rec_t* rec); /* in: physical record */ |
|
125 |
/**********************************************************
|
|
126 |
The following function is used to get the number of fields
|
|
127 |
in a record. */
|
|
128 |
UNIV_INLINE
|
|
129 |
ulint
|
|
130 |
rec_get_n_fields( |
|
131 |
/*=============*/
|
|
132 |
/* out: number of data fields */
|
|
133 |
const rec_t* rec, /* in: physical record */ |
|
134 |
const dict_index_t* index); /* in: record descriptor */ |
|
135 |
/**********************************************************
|
|
136 |
The following function is used to get the number of records owned by the
|
|
137 |
previous directory record. */
|
|
138 |
UNIV_INLINE
|
|
139 |
ulint
|
|
140 |
rec_get_n_owned_old( |
|
141 |
/*================*/
|
|
142 |
/* out: number of owned records */
|
|
143 |
const rec_t* rec); /* in: old-style physical record */ |
|
144 |
/**********************************************************
|
|
145 |
The following function is used to set the number of owned records. */
|
|
146 |
UNIV_INLINE
|
|
147 |
void
|
|
148 |
rec_set_n_owned_old( |
|
149 |
/*================*/
|
|
150 |
/* out: TRUE on success */
|
|
151 |
rec_t* rec, /* in: old-style physical record */ |
|
152 |
ulint n_owned); /* in: the number of owned */ |
|
153 |
/**********************************************************
|
|
154 |
The following function is used to get the number of records owned by the
|
|
155 |
previous directory record. */
|
|
156 |
UNIV_INLINE
|
|
157 |
ulint
|
|
158 |
rec_get_n_owned_new( |
|
159 |
/*================*/
|
|
160 |
/* out: number of owned records */
|
|
161 |
const rec_t* rec); /* in: new-style physical record */ |
|
162 |
/**********************************************************
|
|
163 |
The following function is used to set the number of owned records. */
|
|
164 |
UNIV_INLINE
|
|
165 |
void
|
|
166 |
rec_set_n_owned_new( |
|
167 |
/*================*/
|
|
168 |
rec_t* rec, /* in/out: new-style physical record */ |
|
169 |
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ |
|
170 |
ulint n_owned);/* in: the number of owned */ |
|
171 |
/**********************************************************
|
|
172 |
The following function is used to retrieve the info bits of
|
|
173 |
a record. */
|
|
174 |
UNIV_INLINE
|
|
175 |
ulint
|
|
176 |
rec_get_info_bits( |
|
177 |
/*==============*/
|
|
178 |
/* out: info bits */
|
|
179 |
const rec_t* rec, /* in: physical record */ |
|
180 |
ulint comp); /* in: nonzero=compact page format */ |
|
181 |
/**********************************************************
|
|
182 |
The following function is used to set the info bits of a record. */
|
|
183 |
UNIV_INLINE
|
|
184 |
void
|
|
185 |
rec_set_info_bits_old( |
|
186 |
/*==================*/
|
|
187 |
rec_t* rec, /* in: old-style physical record */ |
|
188 |
ulint bits); /* in: info bits */ |
|
189 |
/**********************************************************
|
|
190 |
The following function is used to set the info bits of a record. */
|
|
191 |
UNIV_INLINE
|
|
192 |
void
|
|
193 |
rec_set_info_bits_new( |
|
194 |
/*==================*/
|
|
195 |
rec_t* rec, /* in/out: new-style physical record */ |
|
196 |
ulint bits); /* in: info bits */ |
|
197 |
/**********************************************************
|
|
198 |
The following function retrieves the status bits of a new-style record. */
|
|
199 |
UNIV_INLINE
|
|
200 |
ulint
|
|
201 |
rec_get_status( |
|
202 |
/*===========*/
|
|
203 |
/* out: status bits */
|
|
204 |
const rec_t* rec); /* in: physical record */ |
|
205 |
||
206 |
/**********************************************************
|
|
207 |
The following function is used to set the status bits of a new-style record. */
|
|
208 |
UNIV_INLINE
|
|
209 |
void
|
|
210 |
rec_set_status( |
|
211 |
/*===========*/
|
|
212 |
rec_t* rec, /* in/out: physical record */ |
|
213 |
ulint bits); /* in: info bits */ |
|
214 |
||
215 |
/**********************************************************
|
|
216 |
The following function is used to retrieve the info and status
|
|
217 |
bits of a record. (Only compact records have status bits.) */
|
|
218 |
UNIV_INLINE
|
|
219 |
ulint
|
|
220 |
rec_get_info_and_status_bits( |
|
221 |
/*=========================*/
|
|
222 |
/* out: info bits */
|
|
223 |
const rec_t* rec, /* in: physical record */ |
|
224 |
ulint comp); /* in: nonzero=compact page format */ |
|
225 |
/**********************************************************
|
|
226 |
The following function is used to set the info and status
|
|
227 |
bits of a record. (Only compact records have status bits.) */
|
|
228 |
UNIV_INLINE
|
|
229 |
void
|
|
230 |
rec_set_info_and_status_bits( |
|
231 |
/*=========================*/
|
|
232 |
rec_t* rec, /* in/out: compact physical record */ |
|
233 |
ulint bits); /* in: info bits */ |
|
234 |
||
235 |
/**********************************************************
|
|
236 |
The following function tells if record is delete marked. */
|
|
237 |
UNIV_INLINE
|
|
238 |
ulint
|
|
239 |
rec_get_deleted_flag( |
|
240 |
/*=================*/
|
|
241 |
/* out: nonzero if delete marked */
|
|
242 |
const rec_t* rec, /* in: physical record */ |
|
243 |
ulint comp); /* in: nonzero=compact page format */ |
|
244 |
/**********************************************************
|
|
245 |
The following function is used to set the deleted bit. */
|
|
246 |
UNIV_INLINE
|
|
247 |
void
|
|
248 |
rec_set_deleted_flag_old( |
|
249 |
/*=====================*/
|
|
250 |
rec_t* rec, /* in: old-style physical record */ |
|
251 |
ulint flag); /* in: nonzero if delete marked */ |
|
252 |
/**********************************************************
|
|
253 |
The following function is used to set the deleted bit. */
|
|
254 |
UNIV_INLINE
|
|
255 |
void
|
|
256 |
rec_set_deleted_flag_new( |
|
257 |
/*=====================*/
|
|
258 |
rec_t* rec, /* in/out: new-style physical record */ |
|
259 |
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ |
|
260 |
ulint flag); /* in: nonzero if delete marked */ |
|
261 |
/**********************************************************
|
|
262 |
The following function tells if a new-style record is a node pointer. */
|
|
263 |
UNIV_INLINE
|
|
264 |
ibool
|
|
265 |
rec_get_node_ptr_flag( |
|
266 |
/*==================*/
|
|
267 |
/* out: TRUE if node pointer */
|
|
268 |
const rec_t* rec); /* in: physical record */ |
|
269 |
/**********************************************************
|
|
270 |
The following function is used to get the order number
|
|
271 |
of an old-style record in the heap of the index page. */
|
|
272 |
UNIV_INLINE
|
|
273 |
ulint
|
|
274 |
rec_get_heap_no_old( |
|
275 |
/*================*/
|
|
276 |
/* out: heap order number */
|
|
277 |
const rec_t* rec); /* in: physical record */ |
|
278 |
/**********************************************************
|
|
279 |
The following function is used to set the heap number
|
|
280 |
field in an old-style record. */
|
|
281 |
UNIV_INLINE
|
|
282 |
void
|
|
283 |
rec_set_heap_no_old( |
|
284 |
/*================*/
|
|
285 |
rec_t* rec, /* in: physical record */ |
|
286 |
ulint heap_no);/* in: the heap number */ |
|
287 |
/**********************************************************
|
|
288 |
The following function is used to get the order number
|
|
289 |
of a new-style record in the heap of the index page. */
|
|
290 |
UNIV_INLINE
|
|
291 |
ulint
|
|
292 |
rec_get_heap_no_new( |
|
293 |
/*================*/
|
|
294 |
/* out: heap order number */
|
|
295 |
const rec_t* rec); /* in: physical record */ |
|
296 |
/**********************************************************
|
|
297 |
The following function is used to set the heap number
|
|
298 |
field in a new-style record. */
|
|
299 |
UNIV_INLINE
|
|
300 |
void
|
|
301 |
rec_set_heap_no_new( |
|
302 |
/*================*/
|
|
303 |
rec_t* rec, /* in/out: physical record */ |
|
304 |
ulint heap_no);/* in: the heap number */ |
|
305 |
/**********************************************************
|
|
306 |
The following function is used to test whether the data offsets
|
|
307 |
in the record are stored in one-byte or two-byte format. */
|
|
308 |
UNIV_INLINE
|
|
309 |
ibool
|
|
310 |
rec_get_1byte_offs_flag( |
|
311 |
/*====================*/
|
|
312 |
/* out: TRUE if 1-byte form */
|
|
313 |
const rec_t* rec); /* in: physical record */ |
|
314 |
||
315 |
/**********************************************************
|
|
316 |
Determine how many of the first n columns in a compact
|
|
317 |
physical record are stored externally. */
|
|
318 |
UNIV_INTERN
|
|
319 |
ulint
|
|
320 |
rec_get_n_extern_new( |
|
321 |
/*=================*/
|
|
322 |
/* out: number of externally stored columns */
|
|
323 |
const rec_t* rec, /* in: compact physical record */ |
|
324 |
dict_index_t* index, /* in: record descriptor */ |
|
325 |
ulint n); /* in: number of columns to scan */ |
|
326 |
||
327 |
/**********************************************************
|
|
328 |
The following function determines the offsets to each field
|
|
329 |
in the record. It can reuse a previously allocated array. */
|
|
330 |
UNIV_INTERN
|
|
331 |
ulint* |
|
332 |
rec_get_offsets_func( |
|
333 |
/*=================*/
|
|
334 |
/* out: the new offsets */
|
|
335 |
const rec_t* rec, /* in: physical record */ |
|
336 |
const dict_index_t* index, /* in: record descriptor */ |
|
337 |
ulint* offsets,/* in/out: array consisting of |
|
338 |
offsets[0] allocated elements,
|
|
339 |
or an array from rec_get_offsets(),
|
|
340 |
or NULL */
|
|
341 |
ulint n_fields,/* in: maximum number of |
|
342 |
initialized fields
|
|
343 |
(ULINT_UNDEFINED if all fields) */
|
|
344 |
mem_heap_t** heap, /* in/out: memory heap */ |
|
345 |
const char* file, /* in: file name where called */ |
|
346 |
ulint line); /* in: line number where called */ |
|
347 |
||
348 |
#define rec_get_offsets(rec,index,offsets,n,heap) \
|
|
349 |
rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
|
|
350 |
||
351 |
/**********************************************************
|
|
352 |
Determine the offset to each field in a leaf-page record
|
|
353 |
in ROW_FORMAT=COMPACT. This is a special case of
|
|
354 |
rec_init_offsets() and rec_get_offsets_func(). */
|
|
355 |
UNIV_INTERN
|
|
356 |
void
|
|
357 |
rec_init_offsets_comp_ordinary( |
|
358 |
/*===========================*/
|
|
359 |
const rec_t* rec, /* in: physical record in |
|
360 |
ROW_FORMAT=COMPACT */
|
|
361 |
ulint extra, /* in: number of bytes to reserve |
|
362 |
between the record header and
|
|
363 |
the data payload
|
|
364 |
(usually REC_N_NEW_EXTRA_BYTES) */
|
|
365 |
const dict_index_t* index, /* in: record descriptor */ |
|
366 |
ulint* offsets);/* in/out: array of offsets; |
|
367 |
in: n=rec_offs_n_fields(offsets) */
|
|
368 |
||
369 |
/**********************************************************
|
|
370 |
The following function determines the offsets to each field
|
|
371 |
in the record. It can reuse a previously allocated array. */
|
|
372 |
UNIV_INTERN
|
|
373 |
void
|
|
374 |
rec_get_offsets_reverse( |
|
375 |
/*====================*/
|
|
376 |
const byte* extra, /* in: the extra bytes of a |
|
377 |
compact record in reverse order,
|
|
378 |
excluding the fixed-size
|
|
379 |
REC_N_NEW_EXTRA_BYTES */
|
|
380 |
const dict_index_t* index, /* in: record descriptor */ |
|
381 |
ulint node_ptr,/* in: nonzero=node pointer, |
|
382 |
0=leaf node */
|
|
383 |
ulint* offsets);/* in/out: array consisting of |
|
384 |
offsets[0] allocated elements */
|
|
385 |
||
386 |
/****************************************************************
|
|
387 |
Validates offsets returned by rec_get_offsets(). */
|
|
388 |
UNIV_INLINE
|
|
389 |
ibool
|
|
390 |
rec_offs_validate( |
|
391 |
/*==============*/
|
|
392 |
/* out: TRUE if valid */
|
|
393 |
const rec_t* rec, /* in: record or NULL */ |
|
394 |
const dict_index_t* index, /* in: record descriptor or NULL */ |
|
395 |
const ulint* offsets);/* in: array returned by |
|
396 |
rec_get_offsets() */
|
|
397 |
#ifdef UNIV_DEBUG
|
|
398 |
/****************************************************************
|
|
399 |
Updates debug data in offsets, in order to avoid bogus
|
|
400 |
rec_offs_validate() failures. */
|
|
401 |
UNIV_INLINE
|
|
402 |
void
|
|
403 |
rec_offs_make_valid( |
|
404 |
/*================*/
|
|
405 |
const rec_t* rec, /* in: record */ |
|
406 |
const dict_index_t* index, /* in: record descriptor */ |
|
407 |
ulint* offsets);/* in: array returned by |
|
408 |
rec_get_offsets() */
|
|
409 |
#else
|
|
410 |
# define rec_offs_make_valid(rec, index, offsets) ((void) 0)
|
|
411 |
#endif /* UNIV_DEBUG */ |
|
412 |
||
413 |
/****************************************************************
|
|
414 |
The following function is used to get the offset to the nth
|
|
415 |
data field in an old-style record. */
|
|
416 |
UNIV_INTERN
|
|
417 |
ulint
|
|
418 |
rec_get_nth_field_offs_old( |
|
419 |
/*=======================*/
|
|
420 |
/* out: offset to the field */
|
|
421 |
const rec_t* rec, /* in: record */ |
|
422 |
ulint n, /* in: index of the field */ |
|
423 |
ulint* len); /* out: length of the field; UNIV_SQL_NULL |
|
424 |
if SQL null */
|
|
425 |
#define rec_get_nth_field_old(rec, n, len) \
|
|
426 |
((rec) + rec_get_nth_field_offs_old(rec, n, len))
|
|
427 |
/****************************************************************
|
|
428 |
Gets the physical size of an old-style field.
|
|
429 |
Also an SQL null may have a field of size > 0,
|
|
430 |
if the data type is of a fixed size. */
|
|
431 |
UNIV_INLINE
|
|
432 |
ulint
|
|
433 |
rec_get_nth_field_size( |
|
434 |
/*===================*/
|
|
435 |
/* out: field size in bytes */
|
|
436 |
const rec_t* rec, /* in: record */ |
|
437 |
ulint n); /* in: index of the field */ |
|
438 |
/****************************************************************
|
|
439 |
The following function is used to get an offset to the nth
|
|
440 |
data field in a record. */
|
|
441 |
UNIV_INLINE
|
|
442 |
ulint
|
|
443 |
rec_get_nth_field_offs( |
|
444 |
/*===================*/
|
|
445 |
/* out: offset from the origin of rec */
|
|
446 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
447 |
ulint n, /* in: index of the field */ |
|
448 |
ulint* len); /* out: length of the field; UNIV_SQL_NULL |
|
449 |
if SQL null */
|
|
450 |
#define rec_get_nth_field(rec, offsets, n, len) \
|
|
451 |
((rec) + rec_get_nth_field_offs(offsets, n, len))
|
|
452 |
/**********************************************************
|
|
453 |
Determine if the offsets are for a record in the new
|
|
454 |
compact format. */
|
|
455 |
UNIV_INLINE
|
|
456 |
ulint
|
|
457 |
rec_offs_comp( |
|
458 |
/*==========*/
|
|
459 |
/* out: nonzero if compact format */
|
|
460 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
461 |
/**********************************************************
|
|
462 |
Determine if the offsets are for a record containing
|
|
463 |
externally stored columns. */
|
|
464 |
UNIV_INLINE
|
|
465 |
ulint
|
|
466 |
rec_offs_any_extern( |
|
467 |
/*================*/
|
|
468 |
/* out: nonzero if externally stored */
|
|
469 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
470 |
/**********************************************************
|
|
471 |
Returns nonzero if the extern bit is set in nth field of rec. */
|
|
472 |
UNIV_INLINE
|
|
473 |
ulint
|
|
474 |
rec_offs_nth_extern( |
|
475 |
/*================*/
|
|
476 |
/* out: nonzero if externally stored */
|
|
477 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
478 |
ulint n); /* in: nth field */ |
|
479 |
/**********************************************************
|
|
480 |
Returns nonzero if the SQL NULL bit is set in nth field of rec. */
|
|
481 |
UNIV_INLINE
|
|
482 |
ulint
|
|
483 |
rec_offs_nth_sql_null( |
|
484 |
/*==================*/
|
|
485 |
/* out: nonzero if SQL NULL */
|
|
486 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
487 |
ulint n); /* in: nth field */ |
|
488 |
/**********************************************************
|
|
489 |
Gets the physical size of a field. */
|
|
490 |
UNIV_INLINE
|
|
491 |
ulint
|
|
492 |
rec_offs_nth_size( |
|
493 |
/*==============*/
|
|
494 |
/* out: length of field */
|
|
495 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
496 |
ulint n); /* in: nth field */ |
|
497 |
||
498 |
/**********************************************************
|
|
499 |
Returns the number of extern bits set in a record. */
|
|
500 |
UNIV_INLINE
|
|
501 |
ulint
|
|
502 |
rec_offs_n_extern( |
|
503 |
/*==============*/
|
|
504 |
/* out: number of externally stored fields */
|
|
505 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
506 |
/***************************************************************
|
|
507 |
This is used to modify the value of an already existing field in a record.
|
|
508 |
The previous value must have exactly the same size as the new value. If len
|
|
509 |
is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
|
|
510 |
records. For new-style records, len must not be UNIV_SQL_NULL. */
|
|
511 |
UNIV_INLINE
|
|
512 |
void
|
|
513 |
rec_set_nth_field( |
|
514 |
/*==============*/
|
|
515 |
rec_t* rec, /* in: record */ |
|
516 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
517 |
ulint n, /* in: index number of the field */ |
|
518 |
const void* data, /* in: pointer to the data if not SQL null */ |
|
519 |
ulint len); /* in: length of the data or UNIV_SQL_NULL. |
|
520 |
If not SQL null, must have the same
|
|
521 |
length as the previous value.
|
|
522 |
If SQL null, previous value must be
|
|
523 |
SQL null. */
|
|
524 |
/**************************************************************
|
|
525 |
The following function returns the data size of an old-style physical
|
|
526 |
record, that is the sum of field lengths. SQL null fields
|
|
527 |
are counted as length 0 fields. The value returned by the function
|
|
528 |
is the distance from record origin to record end in bytes. */
|
|
529 |
UNIV_INLINE
|
|
530 |
ulint
|
|
531 |
rec_get_data_size_old( |
|
532 |
/*==================*/
|
|
533 |
/* out: size */
|
|
534 |
const rec_t* rec); /* in: physical record */ |
|
535 |
/**************************************************************
|
|
536 |
The following function returns the number of allocated elements
|
|
537 |
for an array of offsets. */
|
|
538 |
UNIV_INLINE
|
|
539 |
ulint
|
|
540 |
rec_offs_get_n_alloc( |
|
541 |
/*=================*/
|
|
542 |
/* out: number of elements */
|
|
543 |
const ulint* offsets);/* in: array for rec_get_offsets() */ |
|
544 |
/**************************************************************
|
|
545 |
The following function sets the number of allocated elements
|
|
546 |
for an array of offsets. */
|
|
547 |
UNIV_INLINE
|
|
548 |
void
|
|
549 |
rec_offs_set_n_alloc( |
|
550 |
/*=================*/
|
|
551 |
ulint* offsets, /* out: array for rec_get_offsets(), |
|
552 |
must be allocated */
|
|
553 |
ulint n_alloc); /* in: number of elements */ |
|
554 |
#define rec_offs_init(offsets) \
|
|
555 |
rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
|
|
556 |
/**************************************************************
|
|
557 |
The following function returns the number of fields in a record. */
|
|
558 |
UNIV_INLINE
|
|
559 |
ulint
|
|
560 |
rec_offs_n_fields( |
|
561 |
/*==============*/
|
|
562 |
/* out: number of fields */
|
|
563 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
564 |
/**************************************************************
|
|
565 |
The following function returns the data size of a physical
|
|
566 |
record, that is the sum of field lengths. SQL null fields
|
|
567 |
are counted as length 0 fields. The value returned by the function
|
|
568 |
is the distance from record origin to record end in bytes. */
|
|
569 |
UNIV_INLINE
|
|
570 |
ulint
|
|
571 |
rec_offs_data_size( |
|
572 |
/*===============*/
|
|
573 |
/* out: size */
|
|
574 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
575 |
/**************************************************************
|
|
576 |
Returns the total size of record minus data size of record.
|
|
577 |
The value returned by the function is the distance from record
|
|
578 |
start to record origin in bytes. */
|
|
579 |
UNIV_INLINE
|
|
580 |
ulint
|
|
581 |
rec_offs_extra_size( |
|
582 |
/*================*/
|
|
583 |
/* out: size */
|
|
584 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
585 |
/**************************************************************
|
|
586 |
Returns the total size of a physical record. */
|
|
587 |
UNIV_INLINE
|
|
588 |
ulint
|
|
589 |
rec_offs_size( |
|
590 |
/*==========*/
|
|
591 |
/* out: size */
|
|
592 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
593 |
/**************************************************************
|
|
594 |
Returns a pointer to the start of the record. */
|
|
595 |
UNIV_INLINE
|
|
596 |
byte* |
|
597 |
rec_get_start( |
|
598 |
/*==========*/
|
|
599 |
/* out: pointer to start */
|
|
600 |
rec_t* rec, /* in: pointer to record */ |
|
601 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
602 |
/**************************************************************
|
|
603 |
Returns a pointer to the end of the record. */
|
|
604 |
UNIV_INLINE
|
|
605 |
byte* |
|
606 |
rec_get_end( |
|
607 |
/*========*/
|
|
608 |
/* out: pointer to end */
|
|
609 |
rec_t* rec, /* in: pointer to record */ |
|
610 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
611 |
/*******************************************************************
|
|
612 |
Copies a physical record to a buffer. */
|
|
613 |
UNIV_INLINE
|
|
614 |
rec_t* |
|
615 |
rec_copy( |
|
616 |
/*=====*/
|
|
617 |
/* out: pointer to the origin of the copy */
|
|
618 |
void* buf, /* in: buffer */ |
|
619 |
const rec_t* rec, /* in: physical record */ |
|
620 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
621 |
/******************************************************************
|
|
622 |
Copies the first n fields of a physical record to a new physical record in
|
|
623 |
a buffer. */
|
|
624 |
UNIV_INTERN
|
|
625 |
rec_t* |
|
626 |
rec_copy_prefix_to_buf( |
|
627 |
/*===================*/
|
|
628 |
/* out, own: copied record */
|
|
629 |
const rec_t* rec, /* in: physical record */ |
|
630 |
const dict_index_t* index, /* in: record descriptor */ |
|
631 |
ulint n_fields, /* in: number of fields |
|
632 |
to copy */
|
|
633 |
byte** buf, /* in/out: memory buffer |
|
634 |
for the copied prefix,
|
|
635 |
or NULL */
|
|
636 |
ulint* buf_size); /* in/out: buffer size */ |
|
637 |
/****************************************************************
|
|
638 |
Folds a prefix of a physical record to a ulint. */
|
|
639 |
UNIV_INLINE
|
|
640 |
ulint
|
|
641 |
rec_fold( |
|
642 |
/*=====*/
|
|
643 |
/* out: the folded value */
|
|
644 |
const rec_t* rec, /* in: the physical record */ |
|
645 |
const ulint* offsets, /* in: array returned by |
|
646 |
rec_get_offsets() */
|
|
647 |
ulint n_fields, /* in: number of complete |
|
648 |
fields to fold */
|
|
649 |
ulint n_bytes, /* in: number of bytes to fold |
|
650 |
in an incomplete last field */
|
|
651 |
dulint tree_id) /* in: index tree id */ |
|
652 |
__attribute__((pure)); |
|
653 |
/*************************************************************
|
|
654 |
Builds a ROW_FORMAT=COMPACT record out of a data tuple. */
|
|
655 |
UNIV_INTERN
|
|
656 |
void
|
|
657 |
rec_convert_dtuple_to_rec_comp( |
|
658 |
/*===========================*/
|
|
659 |
rec_t* rec, /* in: origin of record */ |
|
660 |
ulint extra, /* in: number of bytes to |
|
661 |
reserve between the record
|
|
662 |
header and the data payload
|
|
663 |
(normally REC_N_NEW_EXTRA_BYTES) */
|
|
664 |
const dict_index_t* index, /* in: record descriptor */ |
|
665 |
ulint status, /* in: status bits of the record */ |
|
666 |
const dfield_t* fields, /* in: array of data fields */ |
|
667 |
ulint n_fields);/* in: number of data fields */ |
|
668 |
/*************************************************************
|
|
669 |
Builds a physical record out of a data tuple and
|
|
670 |
stores it into the given buffer. */
|
|
671 |
UNIV_INTERN
|
|
672 |
rec_t* |
|
673 |
rec_convert_dtuple_to_rec( |
|
674 |
/*======================*/
|
|
675 |
/* out: pointer to the origin
|
|
676 |
of physical record */
|
|
677 |
byte* buf, /* in: start address of the |
|
678 |
physical record */
|
|
679 |
const dict_index_t* index, /* in: record descriptor */ |
|
680 |
const dtuple_t* dtuple, /* in: data tuple */ |
|
681 |
ulint n_ext); /* in: number of |
|
682 |
externally stored columns */
|
|
683 |
/**************************************************************
|
|
684 |
Returns the extra size of an old-style physical record if we know its
|
|
685 |
data size and number of fields. */
|
|
686 |
UNIV_INLINE
|
|
687 |
ulint
|
|
688 |
rec_get_converted_extra_size( |
|
689 |
/*=========================*/
|
|
690 |
/* out: extra size */
|
|
691 |
ulint data_size, /* in: data size */ |
|
692 |
ulint n_fields, /* in: number of fields */ |
|
693 |
ulint n_ext) /* in: number of externally stored columns */ |
|
641.1.4
by Monty Taylor
Merged in InnoDB changes. |
694 |
__attribute__((__const__)); |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
695 |
/**************************************************************
|
641.2.1
by Monty Taylor
InnoDB Plugin 1.0.2 |
696 |
Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. */
|
697 |
UNIV_INTERN
|
|
698 |
ulint
|
|
699 |
rec_get_converted_size_comp_prefix( |
|
700 |
/*===============================*/
|
|
701 |
/* out: total size */
|
|
702 |
const dict_index_t* index, /* in: record descriptor; |
|
703 |
dict_table_is_comp() is
|
|
704 |
assumed to hold, even if
|
|
705 |
it does not */
|
|
706 |
const dfield_t* fields, /* in: array of data fields */ |
|
707 |
ulint n_fields,/* in: number of data fields */ |
|
708 |
ulint* extra); /* out: extra size */ |
|
709 |
/**************************************************************
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
710 |
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
|
711 |
UNIV_INTERN
|
|
712 |
ulint
|
|
713 |
rec_get_converted_size_comp( |
|
714 |
/*========================*/
|
|
715 |
/* out: total size */
|
|
716 |
const dict_index_t* index, /* in: record descriptor; |
|
717 |
dict_table_is_comp() is
|
|
718 |
assumed to hold, even if
|
|
719 |
it does not */
|
|
720 |
ulint status, /* in: status bits of the record */ |
|
721 |
const dfield_t* fields, /* in: array of data fields */ |
|
722 |
ulint n_fields,/* in: number of data fields */ |
|
723 |
ulint* extra); /* out: extra size */ |
|
724 |
/**************************************************************
|
|
725 |
The following function returns the size of a data tuple when converted to
|
|
726 |
a physical record. */
|
|
727 |
UNIV_INLINE
|
|
728 |
ulint
|
|
729 |
rec_get_converted_size( |
|
730 |
/*===================*/
|
|
731 |
/* out: size */
|
|
732 |
dict_index_t* index, /* in: record descriptor */ |
|
733 |
const dtuple_t* dtuple, /* in: data tuple */ |
|
734 |
ulint n_ext); /* in: number of externally stored columns */ |
|
735 |
/******************************************************************
|
|
736 |
Copies the first n fields of a physical record to a data tuple.
|
|
737 |
The fields are copied to the memory heap. */
|
|
738 |
UNIV_INTERN
|
|
739 |
void
|
|
740 |
rec_copy_prefix_to_dtuple( |
|
741 |
/*======================*/
|
|
742 |
dtuple_t* tuple, /* out: data tuple */ |
|
743 |
const rec_t* rec, /* in: physical record */ |
|
744 |
const dict_index_t* index, /* in: record descriptor */ |
|
745 |
ulint n_fields, /* in: number of fields |
|
746 |
to copy */
|
|
747 |
mem_heap_t* heap); /* in: memory heap */ |
|
748 |
/*******************************************************************
|
|
749 |
Validates the consistency of a physical record. */
|
|
750 |
UNIV_INTERN
|
|
751 |
ibool
|
|
752 |
rec_validate( |
|
753 |
/*=========*/
|
|
754 |
/* out: TRUE if ok */
|
|
755 |
const rec_t* rec, /* in: physical record */ |
|
756 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
757 |
/*******************************************************************
|
|
758 |
Prints an old-style physical record. */
|
|
759 |
UNIV_INTERN
|
|
760 |
void
|
|
761 |
rec_print_old( |
|
762 |
/*==========*/
|
|
763 |
FILE* file, /* in: file where to print */ |
|
764 |
const rec_t* rec); /* in: physical record */ |
|
765 |
/*******************************************************************
|
|
766 |
Prints a physical record in ROW_FORMAT=COMPACT. Ignores the
|
|
767 |
record header. */
|
|
768 |
UNIV_INTERN
|
|
769 |
void
|
|
770 |
rec_print_comp( |
|
771 |
/*===========*/
|
|
772 |
FILE* file, /* in: file where to print */ |
|
773 |
const rec_t* rec, /* in: physical record */ |
|
774 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
775 |
/*******************************************************************
|
|
776 |
Prints a physical record. */
|
|
777 |
UNIV_INTERN
|
|
778 |
void
|
|
779 |
rec_print_new( |
|
780 |
/*==========*/
|
|
781 |
FILE* file, /* in: file where to print */ |
|
782 |
const rec_t* rec, /* in: physical record */ |
|
783 |
const ulint* offsets);/* in: array returned by rec_get_offsets() */ |
|
784 |
/*******************************************************************
|
|
785 |
Prints a physical record. */
|
|
786 |
UNIV_INTERN
|
|
787 |
void
|
|
788 |
rec_print( |
|
789 |
/*======*/
|
|
790 |
FILE* file, /* in: file where to print */ |
|
791 |
const rec_t* rec, /* in: physical record */ |
|
792 |
dict_index_t* index); /* in: record descriptor */ |
|
793 |
||
794 |
#define REC_INFO_BITS 6 /* This is single byte bit-field */ |
|
795 |
||
796 |
/* Maximum lengths for the data in a physical record if the offsets
|
|
797 |
are given in one byte (resp. two byte) format. */
|
|
798 |
#define REC_1BYTE_OFFS_LIMIT 0x7FUL
|
|
799 |
#define REC_2BYTE_OFFS_LIMIT 0x7FFFUL
|
|
800 |
||
801 |
/* The data size of record must be smaller than this because we reserve
|
|
802 |
two upmost bits in a two byte offset for special purposes */
|
|
803 |
#define REC_MAX_DATA_SIZE (16 * 1024)
|
|
804 |
||
805 |
#ifndef UNIV_NONINL
|
|
806 |
#include "rem0rec.ic" |
|
807 |
#endif
|
|
808 |
||
809 |
#endif
|