1 /*****************************************************************************
3 Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /**************************************************//**
20 @file include/row0row.ic
23 Created 4/20/1996 Heikki Tuuri
24 *******************************************************/
26 #include "dict0dict.h"
30 /*********************************************************************//**
31 Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of
32 a clustered index record.
33 @return offset of DATA_TRX_ID */
36 row_get_trx_id_offset(
37 /*==================*/
38 const dict_index_t* index, /*!< in: clustered index */
39 const ulint* offsets)/*!< in: record offsets */
45 ut_ad(dict_index_is_clust(index));
46 ut_ad(rec_offs_validate(NULL, index, offsets));
48 pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
50 offset = rec_get_nth_field_offs(offsets, pos, &len);
52 ut_ad(len == DATA_TRX_ID_LEN);
57 /*********************************************************************//**
58 Reads the trx id field from a clustered index record.
59 @return value of the field */
64 const rec_t* rec, /*!< in: record */
65 const dict_index_t* index, /*!< in: clustered index */
66 const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
70 ut_ad(dict_index_is_clust(index));
71 ut_ad(rec_offs_validate(rec, index, offsets));
73 offset = index->trx_id_offset;
76 offset = row_get_trx_id_offset(index, offsets);
79 return(trx_read_trx_id(rec + offset));
82 /*********************************************************************//**
83 Reads the roll pointer field from a clustered index record.
84 @return value of the field */
89 const rec_t* rec, /*!< in: record */
90 const dict_index_t* index, /*!< in: clustered index */
91 const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
95 ut_ad(dict_index_is_clust(index));
96 ut_ad(rec_offs_validate(rec, index, offsets));
98 offset = index->trx_id_offset;
101 offset = row_get_trx_id_offset(index, offsets);
104 return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN));
107 /*******************************************************************//**
108 Builds from a secondary index record a row reference with which we can
109 search the clustered index record. */
112 row_build_row_ref_fast(
113 /*===================*/
114 dtuple_t* ref, /*!< in/out: typed data tuple where the
115 reference is built */
116 const ulint* map, /*!< in: array of field numbers in rec
117 telling how ref should be built from
119 const rec_t* rec, /*!< in: record in the index; must be
120 preserved while ref is used, as we do
121 not copy field values to heap */
122 const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
131 ut_ad(rec_offs_validate(rec, NULL, offsets));
132 ut_ad(!rec_offs_any_extern(offsets));
133 ref_len = dtuple_get_n_fields(ref);
135 for (i = 0; i < ref_len; i++) {
136 dfield = dtuple_get_nth_field(ref, i);
138 field_no = *(map + i);
140 if (field_no != ULINT_UNDEFINED) {
142 field = rec_get_nth_field(rec, offsets,
144 dfield_set_data(dfield, field, len);