~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

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