1
/*****************************************************************************
3
Copyright (c) 2000, 2009, Innobase Oy. All Rights Reserved.
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.
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.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/******************************************************
20
Interface between Innobase row operations and MySQL.
21
Contains also create table and other data dictionary operations.
23
Created 9/17/2000 Heikki Tuuri
24
*******************************************************/
30
#include "data0data.h"
31
#include "que0types.h"
32
#include "dict0types.h"
33
#include "trx0types.h"
34
#include "row0types.h"
36
#include "trx0types.h"
38
extern ibool row_rollback_on_timeout;
40
typedef struct row_prebuilt_struct row_prebuilt_t;
42
/***********************************************************************
43
Frees the blob heap in prebuilt when no longer needed. */
46
row_mysql_prebuilt_free_blob_heap(
47
/*==============================*/
48
row_prebuilt_t* prebuilt); /* in: prebuilt struct of a
49
ha_innobase:: table handle */
50
/***********************************************************************
51
Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row
55
row_mysql_store_true_var_len(
56
/*=========================*/
57
/* out: pointer to the data, we skip the 1 or 2 bytes
58
at the start that are used to store the len */
59
byte* dest, /* in: where to store */
60
ulint len, /* in: length, must fit in two bytes */
61
ulint lenlen);/* in: storage length of len: either 1 or 2 bytes */
62
/***********************************************************************
63
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
64
returns a pointer to the data. */
67
row_mysql_read_true_varchar(
68
/*========================*/
69
/* out: pointer to the data, we skip
70
the 1 or 2 bytes at the start that are
71
used to store the len */
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
76
/***********************************************************************
77
Stores a reference to a BLOB in the MySQL format. */
80
row_mysql_store_blob_ref(
81
/*=====================*/
82
byte* dest, /* in: where to store */
83
ulint col_len,/* in: dest buffer size: determines into
84
how many bytes the BLOB length is stored,
85
the space for the length may vary from 1
87
const void* data, /* in: BLOB data; if the value to store
88
is SQL NULL this should be NULL pointer */
89
ulint len); /* in: BLOB length; if the value to store
90
is SQL NULL this should be 0; remember
91
also to set the NULL bit in the MySQL record
93
/***********************************************************************
94
Reads a reference to a BLOB in the MySQL format. */
97
row_mysql_read_blob_ref(
98
/*====================*/
99
/* out: pointer to BLOB data */
100
ulint* len, /* out: BLOB length */
101
const byte* ref, /* in: BLOB reference in the
103
ulint col_len); /* in: BLOB reference length
105
/******************************************************************
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
111
row_mysql_store_col_in_innobase_format(
112
/*===================================*/
113
/* out: up to which byte we used
114
buf in the conversion */
115
dfield_t* dfield, /* in/out: dfield where dtype
116
information must be already set when
117
this function is called! */
118
byte* buf, /* in/out: buffer for a converted
119
integer value; this must be at least
120
col_len long then! */
121
ibool row_format_col, /* TRUE if the mysql_data is from
122
a MySQL row, FALSE if from a MySQL
124
in MySQL, a true VARCHAR storage
125
format differs in a row and in a
126
key value: in a key value the length
127
is always stored in 2 bytes! */
128
const byte* mysql_data, /* in: MySQL column value, not
129
SQL NULL; NOTE that dfield may also
130
get a pointer to mysql_data,
131
therefore do not discard this as long
132
as dfield is used! */
133
ulint col_len, /* in: MySQL column length; NOTE that
134
this is the storage length of the
135
column in the MySQL format row, not
136
necessarily the length of the actual
137
payload data; if the column is a true
138
VARCHAR then this is irrelevant */
139
ulint comp); /* in: nonzero=compact format */
140
/********************************************************************
141
Handles user errors and lock waits detected by the database engine. */
144
row_mysql_handle_errors(
145
/*====================*/
146
/* out: TRUE if it was a lock wait and
147
we should continue running the query thread */
148
ulint* new_err,/* out: possible new error encountered in
149
rollback, or the old error which was
150
during the function entry */
151
trx_t* trx, /* in: transaction */
152
que_thr_t* thr, /* in: query thread */
153
trx_savept_t* savept);/* in: savepoint */
154
/************************************************************************
155
Create a prebuilt struct for a MySQL table handle. */
160
/* out, own: a prebuilt struct */
161
dict_table_t* table); /* in: Innobase table handle */
162
/************************************************************************
163
Free a prebuilt struct for a MySQL table handle. */
168
row_prebuilt_t* prebuilt, /* in, own: prebuilt struct */
169
ibool dict_locked); /* in: TRUE=data dictionary locked */
170
/*************************************************************************
171
Updates the transaction pointers in query graphs stored in the prebuilt
175
row_update_prebuilt_trx(
176
/*====================*/
177
/* out: prebuilt dtuple */
178
row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL
180
trx_t* trx); /* in: transaction handle */
181
/*************************************************************************
182
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */
185
row_unlock_table_autoinc_for_mysql(
186
/*===============================*/
187
trx_t* trx); /* in/out: transaction */
188
/*************************************************************************
189
Sets an AUTO_INC type lock on the table mentioned in prebuilt. The
190
AUTO_INC lock gives exclusive access to the auto-inc counter of the
191
table. The lock is reserved only for the duration of an SQL statement.
192
It is not compatible with another AUTO_INC or exclusive lock on the
196
row_lock_table_autoinc_for_mysql(
197
/*=============================*/
198
/* out: error code or DB_SUCCESS */
199
row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL
201
/*************************************************************************
202
Sets a table lock on the table mentioned in prebuilt. */
205
row_lock_table_for_mysql(
206
/*=====================*/
207
/* out: error code or DB_SUCCESS */
208
row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL
210
dict_table_t* table, /* in: table to lock, or NULL
211
if prebuilt->table should be
213
prebuilt->select_lock_type */
214
ulint mode); /* in: lock mode of table
215
(ignored if table==NULL) */
217
/*************************************************************************
218
Does an insert for MySQL. */
221
row_insert_for_mysql(
222
/*=================*/
223
/* out: error code or DB_SUCCESS */
224
byte* mysql_rec, /* in: row in the MySQL format */
225
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
227
/*************************************************************************
228
Builds a dummy query graph used in selects. */
231
row_prebuild_sel_graph(
232
/*===================*/
233
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
235
/*************************************************************************
236
Gets pointer to a prebuilt update vector used in updates. If the update
237
graph has not yet been built in the prebuilt struct, then this function
241
row_get_prebuilt_update_vector(
242
/*===========================*/
243
/* out: prebuilt update vector */
244
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
246
/*************************************************************************
247
Checks if a table is such that we automatically created a clustered
248
index on it (on row id). */
251
row_table_got_default_clust_index(
252
/*==============================*/
253
const dict_table_t* table);
254
/*************************************************************************
255
Calculates the key number used inside MySQL for an Innobase index. We have
256
to take into account if we generated a default clustered index for the table */
259
row_get_mysql_key_number_for_index(
260
/*===============================*/
261
const dict_index_t* index);
262
/*************************************************************************
263
Does an update or delete of a row for MySQL. */
266
row_update_for_mysql(
267
/*=================*/
268
/* out: error code or DB_SUCCESS */
269
byte* mysql_rec, /* in: the row to be updated, in
271
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
273
/*************************************************************************
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
282
Thus, this implements a 'mini-rollback' that releases the latest record
286
row_unlock_for_mysql(
287
/*=================*/
288
/* out: error code or DB_SUCCESS */
289
row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL
291
ibool has_latches_on_recs);/* TRUE if called so that we have
292
the latches on the records under pcur
293
and clust_pcur, and we do not need to
294
reposition the cursors. */
295
/*************************************************************************
296
Creates an query graph node of 'update' type to be used in the MySQL
300
row_create_update_node_for_mysql(
301
/*=============================*/
302
/* out, own: update node */
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. */
309
row_update_cascade_for_mysql(
310
/*=========================*/
311
/* out: error code or DB_SUCCESS */
312
que_thr_t* thr, /* in: query thread */
313
upd_node_t* node, /* in: update node used in the cascade
314
or set null operation */
315
dict_table_t* table); /* in: table where we do the operation */
316
/*************************************************************************
317
Locks the data dictionary exclusively for performing a table create or other
318
data dictionary modification operation. */
321
row_mysql_lock_data_dictionary_func(
322
/*================================*/
323
trx_t* trx, /* in/out: transaction */
324
const char* file, /* in: file name */
325
ulint line); /* in: line number */
326
#define row_mysql_lock_data_dictionary(trx) \
327
row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
328
/*************************************************************************
329
Unlocks the data dictionary exclusive lock. */
332
row_mysql_unlock_data_dictionary(
333
/*=============================*/
334
trx_t* trx); /* in/out: transaction */
335
/*************************************************************************
336
Locks the data dictionary in shared mode from modifications, for performing
337
foreign key check, rollback, or other operation invisible to MySQL. */
340
row_mysql_freeze_data_dictionary_func(
341
/*==================================*/
342
trx_t* trx, /* in/out: transaction */
343
const char* file, /* in: file name */
344
ulint line); /* in: line number */
345
#define row_mysql_freeze_data_dictionary(trx) \
346
row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
347
/*************************************************************************
348
Unlocks the data dictionary shared lock. */
351
row_mysql_unfreeze_data_dictionary(
352
/*===============================*/
353
trx_t* trx); /* in/out: transaction */
354
#ifndef UNIV_HOTBACKUP
355
/*************************************************************************
356
Creates a table for MySQL. If the name of the table ends in
357
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
358
"innodb_table_monitor", then this will also start the printing of monitor
359
output by the master thread. If the table name ends in "innodb_mem_validate",
360
InnoDB will try to invoke mem_validate(). */
363
row_create_table_for_mysql(
364
/*=======================*/
365
/* out: error code or DB_SUCCESS */
366
dict_table_t* table, /* in, own: table definition
368
trx_t* trx); /* in: transaction handle */
369
/*************************************************************************
370
Does an index creation operation for MySQL. TODO: currently failure
371
to create an index results in dropping the whole table! This is no problem
372
currently as all indexes must be created at the same time as the table. */
375
row_create_index_for_mysql(
376
/*=======================*/
377
/* out: error number or DB_SUCCESS */
378
dict_index_t* index, /* in, own: index definition
380
trx_t* trx, /* in: transaction handle */
381
const ulint* field_lengths); /* in: if not NULL, must contain
382
dict_index_get_n_fields(index)
383
actual field lengths for the
384
index columns, which are
385
then checked for not being too
387
/*************************************************************************
388
Scans a table create SQL string and adds to the data dictionary
389
the foreign key constraints declared in the string. This function
390
should be called after the indexes for a table have been created.
391
Each foreign key constraint must be accompanied with indexes in
392
bot participating tables. The indexes are allowed to contain more
393
fields than mentioned in the constraint. */
396
row_table_add_foreign_constraints(
397
/*==============================*/
398
/* out: error code or DB_SUCCESS */
399
trx_t* trx, /* in: transaction */
400
const char* sql_string, /* in: table create statement where
401
foreign keys are declared like:
402
FOREIGN KEY (a, b) REFERENCES table2(c, d),
403
table2 can be written also with the
404
database name before it: test.table2 */
405
const char* name, /* in: table full name in the
407
database_name/table_name */
408
ibool reject_fks); /* in: if TRUE, fail with error
409
code DB_CANNOT_ADD_CONSTRAINT if
410
any foreign keys are found. */
412
/*************************************************************************
413
The master thread in srv0srv.c calls this regularly to drop tables which
414
we must drop in background after queries to them have ended. Such lazy
415
dropping of tables is needed in ALTER TABLE on Unix. */
418
row_drop_tables_for_mysql_in_background(void);
419
/*=========================================*/
420
/* out: how many tables dropped
421
+ remaining tables in list */
422
/*************************************************************************
423
Get the background drop list length. NOTE: the caller must own the kernel
427
row_get_background_drop_list_len_low(void);
428
/*======================================*/
429
/* out: how many tables in list */
430
/*************************************************************************
431
Truncates a table for MySQL. */
434
row_truncate_table_for_mysql(
435
/*=========================*/
436
/* out: error code or DB_SUCCESS */
437
dict_table_t* table, /* in: table handle */
438
trx_t* trx); /* in: transaction handle */
439
/*************************************************************************
440
Drops a table for MySQL. If the name of the dropped table ends in
441
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
442
"innodb_table_monitor", then this will also stop the printing of monitor
443
output by the master thread. If the data dictionary was not already locked
444
by the transaction, the transaction will be committed. Otherwise, the
445
data dictionary will remain locked. */
448
row_drop_table_for_mysql(
449
/*=====================*/
450
/* out: error code or DB_SUCCESS */
451
const char* name, /* in: table name */
452
trx_t* trx, /* in: transaction handle */
453
ibool drop_db);/* in: TRUE=dropping whole database */
455
/*************************************************************************
456
Discards the tablespace of a table which stored in an .ibd file. Discarding
457
means that this function deletes the .ibd file and assigns a new table id for
458
the table. Also the flag table->ibd_file_missing is set TRUE. */
461
row_discard_tablespace_for_mysql(
462
/*=============================*/
463
/* out: error code or DB_SUCCESS */
464
const char* name, /* in: table name */
465
trx_t* trx); /* in: transaction handle */
466
/*********************************************************************
467
Imports a tablespace. The space id in the .ibd file must match the space id
468
of the table in the data dictionary. */
471
row_import_tablespace_for_mysql(
472
/*============================*/
473
/* out: error code or DB_SUCCESS */
474
const char* name, /* in: table name */
475
trx_t* trx); /* in: transaction handle */
476
/*************************************************************************
477
Drops a database for MySQL. */
480
row_drop_database_for_mysql(
481
/*========================*/
482
/* out: error code or DB_SUCCESS */
483
const char* name, /* in: database name which ends to '/' */
484
trx_t* trx); /* in: transaction handle */
485
/*************************************************************************
486
Renames a table for MySQL. */
489
row_rename_table_for_mysql(
490
/*=======================*/
491
/* out: error code or DB_SUCCESS */
492
const char* old_name, /* in: old table name */
493
const char* new_name, /* in: new table name */
494
trx_t* trx, /* in: transaction handle */
495
ibool commit); /* in: if TRUE then commit trx */
496
/*************************************************************************
497
Checks a table for corruption. */
500
row_check_table_for_mysql(
501
/*======================*/
502
/* out: DB_ERROR or DB_SUCCESS */
503
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
505
#endif /* !UNIV_HOTBACKUP */
507
/*************************************************************************
508
Determines if a table is a magic monitor table. */
511
row_is_magic_monitor_table(
512
/*=======================*/
513
/* out: TRUE if monitor table */
514
const char* table_name); /* in: name of the table, in the
515
form database/table_name */
517
/* A struct describing a place for an individual column in the MySQL
518
row format which is presented to the table handler in ha_innobase.
519
This template struct is used to speed up row transformations between
520
Innobase and MySQL. */
522
typedef struct mysql_row_templ_struct mysql_row_templ_t;
523
struct mysql_row_templ_struct {
524
ulint col_no; /* column number of the column */
525
ulint rec_field_no; /* field number of the column in an
526
Innobase record in the current index;
527
not defined if template_type is
528
ROW_MYSQL_WHOLE_ROW */
529
ulint mysql_col_offset; /* offset of the column in the MySQL
531
ulint mysql_col_len; /* length of the column in the MySQL
533
ulint mysql_null_byte_offset; /* MySQL NULL bit byte offset in a
535
ulint mysql_null_bit_mask; /* bit mask to get the NULL bit,
536
zero if column cannot be NULL */
537
ulint type; /* column type in Innobase mtype
538
numbers DATA_CHAR... */
539
ulint mysql_type; /* MySQL type code; this is always
541
ulint mysql_length_bytes; /* if mysql_type
542
== DATA_MYSQL_TRUE_VARCHAR, this tells
543
whether we should use 1 or 2 bytes to
544
store the MySQL true VARCHAR data
545
length at the start of row in the MySQL
546
format (NOTE that the MySQL key value
547
format always uses 2 bytes for the data
549
ulint charset; /* MySQL charset-collation code
550
of the column, or zero */
551
ulint mbminlen; /* minimum length of a char, in bytes,
552
or zero if not a char type */
553
ulint mbmaxlen; /* maximum length of a char, in bytes,
554
or zero if not a char type */
555
ulint is_unsigned; /* if a column type is an integer
556
type and this field is != 0, then
557
it is an unsigned integer type */
560
#define MYSQL_FETCH_CACHE_SIZE 8
561
/* After fetching this many rows, we start caching them in fetch_cache */
562
#define MYSQL_FETCH_CACHE_THRESHOLD 4
564
#define ROW_PREBUILT_ALLOCATED 78540783
565
#define ROW_PREBUILT_FREED 26423527
567
typedef int64_t (*index_cond_func_t)(void *param);
569
/* A struct for (sometimes lazily) prebuilt structures in an Innobase table
570
handle used within MySQL; these are used to save CPU time. */
572
struct row_prebuilt_struct {
573
ulint magic_n; /* this magic number is set to
574
ROW_PREBUILT_ALLOCATED when created,
575
or ROW_PREBUILT_FREED when the
576
struct has been freed */
577
dict_table_t* table; /* Innobase table handle */
578
trx_t* trx; /* current transaction handle */
579
ibool sql_stat_start; /* TRUE when we start processing of
580
an SQL statement: we may have to set
581
an intention lock on the table,
582
create a consistent read view etc. */
583
ibool mysql_has_locked; /* this is set TRUE when MySQL
584
calls external_lock on this handle
585
with a lock flag, and set FALSE when
586
with the F_UNLOCK flag */
587
ibool clust_index_was_generated;
588
/* if the user did not define a
589
primary key in MySQL, then Innobase
590
automatically generated a clustered
591
index where the ordering column is
592
the row id: in this case this flag
594
dict_index_t* index; /* current index for a search, if
596
ulint read_just_key; /* set to 1 when MySQL calls
597
ha_innobase::extra with the
598
argument HA_EXTRA_KEYREAD; it is enough
599
to read just columns defined in
600
the index (i.e., no read of the
601
clustered index record necessary) */
602
ibool used_in_HANDLER;/* TRUE if we have been using this
603
handle in a MySQL HANDLER low level
604
index cursor command: then we must
605
store the pcur position even in a
606
unique search from a clustered index,
607
because HANDLER allows NEXT and PREV
608
in such a situation */
609
ulint template_type; /* ROW_MYSQL_WHOLE_ROW,
610
ROW_MYSQL_REC_FIELDS,
611
ROW_MYSQL_DUMMY_TEMPLATE, or
612
ROW_MYSQL_NO_TEMPLATE */
613
ulint n_template; /* number of elements in the
615
ulint null_bitmap_len;/* number of bytes in the SQL NULL
616
bitmap at the start of a row in the
618
ibool need_to_access_clustered; /* if we are fetching
619
columns through a secondary index
620
and at least one column is not in
621
the secondary index, then this is
623
ibool templ_contains_blob;/* TRUE if the template contains
625
mysql_row_templ_t* mysql_template;/* template used to transform
626
rows fast between MySQL and Innobase
627
formats; memory for this template
628
is not allocated from 'heap' */
629
mem_heap_t* heap; /* memory heap from which
630
these auxiliary structures are
631
allocated when needed */
632
ins_node_t* ins_node; /* Innobase SQL insert node
633
used to perform inserts
635
byte* ins_upd_rec_buff;/* buffer for storing data converted
636
to the Innobase format from the MySQL
638
const byte* default_rec; /* the default values of all columns
639
(a "default row") in MySQL format */
640
ulint hint_need_to_fetch_extra_cols;
641
/* normally this is set to 0; if this
642
is set to ROW_RETRIEVE_PRIMARY_KEY,
643
then we should at least retrieve all
644
columns in the primary key; if this
645
is set to ROW_RETRIEVE_ALL_COLS, then
646
we must retrieve all columns in the
647
key (if read_just_key == 1), or all
648
columns in the table */
649
upd_node_t* upd_node; /* Innobase SQL update node used
650
to perform updates and deletes */
651
que_fork_t* ins_graph; /* Innobase SQL query graph used
653
que_fork_t* upd_graph; /* Innobase SQL query graph used
654
in updates or deletes */
655
btr_pcur_t* pcur; /* persistent cursor used in selects
657
btr_pcur_t* clust_pcur; /* persistent cursor used in
658
some selects and updates */
659
que_fork_t* sel_graph; /* dummy query graph used in
661
dtuple_t* search_tuple; /* prebuilt dtuple used in selects */
662
byte row_id[DATA_ROW_ID_LEN];
663
/* if the clustered index was
664
generated, the row id of the
665
last row fetched is stored
667
dtuple_t* clust_ref; /* prebuilt dtuple used in
669
ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */
670
ulint stored_select_lock_type;/* this field is used to
671
remember the original select_lock_type
672
that was decided in ha_innodb.cc,
673
::store_lock(), ::external_lock(),
675
ulint row_read_type; /* ROW_READ_WITH_LOCKS if row locks
676
should be the obtained for records
677
under an UPDATE or DELETE cursor.
678
If innodb_locks_unsafe_for_binlog
679
is TRUE, this can be set to
680
ROW_READ_TRY_SEMI_CONSISTENT, so that
681
if the row under an UPDATE or DELETE
682
cursor was locked by another
683
transaction, InnoDB will resort
684
to reading the last committed value
685
('semi-consistent read'). Then,
686
this field will be set to
687
ROW_READ_DID_SEMI_CONSISTENT to
688
indicate that. If the row does not
689
match the WHERE condition, MySQL will
690
invoke handler::unlock_row() to
691
clear the flag back to
692
ROW_READ_TRY_SEMI_CONSISTENT and
693
to simply skip the row. If
694
the row matches, the next call to
695
row_search_for_mysql() will lock
697
This eliminates lock waits in some
698
cases; note that this breaks
700
ulint mysql_prefix_len;/* byte offset of the end of
701
the last requested column */
702
ulint mysql_row_len; /* length in bytes of a row in the
704
ulint n_rows_fetched; /* number of rows fetched after
705
positioning the current cursor */
706
ulint fetch_direction;/* ROW_SEL_NEXT or ROW_SEL_PREV */
707
byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE];
708
/* a cache for fetched rows if we
709
fetch many rows from the same cursor:
710
it saves CPU time to fetch them in a
711
batch; we reserve mysql_row_len
712
bytes for each such row; these
713
pointers point 4 bytes past the
714
allocated mem buf start, because
715
there is a 4 byte magic number at the
716
start and at the end */
717
ibool keep_other_fields_on_keyread; /* when using fetch
718
cache with HA_EXTRA_KEYREAD, don't
719
overwrite other fields in mysql row
721
ulint fetch_cache_first;/* position of the first not yet
722
fetched row in fetch_cache */
723
ulint n_fetch_cached; /* number of not yet fetched rows
725
mem_heap_t* blob_heap; /* in SELECTS BLOB fields are copied
727
mem_heap_t* old_vers_heap; /* memory heap where a previous
728
version is built in consistent read */
729
/*----------------------*/
730
ib_uint64_t autoinc_last_value;/* last value of AUTO-INC interval */
731
ib_uint64_t autoinc_increment;/* The increment step of the auto
732
increment column. Value must be
733
greater than or equal to 1. Required to
734
calculate the next value */
735
ib_uint64_t autoinc_offset; /* The offset passed to
736
get_auto_increment() by MySQL. Required
737
to calculate the next value */
738
ulint autoinc_error; /* The actual error code encountered
739
while trying to init or read the
740
autoinc value from the table. We
741
store it here so that we can return
743
/*----------------------*/
744
UT_LIST_NODE_T(row_prebuilt_t) prebuilts;
745
/* list node of table->prebuilts */
746
index_cond_func_t idx_cond_func;/* Index Condition Pushdown function,
747
or NULL if there is none set */
748
void* idx_cond_func_arg;/* ICP function argument */
749
ulint n_index_fields; /* Number of fields at the start of
750
mysql_template. Valid only when using
752
ulint magic_n2; /* this should be the same as
756
#define ROW_PREBUILT_FETCH_MAGIC_N 465765687
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 */
764
/* Values for hint_need_to_fetch_extra_cols */
765
#define ROW_RETRIEVE_PRIMARY_KEY 1
766
#define ROW_RETRIEVE_ALL_COLS 2
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
774
#include "row0mysql.ic"