641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
3 |
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
|
|
4 |
||
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.
|
|
8 |
||
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.
|
|
12 |
||
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., 59 Temple
|
|
15 |
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
*****************************************************************************/
|
|
18 |
||
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
19 |
/******************************************************
|
20 |
General row routines
|
|
21 |
||
22 |
Created 4/20/1996 Heikki Tuuri
|
|
23 |
*******************************************************/
|
|
24 |
||
25 |
#include "dict0dict.h" |
|
26 |
#include "rem0rec.h" |
|
27 |
#include "trx0undo.h" |
|
28 |
||
29 |
/*************************************************************************
|
|
30 |
Reads the trx id field from a clustered index record. */
|
|
31 |
UNIV_INLINE |
|
32 |
dulint |
|
33 |
row_get_rec_trx_id(
|
|
34 |
/*===============*/
|
|
35 |
/* out: value of the field */ |
|
36 |
const rec_t* rec, /* in: record */ |
|
37 |
dict_index_t* index, /* in: clustered index */ |
|
38 |
const ulint* offsets)/* in: rec_get_offsets(rec, index) */ |
|
39 |
{
|
|
40 |
ulint offset; |
|
41 |
||
42 |
ut_ad(dict_index_is_clust(index)); |
|
43 |
ut_ad(rec_offs_validate(rec, index, offsets)); |
|
44 |
||
45 |
offset = index->trx_id_offset; |
|
46 |
||
47 |
if (!offset) { |
|
48 |
offset = row_get_trx_id_offset(rec, index, offsets); |
|
49 |
} |
|
50 |
||
51 |
return(trx_read_trx_id(rec + offset)); |
|
52 |
}
|
|
53 |
||
54 |
/*************************************************************************
|
|
55 |
Reads the roll pointer field from a clustered index record. */
|
|
56 |
UNIV_INLINE |
|
57 |
dulint |
|
58 |
row_get_rec_roll_ptr(
|
|
59 |
/*=================*/
|
|
60 |
/* out: value of the field */ |
|
61 |
const rec_t* rec, /* in: record */ |
|
62 |
dict_index_t* index, /* in: clustered index */ |
|
63 |
const ulint* offsets)/* in: rec_get_offsets(rec, index) */ |
|
64 |
{
|
|
65 |
ulint offset; |
|
66 |
||
67 |
ut_ad(dict_index_is_clust(index)); |
|
68 |
ut_ad(rec_offs_validate(rec, index, offsets)); |
|
69 |
||
70 |
offset = index->trx_id_offset; |
|
71 |
||
72 |
if (!offset) { |
|
73 |
offset = row_get_trx_id_offset(rec, index, offsets); |
|
74 |
} |
|
75 |
||
76 |
return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN)); |
|
77 |
}
|
|
78 |
||
79 |
/***********************************************************************
|
|
80 |
Builds from a secondary index record a row reference with which we can
|
|
81 |
search the clustered index record. */
|
|
82 |
UNIV_INLINE |
|
83 |
void |
|
84 |
row_build_row_ref_fast(
|
|
85 |
/*===================*/
|
|
86 |
dtuple_t* ref, /* in/out: typed data tuple where the |
|
87 |
reference is built */
|
|
88 |
const ulint* map, /* in: array of field numbers in rec |
|
89 |
telling how ref should be built from
|
|
90 |
the fields of rec */
|
|
91 |
const rec_t* rec, /* in: record in the index; must be |
|
92 |
preserved while ref is used, as we do
|
|
93 |
not copy field values to heap */
|
|
94 |
const ulint* offsets)/* in: array returned by rec_get_offsets() */ |
|
95 |
{
|
|
96 |
dfield_t* dfield; |
|
97 |
const byte* field; |
|
98 |
ulint len; |
|
99 |
ulint ref_len; |
|
100 |
ulint field_no; |
|
101 |
ulint i; |
|
102 |
||
103 |
ut_ad(rec_offs_validate(rec, NULL, offsets)); |
|
104 |
ut_ad(!rec_offs_any_extern(offsets)); |
|
105 |
ref_len = dtuple_get_n_fields(ref); |
|
106 |
||
107 |
for (i = 0; i < ref_len; i++) { |
|
108 |
dfield = dtuple_get_nth_field(ref, i); |
|
109 |
||
110 |
field_no = *(map + i); |
|
111 |
||
112 |
if (field_no != ULINT_UNDEFINED) { |
|
113 |
||
114 |
field = rec_get_nth_field(rec, offsets, |
|
115 |
field_no, &len); |
|
116 |
dfield_set_data(dfield, field, len); |
|
117 |
} |
|
118 |
} |
|
119 |
}
|