mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / row0row.ic
blob831c2339d9624333d97e1d773cdd07733c196992
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
21 General row routines
23 Created 4/20/1996 Heikki Tuuri
24 *******************************************************/
26 #include "dict0dict.h"
27 #include "rem0rec.h"
28 #include "trx0undo.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 */
34 UNIV_INLINE
35 ulint
36 row_get_trx_id_offset(
37 /*==================*/
38         const dict_index_t*     index,  /*!< in: clustered index */
39         const ulint*            offsets)/*!< in: record offsets */
41         ulint   pos;
42         ulint   offset;
43         ulint   len;
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);
54         return(offset);
57 /*********************************************************************//**
58 Reads the trx id field from a clustered index record.
59 @return value of the field */
60 UNIV_INLINE
61 trx_id_t
62 row_get_rec_trx_id(
63 /*===============*/
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) */
68         ulint   offset;
70         ut_ad(dict_index_is_clust(index));
71         ut_ad(rec_offs_validate(rec, index, offsets));
73         offset = index->trx_id_offset;
75         if (!offset) {
76                 offset = row_get_trx_id_offset(index, offsets);
77         }
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 */
85 UNIV_INLINE
86 roll_ptr_t
87 row_get_rec_roll_ptr(
88 /*=================*/
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) */
93         ulint   offset;
95         ut_ad(dict_index_is_clust(index));
96         ut_ad(rec_offs_validate(rec, index, offsets));
98         offset = index->trx_id_offset;
100         if (!offset) {
101                 offset = row_get_trx_id_offset(index, offsets);
102         }
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. */
110 UNIV_INLINE
111 void
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
118                                 the fields of rec */
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() */
124         dfield_t*       dfield;
125         const byte*     field;
126         ulint           len;
127         ulint           ref_len;
128         ulint           field_no;
129         ulint           i;
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,
143                                                   field_no, &len);
144                         dfield_set_data(dfield, field, len);
145                 }
146         }