1
/******************************************************
6
Created 4/20/1996 Heikki Tuuri
7
*******************************************************/
13
#include "data0data.h"
14
#include "dict0types.h"
15
#include "trx0types.h"
16
#include "que0types.h"
18
#include "rem0types.h"
19
#include "read0types.h"
20
#include "btr0types.h"
22
/*************************************************************************
23
Reads the trx id field from a clustered index record. */
28
/* out: value of the field */
29
rec_t* rec, /* in: record */
30
dict_index_t* index); /* in: clustered index */
31
/*************************************************************************
32
Reads the roll pointer field from a clustered index record. */
37
/* out: value of the field */
38
rec_t* rec, /* in: record */
39
dict_index_t* index); /* in: clustered index */
40
/*************************************************************************
41
Writes the trx id field to a clustered index record. */
46
rec_t* rec, /* in: record */
47
dict_index_t* index, /* in: clustered index */
48
dulint trx_id); /* in: value of the field */
49
/*************************************************************************
50
Sets the roll pointer field in a clustered index record. */
55
rec_t* rec, /* in: record */
56
dict_index_t* index, /* in: clustered index */
57
dulint roll_ptr);/* in: value of the field */
58
/*********************************************************************
59
When an insert to a table is performed, this function builds the entry which
60
has to be inserted to an index on the table. */
63
row_build_index_entry(
64
/*==================*/
65
/* out: index entry which should be inserted */
66
dtuple_t* row, /* in: row which should be inserted to the
68
dict_index_t* index, /* in: index on the table */
69
mem_heap_t* heap); /* in: memory heap from which the memory for
70
the index entry is allocated */
71
/*********************************************************************
72
Builds an index entry from a row. */
75
row_build_index_entry_to_tuple(
76
/*===========================*/
77
dtuple_t* entry, /* in/out: index entry; the dtuple must have
78
enough fields for the index! */
79
dtuple_t* row, /* in: row */
80
dict_index_t* index); /* in: index on the table */
81
/***********************************************************************
82
An inverse function to dict_row_build_index_entry. Builds a row from a
83
record in a clustered index. */
88
/* out, own: row built; see the NOTE below! */
89
ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
90
the former copies also the data fields to
91
heap as the latter only places pointers to
92
data fields on the index page, and thus is
94
dict_index_t* index, /* in: clustered index */
95
rec_t* rec, /* in: record in the clustered index;
96
NOTE: in the case ROW_COPY_POINTERS
97
the data fields in the row will point
98
directly into this record, therefore,
99
the buffer page of this record must be
100
at least s-latched and the latch held
101
as long as the row dtuple is used! */
102
mem_heap_t* heap); /* in: memory heap from which the memory
103
needed is allocated */
104
/***********************************************************************
105
An inverse function to dict_row_build_index_entry. Builds a row from a
106
record in a clustered index. */
111
dtuple_t* row, /* in/out: row built; see the NOTE below! */
112
dict_index_t* index, /* in: clustered index */
113
rec_t* rec); /* in: record in the clustered index;
114
NOTE: the data fields in the row will point
115
directly into this record, therefore,
116
the buffer page of this record must be
117
at least s-latched and the latch held
118
as long as the row dtuple is used! */
119
/***********************************************************************
120
Converts an index record to a typed data tuple. */
123
row_rec_to_index_entry(
124
/*===================*/
125
/* out, own: index entry built; see the
127
ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
128
the former copies also the data fields to
129
heap as the latter only places pointers to
130
data fields on the index page */
131
dict_index_t* index, /* in: index */
132
rec_t* rec, /* in: record in the index;
133
NOTE: in the case ROW_COPY_POINTERS
134
the data fields in the row will point
135
directly into this record, therefore,
136
the buffer page of this record must be
137
at least s-latched and the latch held
138
as long as the dtuple is used! */
139
mem_heap_t* heap); /* in: memory heap from which the memory
140
needed is allocated */
141
/***********************************************************************
142
Builds from a secondary index record a row reference with which we can
143
search the clustered index record. */
148
/* out, own: row reference built; see the
150
ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
151
the former copies also the data fields to
152
heap, whereas the latter only places pointers
153
to data fields on the index page */
154
dict_index_t* index, /* in: index */
155
rec_t* rec, /* in: record in the index;
156
NOTE: in the case ROW_COPY_POINTERS
157
the data fields in the row will point
158
directly into this record, therefore,
159
the buffer page of this record must be
160
at least s-latched and the latch held
161
as long as the row reference is used! */
162
mem_heap_t* heap); /* in: memory heap from which the memory
163
needed is allocated */
164
/***********************************************************************
165
Builds from a secondary index record a row reference with which we can
166
search the clustered index record. */
169
row_build_row_ref_in_tuple(
170
/*=======================*/
171
dtuple_t* ref, /* in/out: row reference built; see the
173
dict_index_t* index, /* in: index */
174
rec_t* rec); /* in: record in the index;
175
NOTE: the data fields in ref will point
176
directly into this record, therefore,
177
the buffer page of this record must be
178
at least s-latched and the latch held
179
as long as the row reference is used! */
180
/***********************************************************************
181
From a row build a row reference with which we can search the clustered
185
row_build_row_ref_from_row(
186
/*=======================*/
187
dtuple_t* ref, /* in/out: row reference built; see the
188
NOTE below! ref must have the right number
190
dict_table_t* table, /* in: table */
191
dtuple_t* row); /* in: row
192
NOTE: the data fields in ref will point
193
directly into data of this row */
194
/***********************************************************************
195
Builds from a secondary index record a row reference with which we can
196
search the clustered index record. */
199
row_build_row_ref_fast(
200
/*===================*/
201
dtuple_t* ref, /* in: typed data tuple where the reference
203
ulint* map, /* in: array of field numbers in rec telling
204
how ref should be built from the fields of
206
rec_t* rec); /* in: record in the index; must be preserved
207
while ref is used, as we do not copy field
209
/*******************************************************************
210
Searches the clustered index record for a row, if we have the row
214
row_search_on_row_ref(
215
/*==================*/
216
/* out: TRUE if found */
217
btr_pcur_t* pcur, /* in/out: persistent cursor, which must
218
be closed by the caller */
219
ulint mode, /* in: BTR_MODIFY_LEAF, ... */
220
dict_table_t* table, /* in: table */
221
dtuple_t* ref, /* in: row reference */
222
mtr_t* mtr); /* in: mtr */
223
/*************************************************************************
224
Fetches the clustered index record for a secondary index record. The latches
225
on the secondary index record are preserved. */
230
/* out: record or NULL, if no record found */
231
ulint mode, /* in: BTR_MODIFY_LEAF, ... */
232
rec_t* rec, /* in: record in a secondary index */
233
dict_index_t* index, /* in: secondary index */
234
dict_index_t** clust_index,/* out: clustered index */
235
mtr_t* mtr); /* in: mtr */
236
/*******************************************************************
237
Searches an index record. */
240
row_search_index_entry(
241
/*===================*/
242
/* out: TRUE if found */
243
dict_index_t* index, /* in: index */
244
dtuple_t* entry, /* in: index entry */
245
ulint mode, /* in: BTR_MODIFY_LEAF, ... */
246
btr_pcur_t* pcur, /* in/out: persistent cursor, which must
247
be closed by the caller */
248
mtr_t* mtr); /* in: mtr */
251
#define ROW_COPY_DATA 1
252
#define ROW_COPY_POINTERS 2
254
/* The allowed latching order of index records is the following:
255
(1) a secondary index record ->
256
(2) the clustered index record ->
257
(3) rollback segment data for the clustered index record.
259
No new latches may be obtained while the kernel mutex is reserved.
260
However, the kernel mutex can be reserved while latches are owned. */
263
#include "row0row.ic"