~drizzle-trunk/drizzle/development

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