~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/row/row0row.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
47
47
#include "read0read.h"
48
48
#include "ut0mem.h"
49
49
 
50
 
/*********************************************************************//**
51
 
Gets the offset of trx id field, in bytes relative to the origin of
52
 
a clustered index record.
53
 
@return offset of DATA_TRX_ID */
54
 
UNIV_INTERN
55
 
ulint
56
 
row_get_trx_id_offset(
57
 
/*==================*/
58
 
        const rec_t*    rec __attribute__((unused)),
59
 
                                /*!< in: record */
60
 
        dict_index_t*   index,  /*!< in: clustered index */
61
 
        const ulint*    offsets)/*!< in: rec_get_offsets(rec, index) */
62
 
{
63
 
        ulint   pos;
64
 
        ulint   offset;
65
 
        ulint   len;
66
 
 
67
 
        ut_ad(dict_index_is_clust(index));
68
 
        ut_ad(rec_offs_validate(rec, index, offsets));
69
 
 
70
 
        pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
71
 
 
72
 
        offset = rec_get_nth_field_offs(offsets, pos, &len);
73
 
 
74
 
        ut_ad(len == DATA_TRX_ID_LEN);
75
 
 
76
 
        return(offset);
77
 
}
78
 
 
79
50
/*****************************************************************//**
80
51
When an insert or purge to a table is performed, this function builds
81
52
the entry to be inserted into or purged from an index on the table.
130
101
 
131
102
                dfield_copy(dfield, dfield2);
132
103
 
133
 
                if (dfield_is_null(dfield) || ind_field->prefix_len == 0) {
134
 
                        continue;
135
 
                }
136
 
 
137
 
                /* If a column prefix index, take only the prefix.
138
 
                Prefix-indexed columns may be externally stored. */
 
104
                if (dfield_is_null(dfield)) {
 
105
                        continue;
 
106
                }
 
107
 
 
108
                if (ind_field->prefix_len == 0
 
109
                    && (!dfield_is_ext(dfield)
 
110
                        || dict_index_is_clust(index))) {
 
111
                        /* The dfield_copy() above suffices for
 
112
                        columns that are stored in-page, or for
 
113
                        clustered index record columns that are not
 
114
                        part of a column prefix in the PRIMARY KEY. */
 
115
                        continue;
 
116
                }
 
117
 
 
118
                /* If the column is stored externally (off-page) in
 
119
                the clustered index, it must be an ordering field in
 
120
                the secondary index.  In the Antelope format, only
 
121
                prefix-indexed columns may be stored off-page in the
 
122
                clustered index record. In the Barracuda format, also
 
123
                fully indexed long CHAR or VARCHAR columns may be
 
124
                stored off-page. */
139
125
                ut_ad(col->ord_part);
140
126
 
141
127
                if (UNIV_LIKELY_NULL(ext)) {
148
134
                                }
149
135
                                dfield_set_data(dfield, buf, len);
150
136
                        }
 
137
 
 
138
                        if (ind_field->prefix_len == 0) {
 
139
                                /* In the Barracuda format
 
140
                                (ROW_FORMAT=DYNAMIC or
 
141
                                ROW_FORMAT=COMPRESSED), we can have a
 
142
                                secondary index on an entire column
 
143
                                that is stored off-page in the
 
144
                                clustered index. As this is not a
 
145
                                prefix index (prefix_len == 0),
 
146
                                include the entire off-page column in
 
147
                                the secondary index record. */
 
148
                                continue;
 
149
                        }
151
150
                } else if (dfield_is_ext(dfield)) {
 
151
                        /* This table is either in Antelope format
 
152
                        (ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPACT)
 
153
                        or a purge record where the ordered part of
 
154
                        the field is not external.
 
155
                        In Antelope, the maximum column prefix
 
156
                        index length is 767 bytes, and the clustered
 
157
                        index record contains a 768-byte prefix of
 
158
                        each off-page column. */
152
159
                        ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
153
160
                        len -= BTR_EXTERN_FIELD_REF_SIZE;
154
 
                        ut_a(ind_field->prefix_len <= len
155
 
                             || dict_index_is_clust(index));
 
161
                        dfield_set_len(dfield, len);
156
162
                }
157
163
 
158
 
                len = dtype_get_at_most_n_mbchars(
159
 
                        col->prtype, col->mbminlen, col->mbmaxlen,
160
 
                        ind_field->prefix_len, len, dfield_get_data(dfield));
161
 
                dfield_set_len(dfield, len);
 
164
                /* If a column prefix index, take only the prefix. */
 
165
                if (ind_field->prefix_len) {
 
166
                        len = dtype_get_at_most_n_mbchars(
 
167
                                col->prtype, col->mbminlen, col->mbmaxlen,
 
168
                                ind_field->prefix_len, len,
 
169
                                dfield_get_data(dfield));
 
170
                        dfield_set_len(dfield, len);
 
171
                }
162
172
        }
163
173
 
164
174
        ut_ad(dtuple_check_typed(entry));
223
233
 
224
234
        ut_ad(index && rec && heap);
225
235
        ut_ad(dict_index_is_clust(index));
 
236
        ut_ad(!mutex_own(&kernel_mutex));
226
237
 
227
238
        if (!offsets) {
228
239
                offsets = rec_get_offsets(rec, index, offsets_,
231
242
                ut_ad(rec_offs_validate(rec, index, offsets));
232
243
        }
233
244
 
 
245
#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
 
246
        /* This condition can occur during crash recovery before
 
247
        trx_rollback_active() has completed execution.
 
248
 
 
249
        This condition is possible if the server crashed
 
250
        during an insert or update before
 
251
        btr_store_big_rec_extern_fields() did mtr_commit() all
 
252
        BLOB pointers to the clustered index record.
 
253
 
 
254
        If the record contains a null BLOB pointer, look up the
 
255
        transaction that holds the implicit lock on this record, and
 
256
        assert that it was recovered (and will soon be rolled back). */
 
257
        ut_a(!rec_offs_any_null_extern(rec, offsets)
 
258
             || trx_assert_recovered(row_get_rec_trx_id(rec, index, offsets)));
 
259
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 
260
 
234
261
        if (type != ROW_COPY_POINTERS) {
235
262
                /* Take a copy of rec to heap */
236
263
                buf = mem_heap_alloc(heap, rec_offs_size(offsets));
294
321
 
295
322
        ut_ad(dtuple_check_typed(row));
296
323
 
297
 
        if (j) {
 
324
        if (!ext) {
 
325
                /* REDUNDANT and COMPACT formats store a local
 
326
                768-byte prefix of each externally stored
 
327
                column. No cache is needed. */
 
328
                ut_ad(dict_table_get_format(index->table)
 
329
                      < DICT_TF_FORMAT_ZIP);
 
330
        } else if (j) {
298
331
                *ext = row_ext_create(j, ext_cols, row,
299
332
                                      dict_table_zip_size(index->table),
300
333
                                      heap);
409
442
                rec = rec_copy(buf, rec, offsets);
410
443
                /* Avoid a debug assertion in rec_offs_validate(). */
411
444
                rec_offs_make_valid(rec, index, offsets);
 
445
#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
 
446
        } else {
 
447
                ut_a(!rec_offs_any_null_extern(rec, offsets));
 
448
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
412
449
        }
413
450
 
414
451
        entry = row_rec_to_index_entry_low(rec, index, offsets, n_ext, heap);