~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
3
Copyright (c) 2000, 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
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/row0mysql.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Interface between Innobase row operations and MySQL.
22
Contains also create table and other data dictionary operations.
23
24
Created 9/17/2000 Heikki Tuuri
25
*******************************************************/
26
27
#ifndef row0mysql_h
28
#define row0mysql_h
29
30
#include "univ.i"
31
#include "data0data.h"
32
#include "que0types.h"
33
#include "dict0types.h"
34
#include "trx0types.h"
35
#include "row0types.h"
36
#include "btr0pcur.h"
37
#include "trx0types.h"
38
39
extern ibool row_rollback_on_timeout;
40
41
typedef struct row_prebuilt_struct row_prebuilt_t;
42
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
43
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
44
Frees the blob heap in prebuilt when no longer needed. */
45
UNIV_INTERN
46
void
47
row_mysql_prebuilt_free_blob_heap(
48
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
49
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct of a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
50
					ha_innobase:: table handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
51
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
52
Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
53
format.
54
@return pointer to the data, we skip the 1 or 2 bytes at the start
55
that are used to store the len */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
56
UNIV_INTERN
57
byte*
58
row_mysql_store_true_var_len(
59
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
60
	byte*	dest,	/*!< in: where to store */
61
	ulint	len,	/*!< in: length, must fit in two bytes */
62
	ulint	lenlen);/*!< in: storage length of len: either 1 or 2 bytes */
63
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
64
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
65
returns a pointer to the data.
66
@return pointer to the data, we skip the 1 or 2 bytes at the start
67
that are used to store the len */
68
UNIV_INTERN
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
69
const byte*
70
row_mysql_read_true_varchar(
71
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
72
	ulint*		len,	/*!< out: variable-length field length */
73
	const byte*	field,	/*!< in: field in the MySQL format */
74
	ulint		lenlen);/*!< in: storage length of len: either 1
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
75
				or 2 bytes */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
76
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
77
Stores a reference to a BLOB in the MySQL format. */
78
UNIV_INTERN
79
void
80
row_mysql_store_blob_ref(
81
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
82
	byte*		dest,	/*!< in: where to store */
83
	ulint		col_len,/*!< in: dest buffer size: determines into
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
84
				how many bytes the BLOB length is stored,
85
				the space for the length may vary from 1
86
				to 4 bytes */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
87
	const void*	data,	/*!< in: BLOB data; if the value to store
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
88
				is SQL NULL this should be NULL pointer */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
89
	ulint		len);	/*!< in: BLOB length; if the value to store
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
90
				is SQL NULL this should be 0; remember
91
				also to set the NULL bit in the MySQL record
92
				header! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
93
/*******************************************************************//**
94
Reads a reference to a BLOB in the MySQL format.
95
@return	pointer to BLOB data */
96
UNIV_INTERN
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
97
const byte*
98
row_mysql_read_blob_ref(
99
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
100
	ulint*		len,		/*!< out: BLOB length */
101
	const byte*	ref,		/*!< in: BLOB reference in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
102
					MySQL format */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
103
	ulint		col_len);	/*!< in: BLOB reference length
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
104
					(not BLOB length) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
105
/**************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
106
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
107
The counterpart of this function is row_sel_field_store_in_mysql_format() in
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
108
row0sel.c.
109
@return	up to which byte we used buf in the conversion */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
110
UNIV_INTERN
111
byte*
112
row_mysql_store_col_in_innobase_format(
113
/*===================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
114
	dfield_t*	dfield,		/*!< in/out: dfield where dtype
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
115
					information must be already set when
116
					this function is called! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
117
	byte*		buf,		/*!< in/out: buffer for a converted
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
118
					integer value; this must be at least
119
					col_len long then! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
120
	ibool		row_format_col,	/*!< TRUE if the mysql_data is from
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
121
					a MySQL row, FALSE if from a MySQL
122
					key value;
123
					in MySQL, a true VARCHAR storage
124
					format differs in a row and in a
125
					key value: in a key value the length
126
					is always stored in 2 bytes! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
127
	const byte*	mysql_data,	/*!< in: MySQL column value, not
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
128
					SQL NULL; NOTE that dfield may also
129
					get a pointer to mysql_data,
130
					therefore do not discard this as long
131
					as dfield is used! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
132
	ulint		col_len,	/*!< in: MySQL column length; NOTE that
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
133
					this is the storage length of the
134
					column in the MySQL format row, not
135
					necessarily the length of the actual
136
					payload data; if the column is a true
137
					VARCHAR then this is irrelevant */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
138
	ulint		comp);		/*!< in: nonzero=compact format */
139
/****************************************************************//**
140
Handles user errors and lock waits detected by the database engine.
141
@return TRUE if it was a lock wait and we should continue running the
142
query thread */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
143
UNIV_INTERN
144
ibool
145
row_mysql_handle_errors(
146
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
147
	ulint*		new_err,/*!< out: possible new error encountered in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
148
				rollback, or the old error which was
149
				during the function entry */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
150
	trx_t*		trx,	/*!< in: transaction */
151
	que_thr_t*	thr,	/*!< in: query thread */
152
	trx_savept_t*	savept);/*!< in: savepoint */
153
/********************************************************************//**
154
Create a prebuilt struct for a MySQL table handle.
155
@return	own: a prebuilt struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
156
UNIV_INTERN
157
row_prebuilt_t*
158
row_create_prebuilt(
159
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
160
	dict_table_t*	table);	/*!< in: Innobase table handle */
161
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
162
Free a prebuilt struct for a MySQL table handle. */
163
UNIV_INTERN
164
void
165
row_prebuilt_free(
166
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
167
	row_prebuilt_t*	prebuilt,	/*!< in, own: prebuilt struct */
168
	ibool		dict_locked);	/*!< in: TRUE=data dictionary locked */
169
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
170
Updates the transaction pointers in query graphs stored in the prebuilt
171
struct. */
172
UNIV_INTERN
173
void
174
row_update_prebuilt_trx(
175
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
176
	row_prebuilt_t*	prebuilt,	/*!< in/out: prebuilt struct
177
					in MySQL handle */
178
	trx_t*		trx);		/*!< in: transaction handle */
179
/*********************************************************************//**
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
180
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
181
UNIV_INTERN
182
void
183
row_unlock_table_autoinc_for_mysql(
184
/*===============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
185
	trx_t*	trx);			/*!< in/out: transaction */
186
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
187
Sets an AUTO_INC type lock on the table mentioned in prebuilt. The
188
AUTO_INC lock gives exclusive access to the auto-inc counter of the
189
table. The lock is reserved only for the duration of an SQL statement.
190
It is not compatible with another AUTO_INC or exclusive lock on the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
191
table.
192
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
193
UNIV_INTERN
194
int
195
row_lock_table_autoinc_for_mysql(
196
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
197
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in the MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
198
					table handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
199
/*********************************************************************//**
200
Sets a table lock on the table mentioned in prebuilt.
201
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
202
UNIV_INTERN
203
int
204
row_lock_table_for_mysql(
205
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
206
	row_prebuilt_t*	prebuilt,	/*!< in: prebuilt struct in the MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
207
					table handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
208
	dict_table_t*	table,		/*!< in: table to lock, or NULL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
209
					if prebuilt->table should be
210
					locked as
211
					prebuilt->select_lock_type */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
212
	ulint		mode);		/*!< in: lock mode of table
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
213
					(ignored if table==NULL) */
214
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
215
/*********************************************************************//**
216
Does an insert for MySQL.
217
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
218
UNIV_INTERN
219
int
220
row_insert_for_mysql(
221
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
222
	byte*		mysql_rec,	/*!< in: row in the MySQL format */
223
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
224
					handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
225
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
226
Builds a dummy query graph used in selects. */
227
UNIV_INTERN
228
void
229
row_prebuild_sel_graph(
230
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
231
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
232
					handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
233
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
234
Gets pointer to a prebuilt update vector used in updates. If the update
235
graph has not yet been built in the prebuilt struct, then this function
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
236
first builds it.
237
@return	prebuilt update vector */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
238
UNIV_INTERN
239
upd_t*
240
row_get_prebuilt_update_vector(
241
/*===========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
242
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
243
					handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
244
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
245
Checks if a table is such that we automatically created a clustered
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
246
index on it (on row id).
247
@return	TRUE if the clustered index was generated automatically */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
248
UNIV_INTERN
249
ibool
250
row_table_got_default_clust_index(
251
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
252
	const dict_table_t*	table);	/*!< in: table */
253
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
254
Calculates the key number used inside MySQL for an Innobase index. We have
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
255
to take into account if we generated a default clustered index for the table
256
@return	the key number used inside MySQL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
257
UNIV_INTERN
258
ulint
259
row_get_mysql_key_number_for_index(
260
/*===============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
261
	const dict_index_t*	index);	/*!< in: index */
262
/*********************************************************************//**
263
Does an update or delete of a row for MySQL.
264
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
265
UNIV_INTERN
266
int
267
row_update_for_mysql(
268
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
269
	byte*		mysql_rec,	/*!< in: the row to be updated, in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
270
					the MySQL format */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
271
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
272
					handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
273
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
274
This can only be used when srv_locks_unsafe_for_binlog is TRUE or
275
session is using a READ COMMITTED isolation level. Before
276
calling this function we must use trx_reset_new_rec_lock_info() and
277
trx_register_new_rec_lock() to store the information which new record locks
278
really were set. This function removes a newly set lock under prebuilt->pcur,
279
and also under prebuilt->clust_pcur. Currently, this is only used and tested
280
in the case of an UPDATE or a DELETE statement, where the row lock is of the
281
LOCK_X type.
282
Thus, this implements a 'mini-rollback' that releases the latest record
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
283
locks we set.
284
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
285
UNIV_INTERN
286
int
287
row_unlock_for_mysql(
288
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
289
	row_prebuilt_t*	prebuilt,	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
290
					handle */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
291
	ibool		has_latches_on_recs);/*!< TRUE if called so that we have
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
292
					the latches on the records under pcur
293
					and clust_pcur, and we do not need to
294
					reposition the cursors. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
295
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
296
Creates an query graph node of 'update' type to be used in the MySQL
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
297
interface.
298
@return	own: update node */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
299
UNIV_INTERN
300
upd_node_t*
301
row_create_update_node_for_mysql(
302
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
303
	dict_table_t*	table,	/*!< in: table to update */
304
	mem_heap_t*	heap);	/*!< in: mem heap from which allocated */
305
/**********************************************************************//**
306
Does a cascaded delete or set null in a foreign key operation.
307
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
308
UNIV_INTERN
309
ulint
310
row_update_cascade_for_mysql(
311
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
312
	que_thr_t*	thr,	/*!< in: query thread */
313
	upd_node_t*	node,	/*!< in: update node used in the cascade
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
314
				or set null operation */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
315
	dict_table_t*	table);	/*!< in: table where we do the operation */
316
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
317
Locks the data dictionary exclusively for performing a table create or other
318
data dictionary modification operation. */
319
UNIV_INTERN
320
void
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
321
row_mysql_lock_data_dictionary_func(
322
/*================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
323
	trx_t*		trx,	/*!< in/out: transaction */
324
	const char*	file,	/*!< in: file name */
325
	ulint		line);	/*!< in: line number */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
326
#define row_mysql_lock_data_dictionary(trx)				\
327
	row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
328
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
329
Unlocks the data dictionary exclusive lock. */
330
UNIV_INTERN
331
void
332
row_mysql_unlock_data_dictionary(
333
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
334
	trx_t*	trx);	/*!< in/out: transaction */
335
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
336
Locks the data dictionary in shared mode from modifications, for performing
337
foreign key check, rollback, or other operation invisible to MySQL. */
338
UNIV_INTERN
339
void
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
340
row_mysql_freeze_data_dictionary_func(
341
/*==================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
342
	trx_t*		trx,	/*!< in/out: transaction */
343
	const char*	file,	/*!< in: file name */
344
	ulint		line);	/*!< in: line number */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
345
#define row_mysql_freeze_data_dictionary(trx)				\
346
	row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
347
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
348
Unlocks the data dictionary shared lock. */
349
UNIV_INTERN
350
void
351
row_mysql_unfreeze_data_dictionary(
352
/*===============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
353
	trx_t*	trx);	/*!< in/out: transaction */
354
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
355
Creates a table for MySQL. If the name of the table ends in
356
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
357
"innodb_table_monitor", then this will also start the printing of monitor
358
output by the master thread. If the table name ends in "innodb_mem_validate",
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
359
InnoDB will try to invoke mem_validate().
360
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
361
UNIV_INTERN
362
int
363
row_create_table_for_mysql(
364
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
365
	dict_table_t*	table,		/*!< in, own: table definition
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
366
					(will be freed) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
367
	trx_t*		trx);		/*!< in: transaction handle */
368
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
369
Does an index creation operation for MySQL. TODO: currently failure
370
to create an index results in dropping the whole table! This is no problem
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
371
currently as all indexes must be created at the same time as the table.
372
@return	error number or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
373
UNIV_INTERN
374
int
375
row_create_index_for_mysql(
376
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
377
	dict_index_t*	index,		/*!< in, own: index definition
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
378
					(will be freed) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
379
	trx_t*		trx,		/*!< in: transaction handle */
380
	const ulint*	field_lengths); /*!< in: if not NULL, must contain
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
381
					dict_index_get_n_fields(index)
382
					actual field lengths for the
383
					index columns, which are
384
					then checked for not being too
385
					large. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
386
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
387
Scans a table create SQL string and adds to the data dictionary
388
the foreign key constraints declared in the string. This function
389
should be called after the indexes for a table have been created.
390
Each foreign key constraint must be accompanied with indexes in
391
bot participating tables. The indexes are allowed to contain more
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
392
fields than mentioned in the constraint.
393
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
394
UNIV_INTERN
395
int
396
row_table_add_foreign_constraints(
397
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
398
	trx_t*		trx,		/*!< in: transaction */
399
	const char*	sql_string,	/*!< in: table create statement where
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
400
					foreign keys are declared like:
401
				FOREIGN KEY (a, b) REFERENCES table2(c, d),
402
					table2 can be written also with the
403
					database name before it: test.table2 */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
404
	const char*	name,		/*!< in: table full name in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
405
					normalized form
406
					database_name/table_name */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
407
	ibool		reject_fks);	/*!< in: if TRUE, fail with error
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
408
					code DB_CANNOT_ADD_CONSTRAINT if
409
					any foreign keys are found. */
410
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
411
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
412
The master thread in srv0srv.c calls this regularly to drop tables which
413
we must drop in background after queries to them have ended. Such lazy
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
414
dropping of tables is needed in ALTER TABLE on Unix.
415
@return	how many tables dropped + remaining tables in list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
416
UNIV_INTERN
417
ulint
418
row_drop_tables_for_mysql_in_background(void);
419
/*=========================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
420
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
421
Get the background drop list length. NOTE: the caller must own the kernel
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
422
mutex!
423
@return	how many tables in list */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
424
UNIV_INTERN
425
ulint
426
row_get_background_drop_list_len_low(void);
427
/*======================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
428
/*********************************************************************//**
429
Truncates a table for MySQL.
430
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
431
UNIV_INTERN
432
int
433
row_truncate_table_for_mysql(
434
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
435
	dict_table_t*	table,	/*!< in: table handle */
436
	trx_t*		trx);	/*!< in: transaction handle */
437
/*********************************************************************//**
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
438
Drops a table for MySQL.  If the name of the dropped table ends in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
439
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
440
"innodb_table_monitor", then this will also stop the printing of monitor
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
441
output by the master thread.  If the data dictionary was not already locked
442
by the transaction, the transaction will be committed.  Otherwise, the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
443
data dictionary will remain locked.
444
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
445
UNIV_INTERN
446
int
447
row_drop_table_for_mysql(
448
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
449
	const char*	name,	/*!< in: table name */
450
	trx_t*		trx,	/*!< in: transaction handle */
451
	ibool		drop_db);/*!< in: TRUE=dropping whole database */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
452
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
453
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
454
Discards the tablespace of a table which stored in an .ibd file. Discarding
455
means that this function deletes the .ibd file and assigns a new table id for
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
456
the table. Also the flag table->ibd_file_missing is set TRUE.
457
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
458
UNIV_INTERN
459
int
460
row_discard_tablespace_for_mysql(
461
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
462
	const char*	name,	/*!< in: table name */
463
	trx_t*		trx);	/*!< in: transaction handle */
464
/*****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
465
Imports a tablespace. The space id in the .ibd file must match the space id
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
466
of the table in the data dictionary.
467
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
468
UNIV_INTERN
469
int
470
row_import_tablespace_for_mysql(
471
/*============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
472
	const char*	name,	/*!< in: table name */
473
	trx_t*		trx);	/*!< in: transaction handle */
474
/*********************************************************************//**
475
Drops a database for MySQL.
476
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
477
UNIV_INTERN
478
int
479
row_drop_database_for_mysql(
480
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
481
	const char*	name,	/*!< in: database name which ends to '/' */
482
	trx_t*		trx);	/*!< in: transaction handle */
483
/*********************************************************************//**
484
Renames a table for MySQL.
485
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
486
UNIV_INTERN
487
ulint
488
row_rename_table_for_mysql(
489
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
490
	const char*	old_name,	/*!< in: old table name */
491
	const char*	new_name,	/*!< in: new table name */
492
	trx_t*		trx,		/*!< in: transaction handle */
493
	ibool		commit);	/*!< in: if TRUE then commit trx */
494
/*********************************************************************//**
495
Checks a table for corruption.
496
@return	DB_ERROR or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
497
UNIV_INTERN
498
ulint
499
row_check_table_for_mysql(
500
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
501
	row_prebuilt_t*	prebuilt);	/*!< in: prebuilt struct in MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
502
					handle */
503
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
504
/*********************************************************************//**
505
Determines if a table is a magic monitor table.
506
@return	TRUE if monitor table */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
507
UNIV_INTERN
508
ibool
509
row_is_magic_monitor_table(
510
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
511
	const char*	table_name);	/*!< in: name of the table, in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
512
					form database/table_name */
513
514
/* A struct describing a place for an individual column in the MySQL
515
row format which is presented to the table handler in ha_innobase.
516
This template struct is used to speed up row transformations between
517
Innobase and MySQL. */
518
519
typedef struct mysql_row_templ_struct mysql_row_templ_t;
520
struct mysql_row_templ_struct {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
521
	ulint	col_no;			/*!< column number of the column */
522
	ulint	rec_field_no;		/*!< field number of the column in an
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
523
					Innobase record in the current index;
524
					not defined if template_type is
525
					ROW_MYSQL_WHOLE_ROW */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
526
	ulint	mysql_col_offset;	/*!< offset of the column in the MySQL
527
					row format */
528
	ulint	mysql_col_len;		/*!< length of the column in the MySQL
529
					row format */
530
	ulint	mysql_null_byte_offset;	/*!< MySQL NULL bit byte offset in a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
531
					MySQL record */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
532
	ulint	mysql_null_bit_mask;	/*!< bit mask to get the NULL bit,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
533
					zero if column cannot be NULL */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
534
	ulint	type;			/*!< column type in Innobase mtype
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
535
					numbers DATA_CHAR... */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
536
	ulint	mysql_type;		/*!< MySQL type code; this is always
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
537
					< 256 */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
538
	ulint	mysql_length_bytes;	/*!< if mysql_type
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
539
					== DATA_MYSQL_TRUE_VARCHAR, this tells
540
					whether we should use 1 or 2 bytes to
541
					store the MySQL true VARCHAR data
542
					length at the start of row in the MySQL
543
					format (NOTE that the MySQL key value
544
					format always uses 2 bytes for the data
545
					len) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
546
	ulint	charset;		/*!< MySQL charset-collation code
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
547
					of the column, or zero */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
548
	ulint	mbminlen;		/*!< minimum length of a char, in bytes,
549
					or zero if not a char type */
550
	ulint	mbmaxlen;		/*!< maximum length of a char, in bytes,
551
					or zero if not a char type */
552
	ulint	is_unsigned;		/*!< if a column type is an integer
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
553
					type and this field is != 0, then
554
					it is an unsigned integer type */
555
};
556
557
#define MYSQL_FETCH_CACHE_SIZE		8
558
/* After fetching this many rows, we start caching them in fetch_cache */
559
#define MYSQL_FETCH_CACHE_THRESHOLD	4
560
561
#define ROW_PREBUILT_ALLOCATED	78540783
562
#define ROW_PREBUILT_FREED	26423527
563
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
564
/** A struct for (sometimes lazily) prebuilt structures in an Innobase table
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
565
handle used within MySQL; these are used to save CPU time. */
566
567
struct row_prebuilt_struct {
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
568
	ulint		magic_n;	/*!< this magic number is set to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
569
					ROW_PREBUILT_ALLOCATED when created,
570
					or ROW_PREBUILT_FREED when the
571
					struct has been freed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
572
	dict_table_t*	table;		/*!< Innobase table handle */
573
	dict_index_t*	index;		/*!< current index for a search, if
574
					any */
575
	trx_t*		trx;		/*!< current transaction handle */
576
	unsigned	sql_stat_start:1;/*!< TRUE when we start processing of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
577
					an SQL statement: we may have to set
578
					an intention lock on the table,
579
					create a consistent read view etc. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
580
	unsigned	mysql_has_locked:1;/*!< this is set TRUE when MySQL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
581
					calls external_lock on this handle
582
					with a lock flag, and set FALSE when
583
					with the F_UNLOCK flag */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
584
	unsigned	clust_index_was_generated:1;
585
					/*!< if the user did not define a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
586
					primary key in MySQL, then Innobase
587
					automatically generated a clustered
588
					index where the ordering column is
589
					the row id: in this case this flag
590
					is set to TRUE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
591
	unsigned	index_usable:1;	/*!< caches the value of
592
					row_merge_is_index_usable(trx,index) */
593
	unsigned	read_just_key:1;/*!< set to 1 when MySQL calls
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
594
					ha_innobase::extra with the
595
					argument HA_EXTRA_KEYREAD; it is enough
596
					to read just columns defined in
597
					the index (i.e., no read of the
598
					clustered index record necessary) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
599
	unsigned	template_type:2;/*!< ROW_MYSQL_WHOLE_ROW,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
600
					ROW_MYSQL_REC_FIELDS,
601
					ROW_MYSQL_DUMMY_TEMPLATE, or
602
					ROW_MYSQL_NO_TEMPLATE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
603
	unsigned	n_template:10;	/*!< number of elements in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
604
					template */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
605
	unsigned	null_bitmap_len:10;/*!< number of bytes in the SQL NULL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
606
					bitmap at the start of a row in the
607
					MySQL format */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
608
	unsigned	need_to_access_clustered:1; /*!< if we are fetching
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
609
					columns through a secondary index
610
					and at least one column is not in
611
					the secondary index, then this is
612
					set to TRUE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
613
	unsigned	templ_contains_blob:1;/*!< TRUE if the template contains
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
614
					BLOB column(s) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
615
	mysql_row_templ_t* mysql_template;/*!< template used to transform
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
616
					rows fast between MySQL and Innobase
617
					formats; memory for this template
618
					is not allocated from 'heap' */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
619
	mem_heap_t*	heap;		/*!< memory heap from which
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
620
					these auxiliary structures are
621
					allocated when needed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
622
	ins_node_t*	ins_node;	/*!< Innobase SQL insert node
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
623
					used to perform inserts
624
					to the table */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
625
	byte*		ins_upd_rec_buff;/*!< buffer for storing data converted
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
626
					to the Innobase format from the MySQL
627
					format */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
628
	const byte*	default_rec;	/*!< the default values of all columns
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
629
					(a "default row") in MySQL format */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
630
	ulint		hint_need_to_fetch_extra_cols;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
631
					/*!< normally this is set to 0; if this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
632
					is set to ROW_RETRIEVE_PRIMARY_KEY,
633
					then we should at least retrieve all
634
					columns in the primary key; if this
635
					is set to ROW_RETRIEVE_ALL_COLS, then
636
					we must retrieve all columns in the
637
					key (if read_just_key == 1), or all
638
					columns in the table */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
639
	upd_node_t*	upd_node;	/*!< Innobase SQL update node used
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
640
					to perform updates and deletes */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
641
	que_fork_t*	ins_graph;	/*!< Innobase SQL query graph used
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
642
					in inserts */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
643
	que_fork_t*	upd_graph;	/*!< Innobase SQL query graph used
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
644
					in updates or deletes */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
645
	btr_pcur_t*	pcur;		/*!< persistent cursor used in selects
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
646
					and updates */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
647
	btr_pcur_t*	clust_pcur;	/*!< persistent cursor used in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
648
					some selects and updates */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
649
	que_fork_t*	sel_graph;	/*!< dummy query graph used in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
650
					selects */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
651
	dtuple_t*	search_tuple;	/*!< prebuilt dtuple used in selects */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
652
	byte		row_id[DATA_ROW_ID_LEN];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
653
					/*!< if the clustered index was
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
654
					generated, the row id of the
655
					last row fetched is stored
656
					here */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
657
	dtuple_t*	clust_ref;	/*!< prebuilt dtuple used in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
658
					sel/upd/del */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
659
	ulint		select_lock_type;/*!< LOCK_NONE, LOCK_S, or LOCK_X */
660
	ulint		stored_select_lock_type;/*!< this field is used to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
661
					remember the original select_lock_type
662
					that was decided in ha_innodb.cc,
663
					::store_lock(), ::external_lock(),
664
					etc. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
665
	ulint		row_read_type;	/*!< ROW_READ_WITH_LOCKS if row locks
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
666
					should be the obtained for records
667
					under an UPDATE or DELETE cursor.
668
					If innodb_locks_unsafe_for_binlog
669
					is TRUE, this can be set to
670
					ROW_READ_TRY_SEMI_CONSISTENT, so that
671
					if the row under an UPDATE or DELETE
672
					cursor was locked by another
673
					transaction, InnoDB will resort
674
					to reading the last committed value
675
					('semi-consistent read').  Then,
676
					this field will be set to
677
					ROW_READ_DID_SEMI_CONSISTENT to
678
					indicate that.	If the row does not
679
					match the WHERE condition, MySQL will
680
					invoke handler::unlock_row() to
681
					clear the flag back to
682
					ROW_READ_TRY_SEMI_CONSISTENT and
683
					to simply skip the row.	 If
684
					the row matches, the next call to
685
					row_search_for_mysql() will lock
686
					the row.
687
					This eliminates lock waits in some
688
					cases; note that this breaks
689
					serializability. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
690
	ulint		new_rec_locks;	/*!< normally 0; if
691
					srv_locks_unsafe_for_binlog is
692
					TRUE or session is using READ
693
					COMMITTED isolation level, in a
694
					cursor search, if we set a new
695
					record lock on an index, this is
696
					incremented; this is used in
697
					releasing the locks under the
698
					cursors if we are performing an
699
					UPDATE and we determine after
700
					retrieving the row that it does
701
					not need to be locked; thus,
702
					these can be used to implement a
703
					'mini-rollback' that releases
704
					the latest record locks */
705
	ulint		mysql_prefix_len;/*!< byte offset of the end of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
706
					the last requested column */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
707
	ulint		mysql_row_len;	/*!< length in bytes of a row in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
708
					MySQL format */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
709
	ulint		n_rows_fetched;	/*!< number of rows fetched after
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
710
					positioning the current cursor */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
711
	ulint		fetch_direction;/*!< ROW_SEL_NEXT or ROW_SEL_PREV */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
712
	byte*		fetch_cache[MYSQL_FETCH_CACHE_SIZE];
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
713
					/*!< a cache for fetched rows if we
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
714
					fetch many rows from the same cursor:
715
					it saves CPU time to fetch them in a
716
					batch; we reserve mysql_row_len
717
					bytes for each such row; these
718
					pointers point 4 bytes past the
719
					allocated mem buf start, because
720
					there is a 4 byte magic number at the
721
					start and at the end */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
722
	ibool		keep_other_fields_on_keyread; /*!< when using fetch
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
723
					cache with HA_EXTRA_KEYREAD, don't
724
					overwrite other fields in mysql row
725
					row buffer.*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
726
	ulint		fetch_cache_first;/*!< position of the first not yet
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
727
					fetched row in fetch_cache */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
728
	ulint		n_fetch_cached;	/*!< number of not yet fetched rows
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
729
					in fetch_cache */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
730
	mem_heap_t*	blob_heap;	/*!< in SELECTS BLOB fields are copied
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
731
					to this heap */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
732
	mem_heap_t*	old_vers_heap;	/*!< memory heap where a previous
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
733
					version is built in consistent read */
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
734
	/*----------------------*/
1114.1.1 by Monty Taylor
Merged InnoDB Plugin 1.0.4
735
	ib_uint64_t	autoinc_last_value;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
736
					/*!< last value of AUTO-INC interval */
1114.1.1 by Monty Taylor
Merged InnoDB Plugin 1.0.4
737
	ib_uint64_t	autoinc_increment;/*!< The increment step of the auto
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
738
					increment column. Value must be
739
					greater than or equal to 1. Required to
740
					calculate the next value */
641.1.5 by Monty Taylor
Merged in innodb plugin 1.0.2
741
	ib_uint64_t	autoinc_offset; /* The offset passed to
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
742
					get_auto_increment() by MySQL. Required
743
					to calculate the next value */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
744
	ulint		autoinc_error;	/*!< The actual error code encountered
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
745
					while trying to init or read the
746
					autoinc value from the table. We
747
					store it here so that we can return
748
					it to MySQL */
749
	/*----------------------*/
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
750
	UT_LIST_NODE_T(row_prebuilt_t)	prebuilts;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
751
					/*!< list node of table->prebuilts */
752
	ulint		magic_n2;	/*!< this should be the same as
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
753
					magic_n */
754
};
755
756
#define ROW_PREBUILT_FETCH_MAGIC_N	465765687
757
758
#define ROW_MYSQL_WHOLE_ROW	0
759
#define ROW_MYSQL_REC_FIELDS	1
760
#define ROW_MYSQL_NO_TEMPLATE	2
761
#define ROW_MYSQL_DUMMY_TEMPLATE 3	/* dummy template used in
762
					row_scan_and_check_index */
763
764
/* Values for hint_need_to_fetch_extra_cols */
765
#define ROW_RETRIEVE_PRIMARY_KEY	1
766
#define ROW_RETRIEVE_ALL_COLS		2
767
768
/* Values for row_read_type */
769
#define ROW_READ_WITH_LOCKS		0
770
#define ROW_READ_TRY_SEMI_CONSISTENT	1
771
#define ROW_READ_DID_SEMI_CONSISTENT	2
772
773
#ifndef UNIV_NONINL
774
#include "row0mysql.ic"
775
#endif
776
777
#endif