~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/data/data0data.c

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/************************************************************************
 
19
/********************************************************************//**
 
20
@file data/data0data.c
20
21
SQL data field and tuple
21
22
 
22
23
Created 5/30/1994 Heikki Tuuri
28
29
#include "data0data.ic"
29
30
#endif
30
31
 
 
32
#ifndef UNIV_HOTBACKUP
31
33
#include "rem0rec.h"
32
34
#include "rem0cmp.h"
33
35
#include "page0page.h"
36
38
#include "btr0cur.h"
37
39
 
38
40
#include <ctype.h>
 
41
#endif /* !UNIV_HOTBACKUP */
39
42
 
40
43
#ifdef UNIV_DEBUG
41
 
/* data pointers of tuple fields are initialized to point here
42
 
for error checking */
 
44
/** Dummy variable to catch access to uninitialized fields.  In the
 
45
debug version, dtuple_create() will make all fields of dtuple_t point
 
46
to data_error. */
43
47
UNIV_INTERN byte        data_error;
44
48
 
45
49
# ifndef UNIV_DEBUG_VALGRIND
46
 
/* this is used to fool the compiler in dtuple_validate */
 
50
/** this is used to fool the compiler in dtuple_validate */
47
51
UNIV_INTERN ulint       data_dummy;
48
52
# endif /* !UNIV_DEBUG_VALGRIND */
49
53
#endif /* UNIV_DEBUG */
50
54
 
51
 
/*************************************************************************
52
 
Tests if dfield data length and content is equal to the given. */
 
55
#ifndef UNIV_HOTBACKUP
 
56
/*********************************************************************//**
 
57
Tests if dfield data length and content is equal to the given.
 
58
@return TRUE if equal */
53
59
UNIV_INTERN
54
60
ibool
55
61
dfield_data_is_binary_equal(
56
62
/*========================*/
57
 
                                /* out: TRUE if equal */
58
 
        const dfield_t* field,  /* in: field */
59
 
        ulint           len,    /* in: data length or UNIV_SQL_NULL */
60
 
        const byte*     data)   /* in: data */
 
63
        const dfield_t* field,  /*!< in: field */
 
64
        ulint           len,    /*!< in: data length or UNIV_SQL_NULL */
 
65
        const byte*     data)   /*!< in: data */
61
66
{
62
67
        if (len != dfield_get_len(field)) {
63
68
 
77
82
        return(TRUE);
78
83
}
79
84
 
80
 
/****************************************************************
81
 
Compare two data tuples, respecting the collation of character fields. */
 
85
/************************************************************//**
 
86
Compare two data tuples, respecting the collation of character fields.
 
87
@return 1, 0 , -1 if tuple1 is greater, equal, less, respectively,
 
88
than tuple2 */
82
89
UNIV_INTERN
83
90
int
84
91
dtuple_coll_cmp(
85
92
/*============*/
86
 
                                /* out: 1, 0 , -1 if tuple1 is greater, equal,
87
 
                                less, respectively, than tuple2 */
88
 
        const dtuple_t* tuple1, /* in: tuple 1 */
89
 
        const dtuple_t* tuple2) /* in: tuple 2 */
 
93
        const dtuple_t* tuple1, /*!< in: tuple 1 */
 
94
        const dtuple_t* tuple2) /*!< in: tuple 2 */
90
95
{
91
96
        ulint   n_fields;
92
97
        ulint   i;
119
124
        return(0);
120
125
}
121
126
 
122
 
/*************************************************************************
 
127
/*********************************************************************//**
123
128
Sets number of fields used in a tuple. Normally this is set in
124
129
dtuple_create, but if you want later to set it smaller, you can use this. */
125
130
UNIV_INTERN
126
131
void
127
132
dtuple_set_n_fields(
128
133
/*================*/
129
 
        dtuple_t*       tuple,          /* in: tuple */
130
 
        ulint           n_fields)       /* in: number of fields */
 
134
        dtuple_t*       tuple,          /*!< in: tuple */
 
135
        ulint           n_fields)       /*!< in: number of fields */
131
136
{
132
137
        ut_ad(tuple);
133
138
 
135
140
        tuple->n_fields_cmp = n_fields;
136
141
}
137
142
 
138
 
/**************************************************************
139
 
Checks that a data field is typed. */
 
143
/**********************************************************//**
 
144
Checks that a data field is typed.
 
145
@return TRUE if ok */
140
146
static
141
147
ibool
142
148
dfield_check_typed_no_assert(
143
149
/*=========================*/
144
 
                                /* out: TRUE if ok */
145
 
        const dfield_t* field)  /* in: data field */
 
150
        const dfield_t* field)  /*!< in: data field */
146
151
{
147
152
        if (dfield_get_type(field)->mtype > DATA_MYSQL
148
153
            || dfield_get_type(field)->mtype < DATA_VARCHAR) {
157
162
        return(TRUE);
158
163
}
159
164
 
160
 
/**************************************************************
161
 
Checks that a data tuple is typed. */
 
165
/**********************************************************//**
 
166
Checks that a data tuple is typed.
 
167
@return TRUE if ok */
162
168
UNIV_INTERN
163
169
ibool
164
170
dtuple_check_typed_no_assert(
165
171
/*=========================*/
166
 
                                /* out: TRUE if ok */
167
 
        const dtuple_t* tuple)  /* in: tuple */
 
172
        const dtuple_t* tuple)  /*!< in: tuple */
168
173
{
169
174
        const dfield_t* field;
170
175
        ulint           i;
192
197
 
193
198
        return(TRUE);
194
199
}
 
200
#endif /* !UNIV_HOTBACKUP */
195
201
 
196
 
/**************************************************************
197
 
Checks that a data field is typed. Asserts an error if not. */
 
202
#ifdef UNIV_DEBUG
 
203
/**********************************************************//**
 
204
Checks that a data field is typed. Asserts an error if not.
 
205
@return TRUE if ok */
198
206
UNIV_INTERN
199
207
ibool
200
208
dfield_check_typed(
201
209
/*===============*/
202
 
                                /* out: TRUE if ok */
203
 
        const dfield_t* field)  /* in: data field */
 
210
        const dfield_t* field)  /*!< in: data field */
204
211
{
205
212
        if (dfield_get_type(field)->mtype > DATA_MYSQL
206
213
            || dfield_get_type(field)->mtype < DATA_VARCHAR) {
216
223
        return(TRUE);
217
224
}
218
225
 
219
 
/**************************************************************
220
 
Checks that a data tuple is typed. Asserts an error if not. */
 
226
/**********************************************************//**
 
227
Checks that a data tuple is typed. Asserts an error if not.
 
228
@return TRUE if ok */
221
229
UNIV_INTERN
222
230
ibool
223
231
dtuple_check_typed(
224
232
/*===============*/
225
 
                                /* out: TRUE if ok */
226
 
        const dtuple_t* tuple)  /* in: tuple */
 
233
        const dtuple_t* tuple)  /*!< in: tuple */
227
234
{
228
235
        const dfield_t* field;
229
236
        ulint           i;
238
245
        return(TRUE);
239
246
}
240
247
 
241
 
#ifdef UNIV_DEBUG
242
 
/**************************************************************
 
248
/**********************************************************//**
243
249
Validates the consistency of a tuple which must be complete, i.e,
244
 
all fields must have been set. */
 
250
all fields must have been set.
 
251
@return TRUE if ok */
245
252
UNIV_INTERN
246
253
ibool
247
254
dtuple_validate(
248
255
/*============*/
249
 
                                /* out: TRUE if ok */
250
 
        const dtuple_t* tuple)  /* in: tuple */
 
256
        const dtuple_t* tuple)  /*!< in: tuple */
251
257
{
252
258
        const dfield_t* field;
253
259
        ulint           n_fields;
291
297
}
292
298
#endif /* UNIV_DEBUG */
293
299
 
294
 
/*****************************************************************
 
300
#ifndef UNIV_HOTBACKUP
 
301
/*************************************************************//**
295
302
Pretty prints a dfield value according to its data type. */
296
303
UNIV_INTERN
297
304
void
298
305
dfield_print(
299
306
/*=========*/
300
 
        const dfield_t* dfield) /* in: dfield */
 
307
        const dfield_t* dfield) /*!< in: dfield */
301
308
{
302
309
        const byte*     data;
303
310
        ulint           len;
333
340
        }
334
341
}
335
342
 
336
 
/*****************************************************************
 
343
/*************************************************************//**
337
344
Pretty prints a dfield value according to its data type. Also the hex string
338
345
is printed if a string contains non-printable characters. */
339
346
UNIV_INTERN
340
347
void
341
348
dfield_print_also_hex(
342
349
/*==================*/
343
 
        const dfield_t* dfield) /* in: dfield */
 
350
        const dfield_t* dfield) /*!< in: dfield */
344
351
{
345
352
        const byte*     data;
346
353
        ulint           len;
505
512
        }
506
513
}
507
514
 
508
 
/*****************************************************************
 
515
/*************************************************************//**
509
516
Print a dfield value using ut_print_buf. */
510
517
static
511
518
void
512
519
dfield_print_raw(
513
520
/*=============*/
514
 
        FILE*           f,              /* in: output stream */
515
 
        const dfield_t* dfield)         /* in: dfield */
 
521
        FILE*           f,              /*!< in: output stream */
 
522
        const dfield_t* dfield)         /*!< in: dfield */
516
523
{
517
524
        ulint   len     = dfield_get_len(dfield);
518
525
        if (!dfield_is_null(dfield)) {
528
535
        }
529
536
}
530
537
 
531
 
/**************************************************************
 
538
/**********************************************************//**
532
539
The following function prints the contents of a tuple. */
533
540
UNIV_INTERN
534
541
void
535
542
dtuple_print(
536
543
/*=========*/
537
 
        FILE*           f,      /* in: output stream */
538
 
        const dtuple_t* tuple)  /* in: tuple */
 
544
        FILE*           f,      /*!< in: output stream */
 
545
        const dtuple_t* tuple)  /*!< in: tuple */
539
546
{
540
547
        ulint           n_fields;
541
548
        ulint           i;
556
563
        ut_ad(dtuple_validate(tuple));
557
564
}
558
565
 
559
 
/******************************************************************
 
566
/**************************************************************//**
560
567
Moves parts of long fields in entry to the big record vector so that
561
568
the size of tuple drops below the maximum record size allowed in the
562
569
database. Moves data only from those fields which are not necessary
563
 
to determine uniquely the insertion place of the tuple in the index. */
 
570
to determine uniquely the insertion place of the tuple in the index.
 
571
@return own: created big record vector, NULL if we are not able to
 
572
shorten the entry enough, i.e., if there are too many fixed-length or
 
573
short fields in entry or the index is clustered */
564
574
UNIV_INTERN
565
575
big_rec_t*
566
576
dtuple_convert_big_rec(
567
577
/*===================*/
568
 
                                /* out, own: created big record vector,
569
 
                                NULL if we are not able to shorten
570
 
                                the entry enough, i.e., if there are
571
 
                                too many fixed-length or short fields
572
 
                                in entry or the index is clustered */
573
 
        dict_index_t*   index,  /* in: index */
574
 
        dtuple_t*       entry,  /* in/out: index entry */
575
 
        ulint*          n_ext)  /* in/out: number of
 
578
        dict_index_t*   index,  /*!< in: index */
 
579
        dtuple_t*       entry,  /*!< in/out: index entry */
 
580
        ulint*          n_ext)  /*!< in/out: number of
576
581
                                externally stored columns */
577
582
{
578
583
        mem_heap_t*     heap;
719
724
        return(vector);
720
725
}
721
726
 
722
 
/******************************************************************
 
727
/**************************************************************//**
723
728
Puts back to entry the data stored in vector. Note that to ensure the
724
729
fields in entry can accommodate the data, vector must have been created
725
730
from entry with dtuple_convert_big_rec. */
727
732
void
728
733
dtuple_convert_back_big_rec(
729
734
/*========================*/
730
 
        dict_index_t*   index __attribute__((unused)),  /* in: index */
731
 
        dtuple_t*       entry,  /* in: entry whose data was put to vector */
732
 
        big_rec_t*      vector) /* in, own: big rec vector; it is
 
735
        dict_index_t*   index __attribute__((unused)),  /*!< in: index */
 
736
        dtuple_t*       entry,  /*!< in: entry whose data was put to vector */
 
737
        big_rec_t*      vector) /*!< in, own: big rec vector; it is
733
738
                                freed in this function */
734
739
{
735
740
        big_rec_field_t*                b       = vector->fields;
756
761
 
757
762
        mem_heap_free(vector->heap);
758
763
}
 
764
#endif /* !UNIV_HOTBACKUP */