~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to innobase/include/rem0rec.h

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************
 
2
Record manager
 
3
 
 
4
(c) 1994-1996 Innobase Oy
 
5
 
 
6
Created 5/30/1994 Heikki Tuuri
 
7
*************************************************************************/
 
8
 
 
9
#ifndef rem0rec_h
 
10
#define rem0rec_h
 
11
 
 
12
#include "univ.i"
 
13
#include "data0data.h"
 
14
#include "rem0types.h"
 
15
 
 
16
/* Maximum values for various fields (for non-blob tuples) */
 
17
#define REC_MAX_N_FIELDS        (1024 - 1)
 
18
#define REC_MAX_HEAP_NO         (2 * 8192 - 1)
 
19
#define REC_MAX_N_OWNED         (16 - 1)
 
20
 
 
21
/* Flag denoting the predefined minimum record: this bit is ORed in the 4
 
22
info bits of a record */
 
23
#define REC_INFO_MIN_REC_FLAG   0x10
 
24
 
 
25
/* Number of extra bytes in a record, in addition to the data and the
 
26
offsets */
 
27
#define REC_N_EXTRA_BYTES       6
 
28
 
 
29
/**********************************************************
 
30
The following function is used to get the offset of the
 
31
next chained record on the same page. */
 
32
UNIV_INLINE
 
33
ulint 
 
34
rec_get_next_offs(
 
35
/*==============*/
 
36
                        /* out: the page offset of the next 
 
37
                        chained record */
 
38
        rec_t*  rec);   /* in: physical record */
 
39
/**********************************************************
 
40
The following function is used to set the next record offset field
 
41
of the record. */
 
42
UNIV_INLINE
 
43
void
 
44
rec_set_next_offs(
 
45
/*==============*/
 
46
        rec_t*  rec,    /* in: physical record */
 
47
        ulint   next);  /* in: offset of the next record */
 
48
/**********************************************************
 
49
The following function is used to get the number of fields
 
50
in the record. */
 
51
UNIV_INLINE
 
52
ulint
 
53
rec_get_n_fields(
 
54
/*=============*/
 
55
                        /* out: number of data fields */
 
56
        rec_t*  rec);   /* in: physical record */
 
57
/**********************************************************
 
58
The following function is used to get the number of records
 
59
owned by the previous directory record. */
 
60
UNIV_INLINE
 
61
ulint
 
62
rec_get_n_owned(
 
63
/*============*/
 
64
                        /* out: number of owned records */
 
65
        rec_t*  rec);   /* in: physical record */
 
66
/**********************************************************
 
67
The following function is used to set the number of owned
 
68
records. */
 
69
UNIV_INLINE
 
70
void
 
71
rec_set_n_owned(
 
72
/*============*/
 
73
        rec_t*  rec,            /* in: physical record */
 
74
        ulint   n_owned);       /* in: the number of owned */
 
75
/**********************************************************
 
76
The following function is used to retrieve the info bits of
 
77
a record. */
 
78
UNIV_INLINE
 
79
ulint
 
80
rec_get_info_bits(
 
81
/*==============*/
 
82
                        /* out: info bits */
 
83
        rec_t*  rec);   /* in: physical record */
 
84
/**********************************************************
 
85
The following function is used to set the info bits of a record. */
 
86
UNIV_INLINE
 
87
void
 
88
rec_set_info_bits(
 
89
/*==============*/
 
90
        rec_t*  rec,    /* in: physical record */
 
91
        ulint   bits);  /* in: info bits */
 
92
/**********************************************************
 
93
Gets the value of the deleted falg in info bits. */
 
94
UNIV_INLINE
 
95
ibool
 
96
rec_info_bits_get_deleted_flag(
 
97
/*===========================*/
 
98
                                /* out: TRUE if deleted flag set */
 
99
        ulint   info_bits);     /* in: info bits from a record */
 
100
/**********************************************************
 
101
The following function tells if record is delete marked. */
 
102
UNIV_INLINE
 
103
ibool
 
104
rec_get_deleted_flag(
 
105
/*=================*/
 
106
                        /* out: TRUE if delete marked */
 
107
        rec_t*  rec);   /* in: physical record */
 
108
/**********************************************************
 
109
The following function is used to set the deleted bit. */
 
110
UNIV_INLINE
 
111
void
 
112
rec_set_deleted_flag(
 
113
/*=================*/
 
114
        rec_t*  rec,    /* in: physical record */
 
115
        ibool   flag);  /* in: TRUE if delete marked */
 
116
/**********************************************************
 
117
The following function is used to get the order number
 
118
of the record in the heap of the index page. */
 
119
UNIV_INLINE
 
120
ulint
 
121
rec_get_heap_no(
 
122
/*=============*/
 
123
                        /* out: heap order number */
 
124
        rec_t*  rec);   /* in: physical record */
 
125
/**********************************************************
 
126
The following function is used to set the heap number
 
127
field in the record. */
 
128
UNIV_INLINE
 
129
void
 
130
rec_set_heap_no(
 
131
/*=============*/
 
132
        rec_t*  rec,    /* in: physical record */
 
133
        ulint   heap_no);/* in: the heap number */
 
134
/**********************************************************
 
135
The following function is used to test whether the data offsets
 
136
in the record are stored in one-byte or two-byte format. */
 
137
UNIV_INLINE
 
138
ibool
 
139
rec_get_1byte_offs_flag(
 
140
/*====================*/
 
141
                        /* out: TRUE if 1-byte form */
 
142
        rec_t*  rec);   /* in: physical record */
 
143
/****************************************************************
 
144
The following function is used to get a pointer to the nth
 
145
data field in the record. */
 
146
 
 
147
byte*
 
148
rec_get_nth_field(
 
149
/*==============*/
 
150
                        /* out: pointer to the field, NULL if SQL null */
 
151
        rec_t*  rec,    /* in: record */
 
152
        ulint   n,      /* in: index of the field */
 
153
        ulint*  len);   /* out: length of the field; UNIV_SQL_NULL 
 
154
                        if SQL null */
 
155
/****************************************************************
 
156
Gets the physical size of a field. Also an SQL null may have a field of
 
157
size > 0, if the data type is of a fixed size. */
 
158
UNIV_INLINE
 
159
ulint
 
160
rec_get_nth_field_size(
 
161
/*===================*/
 
162
                        /* out: field size in bytes */
 
163
        rec_t*  rec,    /* in: record */
 
164
        ulint   n);     /* in: index of the field */
 
165
/****************************************************************
 
166
The following function is used to get a copy of the nth
 
167
data field in the record to a buffer. */
 
168
UNIV_INLINE
 
169
void
 
170
rec_copy_nth_field(
 
171
/*===============*/
 
172
        void*   buf,    /* in: pointer to the buffer */
 
173
        rec_t*  rec,    /* in: record */
 
174
        ulint   n,      /* in: index of the field */
 
175
        ulint*  len);   /* out: length of the field; UNIV_SQL_NULL if SQL 
 
176
                        null */
 
177
/*************************************************************** 
 
178
This is used to modify the value of an already existing field in 
 
179
a physical record. The previous value must have exactly the same 
 
180
size as the new value. If len is UNIV_SQL_NULL then the field is 
 
181
treated as SQL null. */
 
182
UNIV_INLINE
 
183
void
 
184
rec_set_nth_field(
 
185
/*==============*/
 
186
        rec_t*  rec,    /* in: record */
 
187
        ulint   n,      /* in: index of the field */
 
188
        void*   data,   /* in: pointer to the data if not SQL null */
 
189
        ulint   len);   /* in: length of the data or UNIV_SQL_NULL. 
 
190
                        If not SQL null, must have the same length as the
 
191
                        previous value. If SQL null, previous value must be
 
192
                        SQL null. */
 
193
/************************************************************** 
 
194
The following function returns the data size of a physical
 
195
record, that is the sum of field lengths. SQL null fields
 
196
are counted as length 0 fields. The value returned by the function
 
197
is the distance from record origin to record end in bytes. */
 
198
UNIV_INLINE
 
199
ulint
 
200
rec_get_data_size(
 
201
/*==============*/
 
202
                        /* out: size */
 
203
        rec_t*  rec);   /* in: physical record */
 
204
/************************************************************** 
 
205
Returns the total size of record minus data size of record.
 
206
The value returned by the function is the distance from record 
 
207
start to record origin in bytes. */
 
208
UNIV_INLINE
 
209
ulint
 
210
rec_get_extra_size(
 
211
/*===============*/
 
212
                        /* out: size */
 
213
        rec_t*  rec);   /* in: physical record */
 
214
/************************************************************** 
 
215
Returns the total size of a physical record.  */
 
216
UNIV_INLINE
 
217
ulint
 
218
rec_get_size(
 
219
/*=========*/
 
220
                        /* out: size */
 
221
        rec_t*  rec);   /* in: physical record */
 
222
/**************************************************************
 
223
Returns a pointer to the start of the record. */
 
224
UNIV_INLINE
 
225
byte*
 
226
rec_get_start(
 
227
/*==========*/
 
228
                        /* out: pointer to start */
 
229
        rec_t*  rec);   /* in: pointer to record */
 
230
/**************************************************************
 
231
Returns a pointer to the end of the record. */
 
232
UNIV_INLINE
 
233
byte*
 
234
rec_get_end(
 
235
/*========*/
 
236
                        /* out: pointer to end */
 
237
        rec_t*  rec);   /* in: pointer to record */
 
238
/*******************************************************************
 
239
Copies a physical record to a buffer. */
 
240
UNIV_INLINE
 
241
rec_t*
 
242
rec_copy(
 
243
/*=====*/
 
244
                        /* out: pointer to the origin of the copied record */
 
245
        void*   buf,    /* in: buffer */
 
246
        rec_t*  rec);   /* in: physical record */
 
247
/******************************************************************
 
248
Copies the first n fields of a physical record to a new physical record in
 
249
a buffer. */
 
250
 
 
251
rec_t*
 
252
rec_copy_prefix_to_buf(
 
253
/*===================*/
 
254
                                /* out, own: copied record */
 
255
        rec_t*  rec,            /* in: physical record */
 
256
        ulint   n_fields,       /* in: number of fields to copy */
 
257
        byte**  buf,            /* in/out: memory buffer for the copied prefix,
 
258
                                or NULL */
 
259
        ulint*  buf_size);      /* in/out: buffer size */
 
260
/****************************************************************
 
261
Folds a prefix of a physical record to a ulint. */
 
262
UNIV_INLINE
 
263
ulint
 
264
rec_fold(
 
265
/*=====*/
 
266
                                /* out: the folded value */
 
267
        rec_t*  rec,            /* in: the physical record */
 
268
        ulint   n_fields,       /* in: number of complete fields to fold */
 
269
        ulint   n_bytes,        /* in: number of bytes to fold in an
 
270
                                incomplete last field */
 
271
        dulint  tree_id);       /* in: index tree id */
 
272
/*************************************************************
 
273
Builds a physical record out of a data tuple and stores it beginning from
 
274
address destination. */
 
275
UNIV_INLINE
 
276
rec_t*  
 
277
rec_convert_dtuple_to_rec(
 
278
/*======================*/                      
 
279
                                /* out: pointer to the origin of physical
 
280
                                record */
 
281
        byte*   destination,    /* in: start address of the physical record */
 
282
        dtuple_t* dtuple);      /* in: data tuple */
 
283
/*************************************************************
 
284
Builds a physical record out of a data tuple and stores it beginning from
 
285
address destination. */
 
286
 
 
287
rec_t*  
 
288
rec_convert_dtuple_to_rec_low(
 
289
/*==========================*/                  
 
290
                                /* out: pointer to the origin of physical
 
291
                                record */
 
292
        byte*   destination,    /* in: start address of the physical record */
 
293
        dtuple_t* dtuple,       /* in: data tuple */
 
294
        ulint   data_size);     /* in: data size of dtuple */
 
295
/**************************************************************
 
296
Returns the extra size of a physical record if we know its
 
297
data size and number of fields. */
 
298
UNIV_INLINE
 
299
ulint
 
300
rec_get_converted_extra_size(
 
301
/*=========================*/
 
302
                                /* out: extra size */
 
303
        ulint   data_size,      /* in: data size */
 
304
        ulint   n_fields);      /* in: number of fields */
 
305
/**************************************************************
 
306
The following function returns the size of a data tuple when converted to
 
307
a physical record. */
 
308
UNIV_INLINE
 
309
ulint
 
310
rec_get_converted_size(
 
311
/*===================*/
 
312
                                /* out: size */
 
313
        dtuple_t*       dtuple);/* in: data tuple */
 
314
/******************************************************************
 
315
Copies the first n fields of a physical record to a data tuple.
 
316
The fields are copied to the memory heap. */
 
317
 
 
318
void
 
319
rec_copy_prefix_to_dtuple(
 
320
/*======================*/
 
321
        dtuple_t*       tuple,          /* in: data tuple */
 
322
        rec_t*          rec,            /* in: physical record */
 
323
        ulint           n_fields,       /* in: number of fields to copy */
 
324
        mem_heap_t*     heap);          /* in: memory heap */
 
325
/*******************************************************************
 
326
Validates the consistency of a physical record. */
 
327
 
 
328
ibool
 
329
rec_validate(
 
330
/*=========*/
 
331
                        /* out: TRUE if ok */
 
332
        rec_t*  rec);   /* in: physical record */
 
333
/*******************************************************************
 
334
Prints a physical record. */
 
335
 
 
336
void
 
337
rec_print(
 
338
/*======*/
 
339
        rec_t*  rec);   /* in: physical record */
 
340
/*******************************************************************
 
341
Prints a physical record to a buffer. */
 
342
 
 
343
ulint
 
344
rec_sprintf(
 
345
/*========*/
 
346
                        /* out: printed length in bytes */
 
347
        char*   buf,    /* in: buffer to print to */
 
348
        ulint   buf_len,/* in: buffer length */
 
349
        rec_t*  rec);   /* in: physical record */
 
350
 
 
351
#define REC_INFO_BITS           6       /* This is single byte bit-field */
 
352
 
 
353
#ifndef UNIV_NONINL
 
354
#include "rem0rec.ic"
 
355
#endif
 
356
 
 
357
#endif