1
1
/*****************************************************************************
3
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
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"
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 */
56
row_get_trx_id_offset(
57
/*==================*/
58
const rec_t* rec __attribute__((unused)),
60
dict_index_t* index, /*!< in: clustered index */
61
const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
67
ut_ad(dict_index_is_clust(index));
68
ut_ad(rec_offs_validate(rec, index, offsets));
70
pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
72
offset = rec_get_nth_field_offs(offsets, pos, &len);
74
ut_ad(len == DATA_TRX_ID_LEN);
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.
131
102
dfield_copy(dfield, dfield2);
133
if (dfield_is_null(dfield) || ind_field->prefix_len == 0) {
137
/* If a column prefix index, take only the prefix.
138
Prefix-indexed columns may be externally stored. */
104
if (dfield_is_null(dfield)) {
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. */
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
139
125
ut_ad(col->ord_part);
141
127
if (UNIV_LIKELY_NULL(ext)) {
149
135
dfield_set_data(dfield, buf, len);
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. */
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);
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);
164
174
ut_ad(dtuple_check_typed(entry));
231
242
ut_ad(rec_offs_validate(rec, index, offsets));
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.
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.
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 */
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));
295
322
ut_ad(dtuple_check_typed(row));
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);
298
331
*ext = row_ext_create(j, ext_cols, row,
299
332
dict_table_zip_size(index->table),
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
447
ut_a(!rec_offs_any_null_extern(rec, offsets));
448
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
414
451
entry = row_rec_to_index_entry_low(rec, index, offsets, n_ext, heap);