~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Eric Day
  • Date: 2009-10-31 21:53:33 UTC
  • mfrom: (1200 staging)
  • mto: This revision was merged to the branch mainline in revision 1202.
  • Revision ID: eday@oddments.org-20091031215333-j94bjoanwmi68p6f
Merged trunk.

Show diffs side-by-side

added added

removed removed

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