1
/************************************************************************
4
(c) 1994-1996 Innobase Oy
6
Created 5/30/1994 Heikki Tuuri
7
*************************************************************************/
13
#include "data0data.h"
14
#include "rem0types.h"
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)
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
25
/* Number of extra bytes in a record, in addition to the data and the
27
#define REC_N_EXTRA_BYTES 6
29
/**********************************************************
30
The following function is used to get the offset of the
31
next chained record on the same page. */
36
/* out: the page offset of the next
38
rec_t* rec); /* in: physical record */
39
/**********************************************************
40
The following function is used to set the next record offset field
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
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. */
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
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
83
rec_t* rec); /* in: physical record */
84
/**********************************************************
85
The following function is used to set the info bits of a record. */
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. */
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. */
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. */
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. */
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. */
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. */
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. */
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
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. */
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. */
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
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. */
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
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. */
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. */
213
rec_t* rec); /* in: physical record */
214
/**************************************************************
215
Returns the total size of a physical record. */
221
rec_t* rec); /* in: physical record */
222
/**************************************************************
223
Returns a pointer to the start of the record. */
228
/* out: pointer to start */
229
rec_t* rec); /* in: pointer to record */
230
/**************************************************************
231
Returns a pointer to the end of the record. */
236
/* out: pointer to end */
237
rec_t* rec); /* in: pointer to record */
238
/*******************************************************************
239
Copies a physical record to a buffer. */
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
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,
259
ulint* buf_size); /* in/out: buffer size */
260
/****************************************************************
261
Folds a prefix of a physical record to a ulint. */
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. */
277
rec_convert_dtuple_to_rec(
278
/*======================*/
279
/* out: pointer to the origin of physical
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. */
288
rec_convert_dtuple_to_rec_low(
289
/*==========================*/
290
/* out: pointer to the origin of physical
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. */
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. */
310
rec_get_converted_size(
311
/*===================*/
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. */
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. */
331
/* out: TRUE if ok */
332
rec_t* rec); /* in: physical record */
333
/*******************************************************************
334
Prints a physical record. */
339
rec_t* rec); /* in: physical record */
340
/*******************************************************************
341
Prints a physical record to a buffer. */
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 */
351
#define REC_INFO_BITS 6 /* This is single byte bit-field */
354
#include "rem0rec.ic"