~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Made the_query_id private. Thanks Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
typedef struct big_rec_struct           big_rec_t;
20
20
 
21
 
/* Some non-inlined functions used in the MySQL interface: */
22
 
void
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 */
27
 
void*
28
 
dfield_get_data_noninline(
29
 
        dfield_t* field);       /* in: field */
30
 
ulint
31
 
dfield_get_len_noninline(
32
 
        dfield_t* field);       /* in: field */
33
 
ulint
34
 
dtuple_get_n_fields_noninline(
35
 
        dtuple_t*       tuple); /* in: tuple */
36
 
dfield_t*
37
 
dtuple_get_nth_field_noninline(
38
 
        dtuple_t*       tuple,  /* in: tuple */
39
 
        ulint           n);     /* in: index of field */
40
 
 
 
21
#ifdef UNIV_DEBUG
41
22
/*************************************************************************
42
23
Gets pointer to the type struct of SQL data field. */
43
24
UNIV_INLINE
45
26
dfield_get_type(
46
27
/*============*/
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. */
 
32
UNIV_INLINE
 
33
void*
 
34
dfield_get_data(
 
35
/*============*/
 
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. */
51
44
UNIV_INLINE
55
48
        dfield_t*       field,  /* in: SQL data field */
56
49
        dtype_t*        type);  /* in: pointer to data type struct */
57
50
/*************************************************************************
58
 
Gets pointer to the data in a field. */
59
 
UNIV_INLINE
60
 
void*
61
 
dfield_get_data(
62
 
/*============*/
63
 
                                /* out: pointer to data */
64
 
        dfield_t* field);       /* in: field */
65
 
/*************************************************************************
66
51
Gets length of field data. */
67
52
UNIV_INLINE
68
53
ulint
70
55
/*===========*/
71
56
                                /* out: length of data; UNIV_SQL_NULL if
72
57
                                SQL null data */
73
 
        dfield_t* field);       /* in: field */
 
58
        const dfield_t* field); /* in: field */
74
59
/*************************************************************************
75
60
Sets length in a field. */
76
61
UNIV_INLINE
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 */
 
69
UNIV_INLINE
 
70
ulint
 
71
dfield_is_null(
 
72
/*===========*/
 
73
                                /* out: nonzero if SQL null data */
 
74
        const dfield_t* field); /* in: field */
 
75
/*************************************************************************
 
76
Determines if a field is externally stored */
 
77
UNIV_INLINE
 
78
ulint
 
79
dfield_is_ext(
 
80
/*==========*/
 
81
                                /* out: nonzero if externally stored */
 
82
        const dfield_t* field); /* in: field */
 
83
/*************************************************************************
 
84
Sets the "external storage" flag */
 
85
UNIV_INLINE
 
86
void
 
87
dfield_set_ext(
 
88
/*===========*/
 
89
        dfield_t*       field); /* in/out: field */
 
90
/*************************************************************************
83
91
Sets pointer to the data and length in a field. */
84
92
UNIV_INLINE
85
93
void
88
96
        dfield_t*       field,  /* in: field */
89
97
        const void*     data,   /* in: data */
90
98
        ulint           len);   /* in: length or UNIV_SQL_NULL */
 
99
/*************************************************************************
 
100
Sets a data field to SQL NULL. */
 
101
UNIV_INLINE
 
102
void
 
103
dfield_set_null(
 
104
/*============*/
 
105
        dfield_t*       field); /* in/out: field */
91
106
/**************************************************************************
92
107
Writes an SQL null field full of zeros. */
93
108
UNIV_INLINE
102
117
void
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. */
109
124
UNIV_INLINE
110
125
void
111
126
dfield_copy(
112
127
/*========*/
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. */
 
132
UNIV_INLINE
 
133
void
 
134
dfield_dup(
 
135
/*=======*/
 
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. */
117
140
UNIV_INLINE
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. */
126
 
 
 
149
UNIV_INTERN
127
150
ibool
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. */
136
159
UNIV_INLINE
138
161
dtuple_get_n_fields(
139
162
/*================*/
140
163
                                /* out: number of fields */
141
 
        dtuple_t*       tuple); /* in: tuple */
 
164
        const dtuple_t* tuple); /* in: tuple */
 
165
#ifdef UNIV_DEBUG
142
166
/*************************************************************************
143
167
Gets nth field of a tuple. */
144
168
UNIV_INLINE
146
170
dtuple_get_nth_field(
147
171
/*=================*/
148
172
                                /* out: nth field */
149
 
        dtuple_t*       tuple,  /* in: tuple */
 
173
        const dtuple_t* tuple,  /* in: tuple */
150
174
        ulint           n);     /* in: index of field */
 
175
#else /* UNIV_DEBUG */
 
176
# define dtuple_get_nth_field(tuple, n) ((tuple)->fields + (n))
 
177
#endif /* UNIV_DEBUG */
151
178
/*************************************************************************
152
179
Gets info bits in a data tuple. */
153
180
UNIV_INLINE
155
182
dtuple_get_info_bits(
156
183
/*=================*/
157
184
                                /* out: info bits */
158
 
        dtuple_t*       tuple); /* in: tuple */
 
185
        const dtuple_t* tuple); /* in: tuple */
159
186
/*************************************************************************
160
187
Sets info bits in a data tuple. */
161
188
UNIV_INLINE
172
199
/*====================*/
173
200
                                /* out: number of fields used in comparisons
174
201
                                in rem0cmp.* */
175
 
        dtuple_t*       tuple); /* in: tuple */
 
202
        const dtuple_t* tuple); /* in: tuple */
176
203
/*************************************************************************
177
204
Gets number of fields used in record comparisons. */
178
205
UNIV_INLINE
194
221
                                is created */
195
222
        ulint           n_fields); /* in: number of fields */
196
223
 
197
 
/*************************************************************************
198
 
Creates a dtuple for use in MySQL. */
199
 
 
200
 
dtuple_t*
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. */
208
 
 
209
 
void
210
 
dtuple_free_for_mysql(
211
 
/*==================*/
212
 
        void* heap);
 
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. */
 
227
UNIV_INLINE
 
228
const dtuple_t*
 
229
dtuple_from_fields(
 
230
/*===============*/
 
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 */
 
235
 
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. */
216
 
 
 
239
UNIV_INTERN
217
240
void
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. */
 
248
UNIV_INLINE
 
249
dtuple_t*
 
250
dtuple_copy(
 
251
/*========*/
 
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. */
 
267
UNIV_INLINE
 
268
ulint
 
269
dtuple_get_n_ext(
 
270
/*=============*/
 
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
234
 
strings). */
235
 
 
236
 
ibool
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. */
 
275
UNIV_INTERN
 
276
int
 
277
dtuple_coll_cmp(
 
278
/*============*/
 
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. */
247
285
UNIV_INLINE
249
287
dtuple_fold(
250
288
/*========*/
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. */
259
298
UNIV_INLINE
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. */
275
 
 
 
314
UNIV_INTERN
276
315
ibool
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. */
283
 
 
 
322
UNIV_INTERN
284
323
ibool
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. */
291
 
 
 
330
UNIV_INTERN
292
331
ibool
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. */
301
 
 
 
340
UNIV_INTERN
302
341
ibool
303
342
dtuple_validate(
304
343
/*============*/
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. */
310
 
 
 
349
UNIV_INTERN
311
350
void
312
351
dfield_print(
313
352
/*=========*/
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. */
318
 
 
 
357
UNIV_INTERN
319
358
void
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. */
325
 
 
 
364
UNIV_INTERN
326
365
void
327
366
dtuple_print(
328
367
/*=========*/
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. */
336
 
 
 
375
UNIV_INTERN
337
376
big_rec_t*
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. */
355
 
 
 
392
UNIV_INTERN
356
393
void
357
394
dtuple_convert_back_big_rec(
358
395
/*========================*/
362
399
                                freed in this function */
363
400
/******************************************************************
364
401
Frees the memory in a big rec vector. */
365
 
 
 
402
UNIV_INLINE
366
403
void
367
404
dtuple_big_rec_free(
368
405
/*================*/
374
411
/* Structure for an SQL data field */
375
412
struct dfield_struct{
376
413
        void*           data;   /* pointer to data */
377
 
        ulint           len;    /* data length; UNIV_SQL_NULL if SQL null; */
 
414
        unsigned        ext:1;  /* TRUE=externally stored, FALSE=local */
 
415
        unsigned        len:32; /* data length; UNIV_SQL_NULL if SQL null */
378
416
        dtype_t         type;   /* type of data */
379
417
};
380
418
 
395
433
        UT_LIST_NODE_T(dtuple_t) tuple_list;
396
434
                                        /* data tuples can be linked into a
397
435
                                        list using this field */
 
436
#ifdef UNIV_DEBUG
398
437
        ulint           magic_n;
 
438
# define                DATA_TUPLE_MAGIC_N      65478679
 
439
#endif /* UNIV_DEBUG */
399
440
};
400
 
#define DATA_TUPLE_MAGIC_N      65478679
401
441
 
402
442
/* A slot for a field in a big rec vector */
403
443
 
405
445
struct big_rec_field_struct {
406
446
        ulint           field_no;       /* field number in record */
407
447
        ulint           len;            /* stored data len */
408
 
        byte*           data;           /* stored data */
 
448
        const void*     data;           /* stored data */
409
449
};
410
450
 
411
451
/* Storage format for overflow data in a big record, that is, a record