19
19
typedef struct big_rec_struct big_rec_t;
21
/* Some non-inlined functions used in the MySQL interface: */
23
dfield_set_data_noninline(
24
dfield_t* field, /* in: field */
25
void* data, /* in: data */
26
ulint len); /* in: length or UNIV_SQL_NULL */
28
dfield_get_data_noninline(
29
dfield_t* field); /* in: field */
31
dfield_get_len_noninline(
32
dfield_t* field); /* in: field */
34
dtuple_get_n_fields_noninline(
35
dtuple_t* tuple); /* in: tuple */
37
dtuple_get_nth_field_noninline(
38
dtuple_t* tuple, /* in: tuple */
39
ulint n); /* in: index of field */
41
22
/*************************************************************************
42
23
Gets pointer to the type struct of SQL data field. */
47
28
/* out: pointer to the type struct */
48
dfield_t* field); /* in: SQL data field */
29
const dfield_t* field); /* in: SQL data field */
30
/*************************************************************************
31
Gets pointer to the data in a field. */
36
/* out: pointer to data */
37
const dfield_t* field); /* in: field */
38
#else /* UNIV_DEBUG */
39
# define dfield_get_type(field) (&(field)->type)
40
# define dfield_get_data(field) ((field)->data)
41
#endif /* UNIV_DEBUG */
49
42
/*************************************************************************
50
43
Sets the type struct of SQL data field. */
80
65
dfield_t* field, /* in: field */
81
66
ulint len); /* in: length or UNIV_SQL_NULL */
82
67
/*************************************************************************
68
Determines if a field is SQL NULL */
73
/* out: nonzero if SQL null data */
74
const dfield_t* field); /* in: field */
75
/*************************************************************************
76
Determines if a field is externally stored */
81
/* out: nonzero if externally stored */
82
const dfield_t* field); /* in: field */
83
/*************************************************************************
84
Sets the "external storage" flag */
89
dfield_t* field); /* in/out: field */
90
/*************************************************************************
83
91
Sets pointer to the data and length in a field. */
103
118
dfield_copy_data(
104
119
/*=============*/
105
dfield_t* field1, /* in: field to copy to */
106
dfield_t* field2);/* in: field to copy from */
120
dfield_t* field1, /* out: field to copy to */
121
const dfield_t* field2);/* in: field to copy from */
107
122
/*************************************************************************
108
123
Copies a data field to another. */
113
dfield_t* field1, /* in: field to copy to */
114
dfield_t* field2);/* in: field to copy from */
128
dfield_t* field1, /* out: field to copy to */
129
const dfield_t* field2);/* in: field to copy from */
130
/*************************************************************************
131
Copies the data pointed to by a data field. */
136
dfield_t* field, /* in/out: data field */
137
mem_heap_t* heap); /* in: memory heap where allocated */
115
138
/*************************************************************************
116
139
Tests if data length and content is equal for two dfields. */
119
142
dfield_datas_are_binary_equal(
120
143
/*==========================*/
121
144
/* out: TRUE if equal */
122
dfield_t* field1, /* in: field */
123
dfield_t* field2);/* in: field */
145
const dfield_t* field1, /* in: field */
146
const dfield_t* field2);/* in: field */
124
147
/*************************************************************************
125
148
Tests if dfield data length and content is equal to the given. */
128
151
dfield_data_is_binary_equal(
129
152
/*========================*/
130
153
/* out: TRUE if equal */
131
dfield_t* field, /* in: field */
154
const dfield_t* field, /* in: field */
132
155
ulint len, /* in: data length or UNIV_SQL_NULL */
133
byte* data); /* in: data */
156
const byte* data); /* in: data */
134
157
/*************************************************************************
135
158
Gets number of fields in a data tuple. */
195
222
ulint n_fields); /* in: number of fields */
197
/*************************************************************************
198
Creates a dtuple for use in MySQL. */
201
dtuple_create_for_mysql(
202
/*====================*/
203
/* out, own created dtuple */
204
void** heap, /* out: created memory heap */
205
ulint n_fields); /* in: number of fields */
206
/*************************************************************************
207
Frees a dtuple used in MySQL. */
210
dtuple_free_for_mysql(
211
/*==================*/
224
/**************************************************************
225
Wrap data fields in a tuple. The default value for number
226
of fields used in record comparisons for this tuple is n_fields. */
231
/* out: data tuple */
232
dtuple_t* tuple, /* in: storage for data tuple */
233
const dfield_t* fields, /* in: fields */
234
ulint n_fields); /* in: number of fields */
213
236
/*************************************************************************
214
237
Sets number of fields used in a tuple. Normally this is set in
215
238
dtuple_create, but if you want later to set it smaller, you can use this. */
218
241
dtuple_set_n_fields(
219
242
/*================*/
220
243
dtuple_t* tuple, /* in: tuple */
221
244
ulint n_fields); /* in: number of fields */
245
/*************************************************************************
246
Copies a data tuple to another. This is a shallow copy; if a deep copy
247
is desired, dfield_dup() will have to be invoked on each field. */
252
/* out, own: copy of tuple */
253
const dtuple_t* tuple, /* in: tuple to copy from */
254
mem_heap_t* heap); /* in: memory heap
255
where the tuple is created */
222
256
/**************************************************************
223
257
The following function returns the sum of data lengths of a tuple. The space
224
258
occupied by the field structs or the tuple struct is not counted. */
227
261
dtuple_get_data_size(
228
262
/*=================*/
229
263
/* out: sum of data lens */
230
dtuple_t* tuple); /* in: typed data tuple */
264
const dtuple_t* tuple); /* in: typed data tuple */
265
/*************************************************************************
266
Computes the number of externally stored fields in a data tuple. */
271
/* out: number of fields */
272
const dtuple_t* tuple); /* in: tuple */
231
273
/****************************************************************
232
Returns TRUE if lengths of two dtuples are equal and respective data fields
233
in them are equal when compared with collation in char fields (not as binary
237
dtuple_datas_are_ordering_equal(
238
/*============================*/
239
/* out: TRUE if length and fieds are equal
240
when compared with cmp_data_data:
241
NOTE: in character type fields some letters
242
are identified with others! (collation) */
243
dtuple_t* tuple1, /* in: tuple 1 */
244
dtuple_t* tuple2);/* in: tuple 2 */
274
Compare two data tuples, respecting the collation of character fields. */
279
/* out: 1, 0 , -1 if tuple1 is greater, equal,
280
less, respectively, than tuple2 */
281
const dtuple_t* tuple1, /* in: tuple 1 */
282
const dtuple_t* tuple2);/* in: tuple 2 */
245
283
/****************************************************************
246
284
Folds a prefix given as the number of fields of a tuple. */
251
289
/* out: the folded value */
252
dtuple_t* tuple, /* in: the tuple */
290
const dtuple_t* tuple, /* in: the tuple */
253
291
ulint n_fields,/* in: number of complete fields to fold */
254
292
ulint n_bytes,/* in: number of bytes to fold in an
255
293
incomplete last field */
256
dulint tree_id);/* in: index tree id */
294
dulint tree_id)/* in: index tree id */
295
__attribute__((pure));
257
296
/***********************************************************************
258
297
Sets types of fields binary in a tuple. */
269
308
dtuple_contains_null(
270
309
/*=================*/
271
310
/* out: TRUE if some field is SQL null */
272
dtuple_t* tuple); /* in: dtuple */
311
const dtuple_t* tuple); /* in: dtuple */
273
312
/**************************************************************
274
313
Checks that a data field is typed. Asserts an error if not. */
277
316
dfield_check_typed(
278
317
/*===============*/
279
318
/* out: TRUE if ok */
280
dfield_t* field); /* in: data field */
319
const dfield_t* field); /* in: data field */
281
320
/**************************************************************
282
321
Checks that a data tuple is typed. Asserts an error if not. */
285
324
dtuple_check_typed(
286
325
/*===============*/
287
326
/* out: TRUE if ok */
288
dtuple_t* tuple); /* in: tuple */
327
const dtuple_t* tuple); /* in: tuple */
289
328
/**************************************************************
290
329
Checks that a data tuple is typed. */
293
332
dtuple_check_typed_no_assert(
294
333
/*=========================*/
295
334
/* out: TRUE if ok */
296
dtuple_t* tuple); /* in: tuple */
335
const dtuple_t* tuple); /* in: tuple */
297
336
#ifdef UNIV_DEBUG
298
337
/**************************************************************
299
338
Validates the consistency of a tuple which must be complete, i.e,
300
339
all fields must have been set. */
305
344
/* out: TRUE if ok */
306
dtuple_t* tuple); /* in: tuple */
345
const dtuple_t* tuple); /* in: tuple */
307
346
#endif /* UNIV_DEBUG */
308
347
/*****************************************************************
309
348
Pretty prints a dfield value according to its data type. */
314
dfield_t* dfield);/* in: dfield */
353
const dfield_t* dfield);/* in: dfield */
315
354
/*****************************************************************
316
355
Pretty prints a dfield value according to its data type. Also the hex string
317
356
is printed if a string contains non-printable characters. */
320
359
dfield_print_also_hex(
321
360
/*==================*/
322
dfield_t* dfield); /* in: dfield */
361
const dfield_t* dfield); /* in: dfield */
323
362
/**************************************************************
324
363
The following function prints the contents of a tuple. */
329
368
FILE* f, /* in: output stream */
330
dtuple_t* tuple); /* in: tuple */
369
const dtuple_t* tuple); /* in: tuple */
331
370
/******************************************************************
332
371
Moves parts of long fields in entry to the big record vector so that
333
372
the size of tuple drops below the maximum record size allowed in the
334
373
database. Moves data only from those fields which are not necessary
335
374
to determine uniquely the insertion place of the tuple in the index. */
338
377
dtuple_convert_big_rec(
339
378
/*===================*/
340
379
/* out, own: created big record vector,
341
380
NULL if we are not able to shorten
342
381
the entry enough, i.e., if there are
343
too many short fields in entry */
382
too many fixed-length or short fields
383
in entry or the index is clustered */
344
384
dict_index_t* index, /* in: index */
345
dtuple_t* entry, /* in: index entry */
346
ulint* ext_vec,/* in: array of externally stored fields,
347
or NULL: if a field already is externally
348
stored, then we cannot move it to the vector
349
this function returns */
350
ulint n_ext_vec);/* in: number of elements is ext_vec */
385
dtuple_t* entry, /* in/out: index entry */
386
ulint* n_ext); /* in/out: number of
387
externally stored columns */
351
388
/******************************************************************
352
389
Puts back to entry the data stored in vector. Note that to ensure the
353
390
fields in entry can accommodate the data, vector must have been created
354
391
from entry with dtuple_convert_big_rec. */
357
394
dtuple_convert_back_big_rec(
358
395
/*========================*/