~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/rem0rec.h

  • Committer: Andy Lester
  • Date: 2008-08-10 02:15:48 UTC
  • mto: (266.1.31 use-replace-funcs)
  • mto: This revision was merged to the branch mainline in revision 295.
  • Revision ID: andy@petdance.com-20080810021548-0zx8nhzva6al10k3
Added a proper const qualifer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "data0data.h"
14
14
#include "rem0types.h"
15
15
#include "mtr0types.h"
16
 
#include "page0types.h"
17
16
 
18
17
/* Info bit denoting the predefined minimum record: this bit is set
19
18
if and only if the record is the first user record on a non-leaf
20
19
B-tree page that is the leftmost page on its level
21
20
(PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
22
21
#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
22
 
27
23
/* Number of extra bytes in an old-style record,
28
24
in addition to the data and the offsets */
37
33
#define REC_STATUS_INFIMUM      2
38
34
#define REC_STATUS_SUPREMUM     3
39
35
 
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
36
/* Number of elements that should be initially allocated for the
61
37
offsets[] array, first passed to rec_get_offsets() */
62
38
#define REC_OFFS_NORMAL_SIZE    100
63
39
#define REC_OFFS_SMALL_SIZE     10
64
40
 
65
41
/**********************************************************
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
42
The following function is used to get the offset of the
89
43
next chained record on the same page. */
90
44
UNIV_INLINE
91
45
ulint
92
46
rec_get_next_offs(
93
47
/*==============*/
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 */
 
48
                        /* out: the page offset of the next
 
49
                        chained record */
 
50
        rec_t*  rec,    /* in: physical record */
 
51
        ulint   comp);  /* in: nonzero=compact page format */
 
52
/**********************************************************
 
53
The following function is used to set the next record offset field
 
54
of the record. */
 
55
UNIV_INLINE
 
56
void
 
57
rec_set_next_offs(
 
58
/*==============*/
 
59
        rec_t*  rec,    /* in: physical record */
 
60
        ulint   comp,   /* in: nonzero=compact page format */
115
61
        ulint   next);  /* in: offset of the next record */
116
62
/**********************************************************
117
63
The following function is used to get the number of fields
120
66
ulint
121
67
rec_get_n_fields_old(
122
68
/*=================*/
123
 
                                /* out: number of data fields */
124
 
        const rec_t*    rec);   /* in: physical record */
 
69
                        /* out: number of data fields */
 
70
        rec_t*  rec);   /* in: physical record */
125
71
/**********************************************************
126
72
The following function is used to get the number of fields
127
73
in a record. */
129
75
ulint
130
76
rec_get_n_fields(
131
77
/*=============*/
132
 
                                        /* out: number of data fields */
133
 
        const rec_t*            rec,    /* in: physical record */
134
 
        const dict_index_t*     index); /* in: record descriptor */
 
78
                                /* out: number of data fields */
 
79
        rec_t*          rec,    /* in: physical record */
 
80
        dict_index_t*   index); /* in: record descriptor */
135
81
/**********************************************************
136
 
The following function is used to get the number of records owned by the
137
 
previous directory record. */
 
82
The following function is used to get the number of records
 
83
owned by the previous directory record. */
138
84
UNIV_INLINE
139
85
ulint
140
 
rec_get_n_owned_old(
141
 
/*================*/
142
 
                                /* out: number of owned records */
143
 
        const rec_t*    rec);   /* in: old-style physical record */
 
86
rec_get_n_owned(
 
87
/*============*/
 
88
                        /* out: number of owned records */
 
89
        rec_t*  rec,    /* in: physical record */
 
90
        ulint   comp);  /* in: nonzero=compact page format */
144
91
/**********************************************************
145
 
The following function is used to set the number of owned records. */
 
92
The following function is used to set the number of owned
 
93
records. */
146
94
UNIV_INLINE
147
95
void
148
 
rec_set_n_owned_old(
149
 
/*================*/
150
 
                                /* out: TRUE on success */
151
 
        rec_t*  rec,            /* in: old-style physical record */
 
96
rec_set_n_owned(
 
97
/*============*/
 
98
        rec_t*  rec,            /* in: physical record */
 
99
        ulint   comp,           /* in: nonzero=compact page format */
152
100
        ulint   n_owned);       /* in: the number of owned */
153
101
/**********************************************************
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
102
The following function is used to retrieve the info bits of
173
103
a record. */
174
104
UNIV_INLINE
175
105
ulint
176
106
rec_get_info_bits(
177
107
/*==============*/
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 */
 
108
                        /* out: info bits */
 
109
        rec_t*  rec,    /* in: physical record */
 
110
        ulint   comp);  /* in: nonzero=compact page format */
 
111
/**********************************************************
 
112
The following function is used to set the info bits of a record. */
 
113
UNIV_INLINE
 
114
void
 
115
rec_set_info_bits(
 
116
/*==============*/
 
117
        rec_t*  rec,    /* in: physical record */
 
118
        ulint   comp,   /* in: nonzero=compact page format */
196
119
        ulint   bits);  /* in: info bits */
197
120
/**********************************************************
198
121
The following function retrieves the status bits of a new-style record. */
200
123
ulint
201
124
rec_get_status(
202
125
/*===========*/
203
 
                                /* out: status bits */
204
 
        const rec_t*    rec);   /* in: physical record */
 
126
                        /* out: status bits */
 
127
        rec_t*  rec);   /* in: physical record */
205
128
 
206
129
/**********************************************************
207
130
The following function is used to set the status bits of a new-style record. */
209
132
void
210
133
rec_set_status(
211
134
/*===========*/
212
 
        rec_t*  rec,    /* in/out: physical record */
 
135
        rec_t*  rec,    /* in: physical record */
213
136
        ulint   bits);  /* in: info bits */
214
137
 
215
138
/**********************************************************
219
142
ulint
220
143
rec_get_info_and_status_bits(
221
144
/*=========================*/
222
 
                                /* out: info bits */
223
 
        const rec_t*    rec,    /* in: physical record */
224
 
        ulint           comp);  /* in: nonzero=compact page format */
 
145
                        /* out: info bits */
 
146
        rec_t*  rec,    /* in: physical record */
 
147
        ulint   comp);  /* in: nonzero=compact page format */
225
148
/**********************************************************
226
149
The following function is used to set the info and status
227
150
bits of a record.  (Only compact records have status bits.) */
229
152
void
230
153
rec_set_info_and_status_bits(
231
154
/*=========================*/
232
 
        rec_t*  rec,    /* in/out: compact physical record */
 
155
        rec_t*  rec,    /* in: physical record */
 
156
        ulint   comp,   /* in: nonzero=compact page format */
233
157
        ulint   bits);  /* in: info bits */
234
158
 
235
159
/**********************************************************
238
162
ulint
239
163
rec_get_deleted_flag(
240
164
/*=================*/
241
 
                                /* out: nonzero if delete marked */
242
 
        const rec_t*    rec,    /* in: physical record */
243
 
        ulint           comp);  /* in: nonzero=compact page format */
 
165
                        /* out: nonzero if delete marked */
 
166
        rec_t*  rec,    /* in: physical record */
 
167
        ulint   comp);  /* in: nonzero=compact page format */
244
168
/**********************************************************
245
169
The following function is used to set the deleted bit. */
246
170
UNIV_INLINE
247
171
void
248
 
rec_set_deleted_flag_old(
249
 
/*=====================*/
250
 
        rec_t*  rec,    /* in: old-style physical record */
 
172
rec_set_deleted_flag(
 
173
/*=================*/
 
174
        rec_t*  rec,    /* in: physical record */
 
175
        ulint   comp,   /* in: nonzero=compact page format */
251
176
        ulint   flag);  /* in: nonzero if delete marked */
252
177
/**********************************************************
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
178
The following function tells if a new-style record is a node pointer. */
263
179
UNIV_INLINE
264
180
ibool
265
181
rec_get_node_ptr_flag(
266
182
/*==================*/
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 */
 
183
                        /* out: TRUE if node pointer */
 
184
        rec_t*  rec);   /* in: physical record */
 
185
/**********************************************************
 
186
The following function is used to get the order number
 
187
of the record in the heap of the index page. */
 
188
UNIV_INLINE
 
189
ulint
 
190
rec_get_heap_no(
 
191
/*============*/
 
192
                        /* out: heap order number */
 
193
        rec_t*  rec,    /* in: physical record */
 
194
        ulint   comp);  /* in: nonzero=compact page format */
 
195
/**********************************************************
 
196
The following function is used to set the heap number
 
197
field in the record. */
 
198
UNIV_INLINE
 
199
void
 
200
rec_set_heap_no(
 
201
/*============*/
 
202
        rec_t*  rec,    /* in: physical record */
 
203
        ulint   comp,   /* in: nonzero=compact page format */
304
204
        ulint   heap_no);/* in: the heap number */
305
205
/**********************************************************
306
206
The following function is used to test whether the data offsets
309
209
ibool
310
210
rec_get_1byte_offs_flag(
311
211
/*====================*/
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
 
 
 
212
                        /* out: TRUE if 1-byte form */
 
213
        rec_t*  rec);   /* in: physical record */
327
214
/**********************************************************
328
215
The following function determines the offsets to each field
329
216
in the record.  It can reuse a previously allocated array. */
330
 
UNIV_INTERN
 
217
 
331
218
ulint*
332
219
rec_get_offsets_func(
333
220
/*=================*/
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 */
 
221
                                /* out: the new offsets */
 
222
        rec_t*          rec,    /* in: physical record */
 
223
        dict_index_t*   index,  /* in: record descriptor */
 
224
        ulint*          offsets,/* in: array consisting of offsets[0]
 
225
                                allocated elements, or an array from
 
226
                                rec_get_offsets(), or NULL */
 
227
        ulint           n_fields,/* in: maximum number of initialized fields
 
228
                                (ULINT_UNDEFINED if all fields) */
 
229
        mem_heap_t**    heap,   /* in/out: memory heap */
 
230
        const char*     file,   /* in: file name where called */
 
231
        ulint           line);  /* in: line number where called */
347
232
 
348
233
#define rec_get_offsets(rec,index,offsets,n,heap)       \
349
234
        rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
350
235
 
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
236
/****************************************************************
387
237
Validates offsets returned by rec_get_offsets(). */
388
238
UNIV_INLINE
389
239
ibool
390
240
rec_offs_validate(
391
241
/*==============*/
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
 
242
                                /* out: TRUE if valid */
 
243
        rec_t*          rec,    /* in: record or NULL */
 
244
        dict_index_t*   index,  /* in: record descriptor or NULL */
 
245
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
398
246
/****************************************************************
399
247
Updates debug data in offsets, in order to avoid bogus
400
248
rec_offs_validate() failures. */
402
250
void
403
251
rec_offs_make_valid(
404
252
/*================*/
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 */
 
253
        rec_t*          rec,    /* in: record */
 
254
        dict_index_t*   index,/* in: record descriptor */
 
255
        const ulint*            offsets);/* in: array returned by rec_get_offsets() */
412
256
 
413
257
/****************************************************************
414
 
The following function is used to get the offset to the nth
 
258
The following function is used to get a pointer to the nth
415
259
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))
 
260
 
 
261
byte*
 
262
rec_get_nth_field_old(
 
263
/*==================*/
 
264
                        /* out: pointer to the field */
 
265
        rec_t*  rec,    /* in: record */
 
266
        ulint   n,      /* in: index of the field */
 
267
        ulint*  len);   /* out: length of the field; UNIV_SQL_NULL
 
268
                        if SQL null */
427
269
/****************************************************************
428
270
Gets the physical size of an old-style field.
429
271
Also an SQL null may have a field of size > 0,
432
274
ulint
433
275
rec_get_nth_field_size(
434
276
/*===================*/
435
 
                                /* out: field size in bytes */
436
 
        const rec_t*    rec,    /* in: record */
437
 
        ulint           n);     /* in: index of the field */
 
277
                        /* out: field size in bytes */
 
278
        rec_t*  rec,    /* in: record */
 
279
        ulint   n);     /* in: index of the field */
438
280
/****************************************************************
439
 
The following function is used to get an offset to the nth
 
281
The following function is used to get a pointer to the nth
440
282
data field in a record. */
441
283
UNIV_INLINE
442
 
ulint
443
 
rec_get_nth_field_offs(
444
 
/*===================*/
445
 
                                /* out: offset from the origin of rec */
 
284
byte*
 
285
rec_get_nth_field(
 
286
/*==============*/
 
287
                                /* out: pointer to the field */
 
288
        rec_t*          rec,    /* in: record */
446
289
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
447
290
        ulint           n,      /* in: index of the field */
448
291
        ulint*          len);   /* out: length of the field; UNIV_SQL_NULL
449
292
                                if SQL null */
450
 
#define rec_get_nth_field(rec, offsets, n, len) \
451
 
((rec) + rec_get_nth_field_offs(offsets, n, len))
452
293
/**********************************************************
453
294
Determine if the offsets are for a record in the new
454
295
compact format. */
459
300
                                /* out: nonzero if compact format */
460
301
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
461
302
/**********************************************************
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
303
Returns nonzero if the extern bit is set in nth field of rec. */
472
304
UNIV_INLINE
473
305
ulint
496
328
        ulint           n);     /* in: nth field */
497
329
 
498
330
/**********************************************************
499
 
Returns the number of extern bits set in a record. */
 
331
Returns TRUE if the extern bit is set in any of the fields
 
332
of rec. */
500
333
UNIV_INLINE
501
 
ulint
502
 
rec_offs_n_extern(
503
 
/*==============*/
504
 
                                /* out: number of externally stored fields */
 
334
ibool
 
335
rec_offs_any_extern(
 
336
/*================*/
 
337
                                /* out: TRUE if a field is stored externally */
505
338
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
506
339
/***************************************************************
 
340
Sets the value of the ith field extern storage bit. */
 
341
UNIV_INLINE
 
342
void
 
343
rec_set_nth_field_extern_bit(
 
344
/*=========================*/
 
345
        rec_t*          rec,    /* in: record */
 
346
        dict_index_t*   index,  /* in: record descriptor */
 
347
        ulint           i,      /* in: ith field */
 
348
        ibool           val,    /* in: value to set */
 
349
        mtr_t*          mtr);   /* in: mtr holding an X-latch to the page
 
350
                                where rec is, or NULL; in the NULL case
 
351
                                we do not write to log about the change */
 
352
/***************************************************************
 
353
Sets TRUE the extern storage bits of fields mentioned in an array. */
 
354
 
 
355
void
 
356
rec_set_field_extern_bits(
 
357
/*======================*/
 
358
        rec_t*          rec,    /* in: record */
 
359
        dict_index_t*   index,  /* in: record descriptor */
 
360
        const ulint*    vec,    /* in: array of field numbers */
 
361
        ulint           n_fields,/* in: number of fields numbers */
 
362
        mtr_t*          mtr);   /* in: mtr holding an X-latch to the page
 
363
                                where rec is, or NULL; in the NULL case
 
364
                                we do not write to log about the change */
 
365
/***************************************************************
507
366
This is used to modify the value of an already existing field in a record.
508
367
The previous value must have exactly the same size as the new value. If len
509
368
is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
531
390
rec_get_data_size_old(
532
391
/*==================*/
533
392
                                /* 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)
 
393
        rec_t*  rec);   /* in: physical record */
556
394
/**************************************************************
557
395
The following function returns the number of fields in a record. */
558
396
UNIV_INLINE
621
459
/******************************************************************
622
460
Copies the first n fields of a physical record to a new physical record in
623
461
a buffer. */
624
 
UNIV_INTERN
 
462
 
625
463
rec_t*
626
464
rec_copy_prefix_to_buf(
627
465
/*===================*/
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 */
 
466
                                        /* out, own: copied record */
 
467
        rec_t*          rec,            /* in: physical record */
 
468
        dict_index_t*   index,          /* in: record descriptor */
 
469
        ulint           n_fields,       /* in: number of fields to copy */
 
470
        byte**          buf,            /* in/out: memory buffer
 
471
                                        for the copied prefix, or NULL */
 
472
        ulint*          buf_size);      /* in/out: buffer size */
637
473
/****************************************************************
638
474
Folds a prefix of a physical record to a ulint. */
639
475
UNIV_INLINE
641
477
rec_fold(
642
478
/*=====*/
643
479
                                        /* out: the folded value */
644
 
        const rec_t*    rec,            /* in: the physical record */
 
480
        rec_t*          rec,            /* in: the physical record */
645
481
        const ulint*    offsets,        /* in: array returned by
646
482
                                        rec_get_offsets() */
647
483
        ulint           n_fields,       /* in: number of complete
648
484
                                        fields to fold */
649
485
        ulint           n_bytes,        /* in: number of bytes to fold
650
486
                                        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
 
487
        dulint          tree_id);       /* in: index tree id */
 
488
/*************************************************************
 
489
Builds a physical record out of a data tuple and stores it beginning from
 
490
address destination. */
 
491
 
672
492
rec_t*
673
493
rec_convert_dtuple_to_rec(
674
494
/*======================*/
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 */
 
495
                                /* out: pointer to the origin
 
496
                                of physical record */
 
497
        byte*           buf,    /* in: start address of the
 
498
                                physical record */
 
499
        dict_index_t*   index,  /* in: record descriptor */
 
500
        dtuple_t*       dtuple);/* in: data tuple */
683
501
/**************************************************************
684
502
Returns the extra size of an old-style physical record if we know its
685
503
data size and number of fields. */
689
507
/*=========================*/
690
508
                                /* out: extra size */
691
509
        ulint   data_size,      /* in: data size */
692
 
        ulint   n_fields,       /* in: number of fields */
693
 
        ulint   n_ext)          /* in: number of externally stored columns */
694
 
                __attribute__((__const__));
695
 
/**************************************************************
696
 
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
697
 
UNIV_INTERN
698
 
ulint
699
 
rec_get_converted_size_comp(
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
 
        ulint                   status, /* in: status bits of the record */
707
 
        const dfield_t*         fields, /* in: array of data fields */
708
 
        ulint                   n_fields,/* in: number of data fields */
709
 
        ulint*                  extra); /* out: extra size */
 
510
        ulint   n_fields)       /* in: number of fields */
 
511
                __attribute__((const));
710
512
/**************************************************************
711
513
The following function returns the size of a data tuple when converted to
712
514
a physical record. */
716
518
/*===================*/
717
519
                                /* out: size */
718
520
        dict_index_t*   index,  /* in: record descriptor */
719
 
        const dtuple_t* dtuple, /* in: data tuple */
720
 
        ulint           n_ext); /* in: number of externally stored columns */
 
521
        dtuple_t*       dtuple);/* in: data tuple */
721
522
/******************************************************************
722
523
Copies the first n fields of a physical record to a data tuple.
723
524
The fields are copied to the memory heap. */
724
 
UNIV_INTERN
 
525
 
725
526
void
726
527
rec_copy_prefix_to_dtuple(
727
528
/*======================*/
728
 
        dtuple_t*               tuple,          /* out: data tuple */
729
 
        const rec_t*            rec,            /* in: physical record */
730
 
        const dict_index_t*     index,          /* in: record descriptor */
731
 
        ulint                   n_fields,       /* in: number of fields
732
 
                                                to copy */
733
 
        mem_heap_t*             heap);          /* in: memory heap */
 
529
        dtuple_t*       tuple,          /* in: data tuple */
 
530
        rec_t*          rec,            /* in: physical record */
 
531
        dict_index_t*   index,          /* in: record descriptor */
 
532
        ulint           n_fields,       /* in: number of fields to copy */
 
533
        mem_heap_t*     heap);          /* in: memory heap */
734
534
/*******************************************************************
735
535
Validates the consistency of a physical record. */
736
 
UNIV_INTERN
 
536
 
737
537
ibool
738
538
rec_validate(
739
539
/*=========*/
740
540
                                /* out: TRUE if ok */
741
 
        const rec_t*    rec,    /* in: physical record */
 
541
        rec_t*          rec,    /* in: physical record */
742
542
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
743
543
/*******************************************************************
744
544
Prints an old-style physical record. */
745
 
UNIV_INTERN
 
545
 
746
546
void
747
547
rec_print_old(
748
548
/*==========*/
749
549
        FILE*           file,   /* in: file where to print */
750
 
        const rec_t*    rec);   /* in: physical record */
751
 
/*******************************************************************
752
 
Prints a physical record in ROW_FORMAT=COMPACT.  Ignores the
753
 
record header. */
754
 
UNIV_INTERN
755
 
void
756
 
rec_print_comp(
757
 
/*===========*/
758
 
        FILE*           file,   /* in: file where to print */
759
 
        const rec_t*    rec,    /* in: physical record */
760
 
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
 
550
        rec_t*          rec);   /* in: physical record */
761
551
/*******************************************************************
762
552
Prints a physical record. */
763
 
UNIV_INTERN
 
553
 
764
554
void
765
555
rec_print_new(
766
556
/*==========*/
767
557
        FILE*           file,   /* in: file where to print */
768
 
        const rec_t*    rec,    /* in: physical record */
 
558
        rec_t*          rec,    /* in: physical record */
769
559
        const ulint*    offsets);/* in: array returned by rec_get_offsets() */
770
560
/*******************************************************************
771
561
Prints a physical record. */
772
 
UNIV_INTERN
 
562
 
773
563
void
774
564
rec_print(
775
565
/*======*/
776
566
        FILE*           file,   /* in: file where to print */
777
 
        const rec_t*    rec,    /* in: physical record */
 
567
        rec_t*          rec,    /* in: physical record */
778
568
        dict_index_t*   index); /* in: record descriptor */
779
569
 
780
570
#define REC_INFO_BITS           6       /* This is single byte bit-field */