~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Eric Herman
  • Date: 2008-12-07 15:29:44 UTC
  • mto: (656.1.14 devel)
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: eric@mysql.com-20081207152944-cq1nx1cyi0huqj0f
Added pointer to online version of the FAQ

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
19
 
/**************************************************//**
20
 
@file include/row0upd.h
 
1
/******************************************************
21
2
Update of a row
22
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
23
6
Created 12/27/1996 Heikki Tuuri
24
7
*******************************************************/
25
8
 
28
11
 
29
12
#include "univ.i"
30
13
#include "data0data.h"
31
 
#include "row0types.h"
32
14
#include "btr0types.h"
 
15
#include "btr0pcur.h"
33
16
#include "dict0types.h"
34
17
#include "trx0types.h"
35
 
 
36
 
#ifndef UNIV_HOTBACKUP
37
 
# include "btr0pcur.h"
38
 
# include "que0types.h"
39
 
# include "pars0types.h"
40
 
#endif /* !UNIV_HOTBACKUP */
41
 
 
42
 
/*********************************************************************//**
43
 
Creates an update vector object.
44
 
@return own: update vector object */
 
18
#include "que0types.h"
 
19
#include "row0types.h"
 
20
#include "pars0types.h"
 
21
 
 
22
/*************************************************************************
 
23
Creates an update vector object. */
45
24
UNIV_INLINE
46
25
upd_t*
47
26
upd_create(
48
27
/*=======*/
49
 
        ulint           n,      /*!< in: number of fields */
50
 
        mem_heap_t*     heap);  /*!< in: heap from which memory allocated */
51
 
/*********************************************************************//**
 
28
                                /* out, own: update vector object */
 
29
        ulint           n,      /* in: number of fields */
 
30
        mem_heap_t*     heap);  /* in: heap from which memory allocated */
 
31
/*************************************************************************
52
32
Returns the number of fields in the update vector == number of columns
53
 
to be updated by an update vector.
54
 
@return number of fields */
 
33
to be updated by an update vector. */
55
34
UNIV_INLINE
56
35
ulint
57
36
upd_get_n_fields(
58
37
/*=============*/
59
 
        const upd_t*    update);        /*!< in: update vector */
 
38
                                        /* out: number of fields */
 
39
        const upd_t*    update);        /* in: update vector */
60
40
#ifdef UNIV_DEBUG
61
 
/*********************************************************************//**
62
 
Returns the nth field of an update vector.
63
 
@return update vector field */
 
41
/*************************************************************************
 
42
Returns the nth field of an update vector. */
64
43
UNIV_INLINE
65
44
upd_field_t*
66
45
upd_get_nth_field(
67
46
/*==============*/
68
 
        const upd_t*    update, /*!< in: update vector */
69
 
        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 */
70
50
#else
71
51
# define upd_get_nth_field(update, n) ((update)->fields + (n))
72
52
#endif
73
 
#ifndef UNIV_HOTBACKUP
74
 
/*********************************************************************//**
 
53
/*************************************************************************
75
54
Sets an index field number to be updated by an update vector field. */
76
55
UNIV_INLINE
77
56
void
78
57
upd_field_set_field_no(
79
58
/*===================*/
80
 
        upd_field_t*    upd_field,      /*!< in: update vector field */
81
 
        ulint           field_no,       /*!< in: field number in a clustered
 
59
        upd_field_t*    upd_field,      /* in: update vector field */
 
60
        ulint           field_no,       /* in: field number in a clustered
82
61
                                        index */
83
 
        dict_index_t*   index,          /*!< in: index */
84
 
        trx_t*          trx);           /*!< in: transaction */
85
 
/*********************************************************************//**
86
 
Returns a field of an update vector by field_no.
87
 
@return update vector field, or NULL */
 
62
        dict_index_t*   index,          /* in: index */
 
63
        trx_t*          trx);           /* in: transaction */
 
64
/*************************************************************************
 
65
Returns a field of an update vector by field_no. */
88
66
UNIV_INLINE
89
67
const upd_field_t*
90
68
upd_get_field_by_field_no(
91
69
/*======================*/
92
 
        const upd_t*    update, /*!< in: update vector */
93
 
        ulint           no)     /*!< in: field_no */
 
70
                                /* out: update vector field, or NULL */
 
71
        const upd_t*    update, /* in: update vector */
 
72
        ulint           no)     /* in: field_no */
94
73
        __attribute__((nonnull, pure));
95
 
/*********************************************************************//**
 
74
/*************************************************************************
96
75
Writes into the redo log the values of trx id and roll ptr and enough info
97
 
to determine their positions within a clustered index record.
98
 
@return new pointer to mlog */
 
76
to determine their positions within a clustered index record. */
99
77
UNIV_INTERN
100
78
byte*
101
79
row_upd_write_sys_vals_to_log(
102
80
/*==========================*/
103
 
        dict_index_t*   index,  /*!< in: clustered index */
104
 
        trx_t*          trx,    /*!< in: transaction */
105
 
        roll_ptr_t      roll_ptr,/*!< in: roll ptr of the undo log record */
106
 
        byte*           log_ptr,/*!< pointer to a buffer of size > 20 opened
 
81
                                /* out: new pointer to mlog */
 
82
        dict_index_t*   index,  /* in: clustered index */
 
83
        trx_t*          trx,    /* in: transaction */
 
84
        dulint          roll_ptr,/* in: roll ptr of the undo log record */
 
85
        byte*           log_ptr,/* pointer to a buffer of size > 20 opened
107
86
                                in mlog */
108
 
        mtr_t*          mtr);   /*!< in: mtr */
109
 
/*********************************************************************//**
 
87
        mtr_t*          mtr);   /* in: mtr */
 
88
/*************************************************************************
110
89
Updates the trx id and roll ptr field in a clustered index record when
111
90
a row is updated or marked deleted. */
112
91
UNIV_INLINE
113
92
void
114
93
row_upd_rec_sys_fields(
115
94
/*===================*/
116
 
        rec_t*          rec,    /*!< in/out: record */
117
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page whose
 
95
        rec_t*          rec,    /* in/out: record */
 
96
        page_zip_des_t* page_zip,/* in/out: compressed page whose
118
97
                                uncompressed part will be updated, or NULL */
119
 
        dict_index_t*   index,  /*!< in: clustered index */
120
 
        const ulint*    offsets,/*!< in: rec_get_offsets(rec, index) */
121
 
        trx_t*          trx,    /*!< in: transaction */
122
 
        roll_ptr_t      roll_ptr);/*!< in: roll ptr of the undo log record */
123
 
/*********************************************************************//**
 
98
        dict_index_t*   index,  /* in: clustered index */
 
99
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
 
100
        trx_t*          trx,    /* in: transaction */
 
101
        dulint          roll_ptr);/* in: roll ptr of the undo log record */
 
102
/*************************************************************************
124
103
Sets the trx id or roll ptr field of a clustered index entry. */
125
104
UNIV_INTERN
126
105
void
127
106
row_upd_index_entry_sys_field(
128
107
/*==========================*/
129
 
        const dtuple_t* entry,  /*!< in: index entry, where the memory buffers
 
108
        const dtuple_t* entry,  /* in: index entry, where the memory buffers
130
109
                                for sys fields are already allocated:
131
110
                                the function just copies the new values to
132
111
                                them */
133
 
        dict_index_t*   index,  /*!< in: clustered index */
134
 
        ulint           type,   /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */
135
 
        dulint          val);   /*!< in: value to write */
136
 
/*********************************************************************//**
137
 
Creates an update node for a query graph.
138
 
@return own: update node */
 
112
        dict_index_t*   index,  /* in: clustered index */
 
113
        ulint           type,   /* in: DATA_TRX_ID or DATA_ROLL_PTR */
 
114
        dulint          val);   /* in: value to write */
 
115
/*************************************************************************
 
116
Creates an update node for a query graph. */
139
117
UNIV_INTERN
140
118
upd_node_t*
141
119
upd_node_create(
142
120
/*============*/
143
 
        mem_heap_t*     heap);  /*!< in: mem heap where created */
144
 
/***********************************************************//**
 
121
                                /* out, own: update node */
 
122
        mem_heap_t*     heap);  /* in: mem heap where created */
 
123
/***************************************************************
145
124
Writes to the redo log the new values of the fields occurring in the index. */
146
125
UNIV_INTERN
147
126
void
148
127
row_upd_index_write_log(
149
128
/*====================*/
150
 
        const upd_t*    update, /*!< in: update vector */
151
 
        byte*           log_ptr,/*!< in: pointer to mlog buffer: must
 
129
        const upd_t*    update, /* in: update vector */
 
130
        byte*           log_ptr,/* in: pointer to mlog buffer: must
152
131
                                contain at least MLOG_BUF_MARGIN bytes
153
132
                                of free space; the buffer is closed
154
133
                                within this function */
155
 
        mtr_t*          mtr);   /*!< in: mtr into whose log to write */
156
 
/***********************************************************//**
 
134
        mtr_t*          mtr);   /* in: mtr into whose log to write */
 
135
/***************************************************************
157
136
Returns TRUE if row update changes size of some field in index or if some
158
 
field to be updated is stored externally in rec or update.
159
 
@return TRUE if the update changes the size of some field in index or
160
 
the field is external in rec or update */
 
137
field to be updated is stored externally in rec or update. */
161
138
UNIV_INTERN
162
139
ibool
163
140
row_upd_changes_field_size_or_external(
164
141
/*===================================*/
165
 
        dict_index_t*   index,  /*!< in: index */
166
 
        const ulint*    offsets,/*!< in: rec_get_offsets(rec, index) */
167
 
        const upd_t*    update);/*!< in: update vector */
168
 
#endif /* !UNIV_HOTBACKUP */
169
 
/***********************************************************//**
 
142
                                /* out: TRUE if the update changes the size of
 
143
                                some field in index or the field is external
 
144
                                in rec or update */
 
145
        dict_index_t*   index,  /* in: index */
 
146
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
 
147
        const upd_t*    update);/* in: update vector */
 
148
/***************************************************************
170
149
Replaces the new column values stored in the update vector to the record
171
150
given. No field size changes are allowed. */
172
151
UNIV_INTERN
173
152
void
174
153
row_upd_rec_in_place(
175
154
/*=================*/
176
 
        rec_t*          rec,    /*!< in/out: record where replaced */
177
 
        dict_index_t*   index,  /*!< in: the index the record belongs to */
178
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
179
 
        const upd_t*    update, /*!< in: update vector */
180
 
        page_zip_des_t* page_zip);/*!< in: compressed page with enough space
 
155
        rec_t*          rec,    /* in/out: record where replaced */
 
156
        dict_index_t*   index,  /* in: the index the record belongs to */
 
157
        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
181
160
                                available, or NULL */
182
 
#ifndef UNIV_HOTBACKUP
183
 
/***************************************************************//**
 
161
/*******************************************************************
184
162
Builds an update vector from those fields which in a secondary index entry
185
163
differ from a record that has the equal ordering fields. NOTE: we compare
186
 
the fields as binary strings!
187
 
@return own: update vector of differing fields */
 
164
the fields as binary strings! */
188
165
UNIV_INTERN
189
166
upd_t*
190
167
row_upd_build_sec_rec_difference_binary(
191
168
/*====================================*/
192
 
        dict_index_t*   index,  /*!< in: index */
193
 
        const dtuple_t* entry,  /*!< in: entry to insert */
194
 
        const rec_t*    rec,    /*!< in: secondary index record */
195
 
        trx_t*          trx,    /*!< in: transaction */
196
 
        mem_heap_t*     heap);  /*!< in: memory heap from which allocated */
197
 
/***************************************************************//**
 
169
                                /* out, own: update vector of differing
 
170
                                fields */
 
171
        dict_index_t*   index,  /* in: index */
 
172
        const dtuple_t* entry,  /* in: entry to insert */
 
173
        const rec_t*    rec,    /* in: secondary index record */
 
174
        trx_t*          trx,    /* in: transaction */
 
175
        mem_heap_t*     heap);  /* in: memory heap from which allocated */
 
176
/*******************************************************************
198
177
Builds an update vector from those fields, excluding the roll ptr and
199
178
trx id fields, which in an index entry differ from a record that has
200
 
the equal ordering fields. NOTE: we compare the fields as binary strings!
201
 
@return own: update vector of differing fields, excluding roll ptr and
202
 
trx id */
 
179
the equal ordering fields. NOTE: we compare the fields as binary strings! */
203
180
UNIV_INTERN
204
181
upd_t*
205
182
row_upd_build_difference_binary(
206
183
/*============================*/
207
 
        dict_index_t*   index,  /*!< in: clustered index */
208
 
        const dtuple_t* entry,  /*!< in: entry to insert */
209
 
        const rec_t*    rec,    /*!< in: clustered index record */
210
 
        trx_t*          trx,    /*!< in: transaction */
211
 
        mem_heap_t*     heap);  /*!< in: memory heap from which allocated */
212
 
/***********************************************************//**
 
184
                                /* out, own: update vector of differing
 
185
                                fields, excluding roll ptr and trx id */
 
186
        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 */
 
189
        trx_t*          trx,    /* in: transaction */
 
190
        mem_heap_t*     heap);  /* in: memory heap from which allocated */
 
191
/***************************************************************
213
192
Replaces the new column values stored in the update vector to the index entry
214
193
given. */
215
194
UNIV_INTERN
216
195
void
217
196
row_upd_index_replace_new_col_vals_index_pos(
218
197
/*=========================================*/
219
 
        dtuple_t*       entry,  /*!< in/out: index entry where replaced;
 
198
        dtuple_t*       entry,  /* in/out: index entry where replaced;
220
199
                                the clustered index record must be
221
200
                                covered by a lock or a page latch to
222
201
                                prevent deletion (rollback or purge) */
223
 
        dict_index_t*   index,  /*!< in: index; NOTE that this may also be a
 
202
        dict_index_t*   index,  /* in: index; NOTE that this may also be a
224
203
                                non-clustered index */
225
 
        const 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
226
205
                                that the field number in an upd_field is the
227
206
                                index position */
228
207
        ibool           order_only,
229
 
                                /*!< in: if TRUE, limit the replacement to
 
208
                                /* in: if TRUE, limit the replacement to
230
209
                                ordering fields of index; note that this
231
210
                                does not work for non-clustered indexes. */
232
 
        mem_heap_t*     heap)   /*!< in: memory heap for allocating and
 
211
        mem_heap_t*     heap)   /* in: memory heap for allocating and
233
212
                                copying the new values */
234
213
        __attribute__((nonnull));
235
 
/***********************************************************//**
 
214
/***************************************************************
236
215
Replaces the new column values stored in the update vector to the index entry
237
216
given. */
238
217
UNIV_INTERN
239
218
void
240
219
row_upd_index_replace_new_col_vals(
241
220
/*===============================*/
242
 
        dtuple_t*       entry,  /*!< in/out: index entry where replaced;
 
221
        dtuple_t*       entry,  /* in/out: index entry where replaced;
243
222
                                the clustered index record must be
244
223
                                covered by a lock or a page latch to
245
224
                                prevent deletion (rollback or purge) */
246
 
        dict_index_t*   index,  /*!< in: index; NOTE that this may also be a
 
225
        dict_index_t*   index,  /* in: index; NOTE that this may also be a
247
226
                                non-clustered index */
248
 
        const upd_t*    update, /*!< in: an update vector built for the
 
227
        const upd_t*    update, /* in: an update vector built for the
249
228
                                CLUSTERED index so that the field number in
250
229
                                an upd_field is the clustered index position */
251
 
        mem_heap_t*     heap)   /*!< in: memory heap for allocating and
 
230
        mem_heap_t*     heap)   /* in: memory heap for allocating and
252
231
                                copying the new values */
253
232
        __attribute__((nonnull));
254
 
/***********************************************************//**
 
233
/***************************************************************
255
234
Replaces the new column values stored in the update vector. */
256
235
UNIV_INTERN
257
236
void
258
237
row_upd_replace(
259
238
/*============*/
260
 
        dtuple_t*               row,    /*!< in/out: row where replaced,
 
239
        dtuple_t*               row,    /* in/out: row where replaced,
261
240
                                        indexed by col_no;
262
241
                                        the clustered index record must be
263
242
                                        covered by a lock or a page latch to
264
243
                                        prevent deletion (rollback or purge) */
265
 
        row_ext_t**             ext,    /*!< out, own: NULL, or externally
 
244
        row_ext_t**             ext,    /* out, own: NULL, or externally
266
245
                                        stored column prefixes */
267
 
        const dict_index_t*     index,  /*!< in: clustered index */
268
 
        const upd_t*            update, /*!< in: an update vector built for the
 
246
        const dict_index_t*     index,  /* in: clustered index */
 
247
        const upd_t*            update, /* in: an update vector built for the
269
248
                                        clustered index */
270
 
        mem_heap_t*             heap);  /*!< in: memory heap */
271
 
/***********************************************************//**
 
249
        mem_heap_t*             heap);  /* in: memory heap */
 
250
/***************************************************************
272
251
Checks if an update vector changes an ordering field of an index record.
273
 
 
274
252
This function is fast if the update vector is short or the number of ordering
275
253
fields in the index is small. Otherwise, this can be quadratic.
276
 
NOTE: we compare the fields as binary strings!
277
 
@return TRUE if update vector changes an ordering field in the index record */
 
254
NOTE: we compare the fields as binary strings! */
278
255
UNIV_INTERN
279
256
ibool
280
257
row_upd_changes_ord_field_binary(
281
258
/*=============================*/
282
 
        const dtuple_t* row,    /*!< in: old value of row, or NULL if the
 
259
                                /* out: TRUE if update vector changes
 
260
                                an ordering field in the index record;
 
261
                                NOTE: the fields are compared as binary
 
262
                                strings */
 
263
        const dtuple_t* row,    /* in: old value of row, or NULL if the
283
264
                                row and the data values in update are not
284
265
                                known when this function is called, e.g., at
285
266
                                compile time */
286
 
        dict_index_t*   index,  /*!< in: index of the record */
287
 
        const upd_t*    update);/*!< in: update vector for the row; NOTE: the
 
267
        dict_index_t*   index,  /* in: index of the record */
 
268
        const upd_t*    update);/* in: update vector for the row; NOTE: the
288
269
                                field numbers in this MUST be clustered index
289
270
                                positions! */
290
 
/***********************************************************//**
 
271
/***************************************************************
291
272
Checks if an update vector changes an ordering field of an index record.
292
273
This function is fast if the update vector is short or the number of ordering
293
274
fields in the index is small. Otherwise, this can be quadratic.
294
 
NOTE: we compare the fields as binary strings!
295
 
@return TRUE if update vector may change an ordering field in an index
296
 
record */
 
275
NOTE: we compare the fields as binary strings! */
297
276
UNIV_INTERN
298
277
ibool
299
278
row_upd_changes_some_index_ord_field_binary(
300
279
/*========================================*/
301
 
        const dict_table_t*     table,  /*!< in: table */
302
 
        const upd_t*            update);/*!< in: update vector for the row */
303
 
/***********************************************************//**
 
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 */
 
285
/***************************************************************
304
286
Updates a row in a table. This is a high-level function used
305
 
in SQL execution graphs.
306
 
@return query thread to run next or NULL */
 
287
in SQL execution graphs. */
307
288
UNIV_INTERN
308
289
que_thr_t*
309
290
row_upd_step(
310
291
/*=========*/
311
 
        que_thr_t*      thr);   /*!< in: query thread */
312
 
#endif /* !UNIV_HOTBACKUP */
313
 
/*********************************************************************//**
314
 
Parses the log data of system field values.
315
 
@return log data end or NULL */
 
292
                                /* out: query thread to run next or NULL */
 
293
        que_thr_t*      thr);   /* in: query thread */
 
294
/*************************************************************************
 
295
Performs an in-place update for the current clustered index record in
 
296
select. */
 
297
UNIV_INTERN
 
298
void
 
299
row_upd_in_place_in_select(
 
300
/*=======================*/
 
301
        sel_node_t*     sel_node,       /* in: select node */
 
302
        que_thr_t*      thr,            /* in: query thread */
 
303
        mtr_t*          mtr);           /* in: mtr */
 
304
/*************************************************************************
 
305
Parses the log data of system field values. */
316
306
UNIV_INTERN
317
307
byte*
318
308
row_upd_parse_sys_vals(
319
309
/*===================*/
320
 
        byte*           ptr,    /*!< in: buffer */
321
 
        byte*           end_ptr,/*!< in: buffer end */
322
 
        ulint*          pos,    /*!< out: TRX_ID position in record */
323
 
        trx_id_t*       trx_id, /*!< out: trx id */
324
 
        roll_ptr_t*     roll_ptr);/*!< out: roll ptr */
325
 
/*********************************************************************//**
 
310
                        /* out: log data end or NULL */
 
311
        byte*   ptr,    /* in: buffer */
 
312
        byte*   end_ptr,/* in: buffer end */
 
313
        ulint*  pos,    /* out: TRX_ID position in record */
 
314
        dulint* trx_id, /* out: trx id */
 
315
        dulint* roll_ptr);/* out: roll ptr */
 
316
/*************************************************************************
326
317
Updates the trx id and roll ptr field in a clustered index record in database
327
318
recovery. */
328
319
UNIV_INTERN
329
320
void
330
321
row_upd_rec_sys_fields_in_recovery(
331
322
/*===============================*/
332
 
        rec_t*          rec,    /*!< in/out: record */
333
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
334
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
335
 
        ulint           pos,    /*!< in: TRX_ID position in rec */
336
 
        trx_id_t        trx_id, /*!< in: transaction id */
337
 
        roll_ptr_t      roll_ptr);/*!< in: roll ptr of the undo log record */
338
 
/*********************************************************************//**
339
 
Parses the log data written by row_upd_index_write_log.
340
 
@return log data end or NULL */
 
323
        rec_t*          rec,    /* in/out: record */
 
324
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
325
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
326
        ulint           pos,    /* in: TRX_ID position in rec */
 
327
        dulint          trx_id, /* in: transaction id */
 
328
        dulint          roll_ptr);/* in: roll ptr of the undo log record */
 
329
/*************************************************************************
 
330
Parses the log data written by row_upd_index_write_log. */
341
331
UNIV_INTERN
342
332
byte*
343
333
row_upd_index_parse(
344
334
/*================*/
345
 
        byte*           ptr,    /*!< in: buffer */
346
 
        byte*           end_ptr,/*!< in: buffer end */
347
 
        mem_heap_t*     heap,   /*!< in: memory heap where update vector is
 
335
                                /* out: log data end or NULL */
 
336
        byte*           ptr,    /* in: buffer */
 
337
        byte*           end_ptr,/* in: buffer end */
 
338
        mem_heap_t*     heap,   /* in: memory heap where update vector is
348
339
                                built */
349
 
        upd_t**         update_out);/*!< out: update vector */
 
340
        upd_t**         update_out);/* out: update vector */
350
341
 
351
342
 
352
343
/* Update vector field */
353
344
struct upd_field_struct{
354
 
        unsigned        field_no:16;    /*!< field number in an index, usually
 
345
        unsigned        field_no:16;    /* field number in an index, usually
355
346
                                        the clustered index, but in updating
356
347
                                        a secondary index record in btr0cur.c
357
348
                                        this is the position in the secondary
358
349
                                        index */
359
 
#ifndef UNIV_HOTBACKUP
360
 
        unsigned        orig_len:16;    /*!< original length of the locally
 
350
        unsigned        orig_len:16;    /* original length of the locally
361
351
                                        stored part of an externally stored
362
352
                                        column, or 0 */
363
 
        que_node_t*     exp;            /*!< expression for calculating a new
 
353
        que_node_t*     exp;            /* expression for calculating a new
364
354
                                        value: it refers to column values and
365
355
                                        constants in the symbol table of the
366
356
                                        query graph */
367
 
#endif /* !UNIV_HOTBACKUP */
368
 
        dfield_t        new_val;        /*!< new value for the column */
 
357
        dfield_t        new_val;        /* new value for the column */
369
358
};
370
359
 
371
360
/* Update vector structure */
372
361
struct upd_struct{
373
 
        ulint           info_bits;      /*!< new value of info bits to record;
 
362
        ulint           info_bits;      /* new value of info bits to record;
374
363
                                        default is 0 */
375
 
        ulint           n_fields;       /*!< number of update fields */
376
 
        upd_field_t*    fields;         /*!< array of update fields */
 
364
        ulint           n_fields;       /* number of update fields */
 
365
        upd_field_t*    fields;         /* array of update fields */
377
366
};
378
367
 
379
 
#ifndef UNIV_HOTBACKUP
380
368
/* Update node structure which also implements the delete operation
381
369
of a row */
382
370
 
383
371
struct upd_node_struct{
384
 
        que_common_t    common; /*!< node type: QUE_NODE_UPDATE */
 
372
        que_common_t    common; /* node type: QUE_NODE_UPDATE */
385
373
        ibool           is_delete;/* TRUE if delete, FALSE if update */
386
374
        ibool           searched_update;
387
375
                                /* TRUE if searched update, FALSE if
388
376
                                positioned */
 
377
        ibool           select_will_do_update;
 
378
                                /* TRUE if a searched update where ordering
 
379
                                fields will not be updated, and the size of
 
380
                                the fields will not change: in this case the
 
381
                                select node will take care of the update */
389
382
        ibool           in_mysql_interface;
390
383
                                /* TRUE if the update node was created
391
384
                                for the MySQL interface */
397
390
                                or ... SET NULL for foreign keys */
398
391
        mem_heap_t*     cascade_heap;/* NULL or a mem heap where the cascade
399
392
                                node is created */
400
 
        sel_node_t*     select; /*!< query graph subtree implementing a base
 
393
        sel_node_t*     select; /* query graph subtree implementing a base
401
394
                                table cursor: the rows returned will be
402
395
                                updated */
403
 
        btr_pcur_t*     pcur;   /*!< persistent cursor placed on the clustered
 
396
        btr_pcur_t*     pcur;   /* persistent cursor placed on the clustered
404
397
                                index record which should be updated or
405
398
                                deleted; the cursor is stored in the graph
406
399
                                of 'select' field above, except in the case
407
400
                                of the MySQL interface */
408
 
        dict_table_t*   table;  /*!< table where updated */
409
 
        upd_t*          update; /*!< update vector for the row */
 
401
        dict_table_t*   table;  /* table where updated */
 
402
        upd_t*          update; /* update vector for the row */
410
403
        ulint           update_n_fields;
411
404
                                /* when this struct is used to implement
412
405
                                a cascade operation for foreign keys, we store
425
418
                                UPD_NODE_NO_SIZE_CHANGE, ORed */
426
419
        /*----------------------*/
427
420
        /* Local storage for this graph node */
428
 
        ulint           state;  /*!< node execution state */
429
 
        dict_index_t*   index;  /*!< NULL, or the next index whose record should
 
421
        ulint           state;  /* node execution state */
 
422
        dict_index_t*   index;  /* NULL, or the next index whose record should
430
423
                                be updated */
431
 
        dtuple_t*       row;    /*!< NULL, or a copy (also fields copied to
 
424
        dtuple_t*       row;    /* NULL, or a copy (also fields copied to
432
425
                                heap) of the row to update; this must be reset
433
426
                                to NULL after a successful update */
434
 
        row_ext_t*      ext;    /*!< NULL, or prefixes of the externally
 
427
        row_ext_t*      ext;    /* NULL, or prefixes of the externally
435
428
                                stored columns in the old row */
436
429
        dtuple_t*       upd_row;/* NULL, or a copy of the updated row */
437
430
        row_ext_t*      upd_ext;/* NULL, or prefixes of the externally
438
431
                                stored columns in upd_row */
439
 
        mem_heap_t*     heap;   /*!< memory heap used as auxiliary storage;
 
432
        mem_heap_t*     heap;   /* memory heap used as auxiliary storage;
440
433
                                this must be emptied after a successful
441
434
                                update */
442
435
        /*----------------------*/
474
467
#define UPD_NODE_NO_SIZE_CHANGE 2       /* no record field size will be
475
468
                                        changed in the update */
476
469
 
477
 
#endif /* !UNIV_HOTBACKUP */
478
 
 
479
470
#ifndef UNIV_NONINL
480
471
#include "row0upd.ic"
481
472
#endif