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