~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/row0upd.h

Imported InnoDB plugin with changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
ulint
36
36
upd_get_n_fields(
37
37
/*=============*/
38
 
                        /* out: number of fields */
39
 
        upd_t*  update);        /* in: update vector */
 
38
                                        /* out: number of fields */
 
39
        const upd_t*    update);        /* in: update vector */
 
40
#ifdef UNIV_DEBUG
40
41
/*************************************************************************
41
42
Returns the nth field of an update vector. */
42
43
UNIV_INLINE
43
44
upd_field_t*
44
45
upd_get_nth_field(
45
46
/*==============*/
46
 
                        /* out: update vector field */
47
 
        upd_t*  update, /* in: update vector */
48
 
        ulint   n);     /* in: field position in update vector */
 
47
                                /* out: update vector field */
 
48
        const upd_t*    update, /* in: update vector */
 
49
        ulint           n);     /* in: field position in update vector */
 
50
#else
 
51
# define upd_get_nth_field(update, n) ((update)->fields + (n))
 
52
#endif
49
53
/*************************************************************************
50
54
Sets an index field number to be updated by an update vector field. */
51
55
UNIV_INLINE
58
62
        dict_index_t*   index,          /* in: index */
59
63
        trx_t*          trx);           /* in: transaction */
60
64
/*************************************************************************
 
65
Returns a field of an update vector by field_no. */
 
66
UNIV_INLINE
 
67
const upd_field_t*
 
68
upd_get_field_by_field_no(
 
69
/*======================*/
 
70
                                /* out: update vector field, or NULL */
 
71
        const upd_t*    update, /* in: update vector */
 
72
        ulint           no)     /* in: field_no */
 
73
        __attribute__((nonnull, pure));
 
74
/*************************************************************************
61
75
Writes into the redo log the values of trx id and roll ptr and enough info
62
76
to determine their positions within a clustered index record. */
63
 
 
 
77
UNIV_INTERN
64
78
byte*
65
79
row_upd_write_sys_vals_to_log(
66
80
/*==========================*/
78
92
void
79
93
row_upd_rec_sys_fields(
80
94
/*===================*/
81
 
        rec_t*          rec,    /* in: record */
 
95
        rec_t*          rec,    /* in/out: record */
 
96
        page_zip_des_t* page_zip,/* in/out: compressed page whose
 
97
                                uncompressed part will be updated, or NULL */
82
98
        dict_index_t*   index,  /* in: clustered index */
83
99
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
84
100
        trx_t*          trx,    /* in: transaction */
85
101
        dulint          roll_ptr);/* in: roll ptr of the undo log record */
86
102
/*************************************************************************
87
103
Sets the trx id or roll ptr field of a clustered index entry. */
88
 
 
 
104
UNIV_INTERN
89
105
void
90
106
row_upd_index_entry_sys_field(
91
107
/*==========================*/
92
 
        dtuple_t*       entry,  /* in: index entry, where the memory buffers
 
108
        const dtuple_t* entry,  /* in: index entry, where the memory buffers
93
109
                                for sys fields are already allocated:
94
110
                                the function just copies the new values to
95
111
                                them */
98
114
        dulint          val);   /* in: value to write */
99
115
/*************************************************************************
100
116
Creates an update node for a query graph. */
101
 
 
 
117
UNIV_INTERN
102
118
upd_node_t*
103
119
upd_node_create(
104
120
/*============*/
106
122
        mem_heap_t*     heap);  /* in: mem heap where created */
107
123
/***************************************************************
108
124
Writes to the redo log the new values of the fields occurring in the index. */
109
 
 
 
125
UNIV_INTERN
110
126
void
111
127
row_upd_index_write_log(
112
128
/*====================*/
113
 
        upd_t*  update, /* in: update vector */
114
 
        byte*   log_ptr,/* in: pointer to mlog buffer: must contain at least
115
 
                        MLOG_BUF_MARGIN bytes of free space; the buffer is
116
 
                        closed within this function */
117
 
        mtr_t*  mtr);   /* in: mtr into whose log to write */
 
129
        const upd_t*    update, /* in: update vector */
 
130
        byte*           log_ptr,/* in: pointer to mlog buffer: must
 
131
                                contain at least MLOG_BUF_MARGIN bytes
 
132
                                of free space; the buffer is closed
 
133
                                within this function */
 
134
        mtr_t*          mtr);   /* in: mtr into whose log to write */
118
135
/***************************************************************
119
136
Returns TRUE if row update changes size of some field in index or if some
120
137
field to be updated is stored externally in rec or update. */
121
 
 
 
138
UNIV_INTERN
122
139
ibool
123
140
row_upd_changes_field_size_or_external(
124
141
/*===================================*/
127
144
                                in rec or update */
128
145
        dict_index_t*   index,  /* in: index */
129
146
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
130
 
        upd_t*          update);/* in: update vector */
 
147
        const upd_t*    update);/* in: update vector */
131
148
/***************************************************************
132
149
Replaces the new column values stored in the update vector to the record
133
 
given. No field size changes are allowed. This function is used only for
134
 
a clustered index */
135
 
 
 
150
given. No field size changes are allowed. */
 
151
UNIV_INTERN
136
152
void
137
153
row_upd_rec_in_place(
138
154
/*=================*/
139
155
        rec_t*          rec,    /* in/out: record where replaced */
 
156
        dict_index_t*   index,  /* in: the index the record belongs to */
140
157
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
141
 
        upd_t*          update);/* in: update vector */
 
158
        const upd_t*    update, /* in: update vector */
 
159
        page_zip_des_t* page_zip);/* in: compressed page with enough space
 
160
                                available, or NULL */
142
161
/*******************************************************************
143
162
Builds an update vector from those fields which in a secondary index entry
144
163
differ from a record that has the equal ordering fields. NOTE: we compare
145
164
the fields as binary strings! */
146
 
 
 
165
UNIV_INTERN
147
166
upd_t*
148
167
row_upd_build_sec_rec_difference_binary(
149
168
/*====================================*/
150
169
                                /* out, own: update vector of differing
151
170
                                fields */
152
171
        dict_index_t*   index,  /* in: index */
153
 
        dtuple_t*       entry,  /* in: entry to insert */
154
 
        rec_t*          rec,    /* in: secondary index record */
 
172
        const dtuple_t* entry,  /* in: entry to insert */
 
173
        const rec_t*    rec,    /* in: secondary index record */
155
174
        trx_t*          trx,    /* in: transaction */
156
175
        mem_heap_t*     heap);  /* in: memory heap from which allocated */
157
176
/*******************************************************************
158
177
Builds an update vector from those fields, excluding the roll ptr and
159
178
trx id fields, which in an index entry differ from a record that has
160
179
the equal ordering fields. NOTE: we compare the fields as binary strings! */
161
 
 
 
180
UNIV_INTERN
162
181
upd_t*
163
182
row_upd_build_difference_binary(
164
183
/*============================*/
165
184
                                /* out, own: update vector of differing
166
185
                                fields, excluding roll ptr and trx id */
167
186
        dict_index_t*   index,  /* in: clustered index */
168
 
        dtuple_t*       entry,  /* in: entry to insert */
169
 
        ulint*          ext_vec,/* in: array containing field numbers of
170
 
                                externally stored fields in entry, or NULL */
171
 
        ulint           n_ext_vec,/* in: number of fields in ext_vec */
172
 
        rec_t*          rec,    /* in: clustered index record */
 
187
        const dtuple_t* entry,  /* in: entry to insert */
 
188
        const rec_t*    rec,    /* in: clustered index record */
173
189
        trx_t*          trx,    /* in: transaction */
174
190
        mem_heap_t*     heap);  /* in: memory heap from which allocated */
175
191
/***************************************************************
176
192
Replaces the new column values stored in the update vector to the index entry
177
193
given. */
178
 
 
 
194
UNIV_INTERN
179
195
void
180
196
row_upd_index_replace_new_col_vals_index_pos(
181
197
/*=========================================*/
182
 
        dtuple_t*       entry,  /* in/out: index entry where replaced */
 
198
        dtuple_t*       entry,  /* in/out: index entry where replaced;
 
199
                                the clustered index record must be
 
200
                                covered by a lock or a page latch to
 
201
                                prevent deletion (rollback or purge) */
183
202
        dict_index_t*   index,  /* in: index; NOTE that this may also be a
184
203
                                non-clustered index */
185
 
        upd_t*          update, /* in: an update vector built for the index so
 
204
        const upd_t*    update, /* in: an update vector built for the index so
186
205
                                that the field number in an upd_field is the
187
206
                                index position */
188
207
        ibool           order_only,
189
208
                                /* in: if TRUE, limit the replacement to
190
209
                                ordering fields of index; note that this
191
210
                                does not work for non-clustered indexes. */
192
 
        mem_heap_t*     heap);  /* in: memory heap to which we allocate and
193
 
                                copy the new values, set this as NULL if you
194
 
                                do not want allocation */
 
211
        mem_heap_t*     heap)   /* in: memory heap for allocating and
 
212
                                copying the new values */
 
213
        __attribute__((nonnull));
195
214
/***************************************************************
196
215
Replaces the new column values stored in the update vector to the index entry
197
216
given. */
198
 
 
 
217
UNIV_INTERN
199
218
void
200
219
row_upd_index_replace_new_col_vals(
201
220
/*===============================*/
202
 
        dtuple_t*       entry,  /* in/out: index entry where replaced */
 
221
        dtuple_t*       entry,  /* in/out: index entry where replaced;
 
222
                                the clustered index record must be
 
223
                                covered by a lock or a page latch to
 
224
                                prevent deletion (rollback or purge) */
203
225
        dict_index_t*   index,  /* in: index; NOTE that this may also be a
204
226
                                non-clustered index */
205
 
        upd_t*          update, /* in: an update vector built for the
 
227
        const upd_t*    update, /* in: an update vector built for the
206
228
                                CLUSTERED index so that the field number in
207
229
                                an upd_field is the clustered index position */
208
 
        mem_heap_t*     heap);  /* in: memory heap to which we allocate and
209
 
                                copy the new values, set this as NULL if you
210
 
                                do not want allocation */
 
230
        mem_heap_t*     heap)   /* in: memory heap for allocating and
 
231
                                copying the new values */
 
232
        __attribute__((nonnull));
 
233
/***************************************************************
 
234
Replaces the new column values stored in the update vector. */
 
235
UNIV_INTERN
 
236
void
 
237
row_upd_replace(
 
238
/*============*/
 
239
        dtuple_t*               row,    /* in/out: row where replaced,
 
240
                                        indexed by col_no;
 
241
                                        the clustered index record must be
 
242
                                        covered by a lock or a page latch to
 
243
                                        prevent deletion (rollback or purge) */
 
244
        row_ext_t**             ext,    /* out, own: NULL, or externally
 
245
                                        stored column prefixes */
 
246
        const dict_index_t*     index,  /* in: clustered index */
 
247
        const upd_t*            update, /* in: an update vector built for the
 
248
                                        clustered index */
 
249
        mem_heap_t*             heap);  /* in: memory heap */
211
250
/***************************************************************
212
251
Checks if an update vector changes an ordering field of an index record.
213
252
This function is fast if the update vector is short or the number of ordering
214
253
fields in the index is small. Otherwise, this can be quadratic.
215
254
NOTE: we compare the fields as binary strings! */
216
 
 
 
255
UNIV_INTERN
217
256
ibool
218
257
row_upd_changes_ord_field_binary(
219
258
/*=============================*/
221
260
                                an ordering field in the index record;
222
261
                                NOTE: the fields are compared as binary
223
262
                                strings */
224
 
        dtuple_t*       row,    /* in: old value of row, or NULL if the
 
263
        const dtuple_t* row,    /* in: old value of row, or NULL if the
225
264
                                row and the data values in update are not
226
265
                                known when this function is called, e.g., at
227
266
                                compile time */
228
267
        dict_index_t*   index,  /* in: index of the record */
229
 
        upd_t*          update);/* in: update vector for the row; NOTE: the
 
268
        const upd_t*    update);/* in: update vector for the row; NOTE: the
230
269
                                field numbers in this MUST be clustered index
231
270
                                positions! */
232
271
/***************************************************************
234
273
This function is fast if the update vector is short or the number of ordering
235
274
fields in the index is small. Otherwise, this can be quadratic.
236
275
NOTE: we compare the fields as binary strings! */
237
 
 
 
276
UNIV_INTERN
238
277
ibool
239
278
row_upd_changes_some_index_ord_field_binary(
240
279
/*========================================*/
241
 
                                /* out: TRUE if update vector may change
242
 
                                an ordering field in an index record */
243
 
        dict_table_t*   table,  /* in: table */
244
 
        upd_t*          update);/* in: update vector for the row */
 
280
                                        /* out: TRUE if update vector
 
281
                                        may change an ordering field
 
282
                                        in an index record */
 
283
        const dict_table_t*     table,  /* in: table */
 
284
        const upd_t*            update);/* in: update vector for the row */
245
285
/***************************************************************
246
286
Updates a row in a table. This is a high-level function used
247
287
in SQL execution graphs. */
248
 
 
 
288
UNIV_INTERN
249
289
que_thr_t*
250
290
row_upd_step(
251
291
/*=========*/
254
294
/*************************************************************************
255
295
Performs an in-place update for the current clustered index record in
256
296
select. */
257
 
 
 
297
UNIV_INTERN
258
298
void
259
299
row_upd_in_place_in_select(
260
300
/*=======================*/
263
303
        mtr_t*          mtr);           /* in: mtr */
264
304
/*************************************************************************
265
305
Parses the log data of system field values. */
266
 
 
 
306
UNIV_INTERN
267
307
byte*
268
308
row_upd_parse_sys_vals(
269
309
/*===================*/
276
316
/*************************************************************************
277
317
Updates the trx id and roll ptr field in a clustered index record in database
278
318
recovery. */
279
 
 
 
319
UNIV_INTERN
280
320
void
281
321
row_upd_rec_sys_fields_in_recovery(
282
322
/*===============================*/
283
 
        rec_t*          rec,    /* in: record */
 
323
        rec_t*          rec,    /* in/out: record */
 
324
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
284
325
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
285
326
        ulint           pos,    /* in: TRX_ID position in rec */
286
327
        dulint          trx_id, /* in: transaction id */
287
328
        dulint          roll_ptr);/* in: roll ptr of the undo log record */
288
329
/*************************************************************************
289
330
Parses the log data written by row_upd_index_write_log. */
290
 
 
 
331
UNIV_INTERN
291
332
byte*
292
333
row_upd_index_parse(
293
334
/*================*/
301
342
 
302
343
/* Update vector field */
303
344
struct upd_field_struct{
304
 
        ulint           field_no;       /* field number in an index, usually
 
345
        unsigned        field_no:16;    /* field number in an index, usually
305
346
                                        the clustered index, but in updating
306
347
                                        a secondary index record in btr0cur.c
307
348
                                        this is the position in the secondary
308
349
                                        index */
 
350
        unsigned        orig_len:16;    /* original length of the locally
 
351
                                        stored part of an externally stored
 
352
                                        column, or 0 */
309
353
        que_node_t*     exp;            /* expression for calculating a new
310
354
                                        value: it refers to column values and
311
355
                                        constants in the symbol table of the
312
356
                                        query graph */
313
357
        dfield_t        new_val;        /* new value for the column */
314
 
        ibool           extern_storage; /* this is set to TRUE if dfield
315
 
                                        actually contains a reference to
316
 
                                        an externally stored field */
317
358
};
318
359
 
319
360
/* Update vector structure */
383
424
        dtuple_t*       row;    /* NULL, or a copy (also fields copied to
384
425
                                heap) of the row to update; this must be reset
385
426
                                to NULL after a successful update */
386
 
        ulint*          ext_vec;/* array describing which fields are stored
387
 
                                externally in the clustered index record of
388
 
                                row */
389
 
        ulint           n_ext_vec;/* number of fields in ext_vec */
 
427
        row_ext_t*      ext;    /* NULL, or prefixes of the externally
 
428
                                stored columns in the old row */
 
429
        dtuple_t*       upd_row;/* NULL, or a copy of the updated row */
 
430
        row_ext_t*      upd_ext;/* NULL, or prefixes of the externally
 
431
                                stored columns in upd_row */
390
432
        mem_heap_t*     heap;   /* memory heap used as auxiliary storage;
391
433
                                this must be emptied after a successful
392
434
                                update */