📄 row0mysql.h
字号:
introw_create_index_for_mysql(/*=======================*/ /* out: error number or DB_SUCCESS */ dict_index_t* index, /* in: index definition */ trx_t* trx, /* in: transaction handle */ const ulint* field_lengths); /* in: if not NULL, must contain dict_index_get_n_fields(index) actual field lengths for the index columns, which are then checked for not being too large. *//*************************************************************************Scans a table create SQL string and adds to the data dictionarythe foreign key constraints declared in the string. This functionshould be called after the indexes for a table have been created.Each foreign key constraint must be accompanied with indexes inbot participating tables. The indexes are allowed to contain morefields than mentioned in the constraint. */introw_table_add_foreign_constraints(/*==============================*/ /* out: error code or DB_SUCCESS */ trx_t* trx, /* in: transaction */ const char* sql_string, /* in: table create statement where foreign keys are declared like: FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2 */ const char* name, /* in: table full name in the normalized form database_name/table_name */ ibool reject_fks); /* in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. *//*************************************************************************The master thread in srv0srv.c calls this regularly to drop tables whichwe must drop in background after queries to them have ended. Such lazydropping of tables is needed in ALTER TABLE on Unix. */ulintrow_drop_tables_for_mysql_in_background(void);/*=========================================*/ /* out: how many tables dropped + remaining tables in list *//*************************************************************************Get the background drop list length. NOTE: the caller must own the kernelmutex! */ulintrow_get_background_drop_list_len_low(void);/*======================================*/ /* out: how many tables in list *//*************************************************************************Truncates a table for MySQL. */introw_truncate_table_for_mysql(/*=========================*/ /* out: error code or DB_SUCCESS */ dict_table_t* table, /* in: table handle */ trx_t* trx); /* in: transaction handle *//*************************************************************************Drops a table for MySQL. If the name of the dropped table ends tocharacters INNODB_MONITOR, then this also stops printing of monitoroutput by the master thread. */introw_drop_table_for_mysql(/*=====================*/ /* out: error code or DB_SUCCESS */ const char* name, /* in: table name */ trx_t* trx, /* in: transaction handle */ ibool drop_db);/* in: TRUE=dropping whole database *//*************************************************************************Discards the tablespace of a table which stored in an .ibd file. Discardingmeans that this function deletes the .ibd file and assigns a new table id forthe table. Also the flag table->ibd_file_missing is set TRUE. */introw_discard_tablespace_for_mysql(/*=============================*/ /* out: error code or DB_SUCCESS */ const char* name, /* in: table name */ trx_t* trx); /* in: transaction handle *//*********************************************************************Imports a tablespace. The space id in the .ibd file must match the space idof the table in the data dictionary. */introw_import_tablespace_for_mysql(/*============================*/ /* out: error code or DB_SUCCESS */ const char* name, /* in: table name */ trx_t* trx); /* in: transaction handle *//*************************************************************************Drops a database for MySQL. */introw_drop_database_for_mysql(/*========================*/ /* out: error code or DB_SUCCESS */ const char* name, /* in: database name which ends to '/' */ trx_t* trx); /* in: transaction handle *//*************************************************************************Renames a table for MySQL. */introw_rename_table_for_mysql(/*=======================*/ /* out: error code or DB_SUCCESS */ const char* old_name, /* in: old table name */ const char* new_name, /* in: new table name */ trx_t* trx); /* in: transaction handle *//*************************************************************************Checks a table for corruption. */ulintrow_check_table_for_mysql(/*======================*/ /* out: DB_ERROR or DB_SUCCESS */ row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL handle *//* A struct describing a place for an individual column in the MySQLrow format which is presented to the table handler in ha_innobase.This template struct is used to speed up row transformations betweenInnobase and MySQL. */typedef struct mysql_row_templ_struct mysql_row_templ_t;struct mysql_row_templ_struct { ulint col_no; /* column number of the column */ ulint rec_field_no; /* field number of the column in an Innobase record in the current index; not defined if template_type is ROW_MYSQL_WHOLE_ROW */ ulint mysql_col_offset; /* offset of the column in the MySQL row format */ ulint mysql_col_len; /* length of the column in the MySQL row format */ ulint mysql_null_byte_offset; /* MySQL NULL bit byte offset in a MySQL record */ ulint mysql_null_bit_mask; /* bit mask to get the NULL bit, zero if column cannot be NULL */ ulint type; /* column type in Innobase mtype numbers DATA_CHAR... */ ulint mysql_type; /* MySQL type code; this is always < 256 */ ulint mysql_length_bytes; /* if mysql_type == DATA_MYSQL_TRUE_VARCHAR, this tells whether we should use 1 or 2 bytes to store the MySQL true VARCHAR data length at the start of row in the MySQL format (NOTE that the MySQL key value format always uses 2 bytes for the data len) */ ulint charset; /* MySQL charset-collation code of the column, or zero */ ulint mbminlen; /* minimum length of a char, in bytes, or zero if not a char type */ ulint mbmaxlen; /* maximum length of a char, in bytes, or zero if not a char type */ ulint is_unsigned; /* if a column type is an integer type and this field is != 0, then it is an unsigned integer type */};#define MYSQL_FETCH_CACHE_SIZE 8/* After fetching this many rows, we start caching them in fetch_cache */#define MYSQL_FETCH_CACHE_THRESHOLD 4#define ROW_PREBUILT_ALLOCATED 78540783#define ROW_PREBUILT_FREED 26423527/* A struct for (sometimes lazily) prebuilt structures in an Innobase tablehandle used within MySQL; these are used to save CPU time. */struct row_prebuilt_struct { ulint magic_n; /* this magic number is set to ROW_PREBUILT_ALLOCATED when created and to ROW_PREBUILT_FREED when the struct has been freed; used in debugging */ dict_table_t* table; /* Innobase table handle */ trx_t* trx; /* current transaction handle */ ibool sql_stat_start; /* TRUE when we start processing of an SQL statement: we may have to set an intention lock on the table, create a consistent read view etc. */ ibool mysql_has_locked; /* this is set TRUE when MySQL calls external_lock on this handle with a lock flag, and set FALSE when with the F_UNLOCK flag */ ibool clust_index_was_generated; /* if the user did not define a primary key in MySQL, then Innobase automatically generated a clustered index where the ordering column is the row id: in this case this flag is set to TRUE */ dict_index_t* index; /* current index for a search, if any */ ulint read_just_key; /* set to 1 when MySQL calls ha_innobase::extra with the argument HA_EXTRA_KEYREAD; it is enough to read just columns defined in the index (i.e., no read of the clustered index record necessary) */ ibool used_in_HANDLER;/* TRUE if we have been using this handle in a MySQL HANDLER low level index cursor command: then we must store the pcur position even in a unique search from a clustered index, because HANDLER allows NEXT and PREV in such a situation */ ulint template_type; /* ROW_MYSQL_WHOLE_ROW, ROW_MYSQL_REC_FIELDS, ROW_MYSQL_DUMMY_TEMPLATE, or ROW_MYSQL_NO_TEMPLATE */ ulint n_template; /* number of elements in the template */ ulint null_bitmap_len;/* number of bytes in the SQL NULL bitmap at the start of a row in the MySQL format */ ibool need_to_access_clustered; /* if we are fetching columns through a secondary index and at least one column is not in the secondary index, then this is set to TRUE */ ibool templ_contains_blob;/* TRUE if the template contains BLOB column(s) */ mysql_row_templ_t* mysql_template;/* template used to transform rows fast between MySQL and Innobase formats; memory for this template is not allocated from 'heap' */ mem_heap_t* heap; /* memory heap from which these auxiliary structures are allocated when needed */ ins_node_t* ins_node; /* Innobase SQL insert node used to perform inserts to the table */ byte* ins_upd_rec_buff;/* buffer for storing data converted to the Innobase format from the MySQL format */ ulint hint_need_to_fetch_extra_cols; /* normally this is set to 0; if this is set to ROW_RETRIEVE_PRIMARY_KEY, then we should at least retrieve all columns in the primary key; if this is set to ROW_RETRIEVE_ALL_COLS, then we must retrieve all columns in the key (if read_just_key == 1), or all columns in the table */ upd_node_t* upd_node; /* Innobase SQL update node used to perform updates and deletes */ que_fork_t* ins_graph; /* Innobase SQL query graph used in inserts */ que_fork_t* upd_graph; /* Innobase SQL query graph used in updates or deletes */ btr_pcur_t* pcur; /* persistent cursor used in selects and updates */ btr_pcur_t* clust_pcur; /* persistent cursor used in some selects and updates */ que_fork_t* sel_graph; /* dummy query graph used in selects */ dtuple_t* search_tuple; /* prebuilt dtuple used in selects */ byte row_id[DATA_ROW_ID_LEN]; /* if the clustered index was generated, the row id of the last row fetched is stored here */ dtuple_t* clust_ref; /* prebuilt dtuple used in sel/upd/del */ ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */ ulint stored_select_lock_type;/* this field is used to remember the original select_lock_type that was decided in ha_innodb.cc, ::store_lock(), ::external_lock(), etc. */ ulint mysql_prefix_len;/* byte offset of the end of the last requested column */ ulint mysql_row_len; /* length in bytes of a row in the MySQL format */ ulint n_rows_fetched; /* number of rows fetched after positioning the current cursor */ ulint fetch_direction;/* ROW_SEL_NEXT or ROW_SEL_PREV */ byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE]; /* a cache for fetched rows if we fetch many rows from the same cursor: it saves CPU time to fetch them in a batch; we reserve mysql_row_len bytes for each such row; these pointers point 4 bytes past the allocated mem buf start, because there is a 4 byte magic number at the start and at the end */ ibool keep_other_fields_on_keyread; /* when using fetch cache with HA_EXTRA_KEYREAD, don't overwrite other fields in mysql row row buffer.*/ ulint fetch_cache_first;/* position of the first not yet fetched row in fetch_cache */ ulint n_fetch_cached; /* number of not yet fetched rows in fetch_cache */ mem_heap_t* blob_heap; /* in SELECTS BLOB fie lds are copied to this heap */ mem_heap_t* old_vers_heap; /* memory heap where a previous version is built in consistent read */ ulint magic_n2; /* this should be the same as magic_n */};#define ROW_PREBUILT_FETCH_MAGIC_N 465765687#define ROW_MYSQL_WHOLE_ROW 0#define ROW_MYSQL_REC_FIELDS 1#define ROW_MYSQL_NO_TEMPLATE 2#define ROW_MYSQL_DUMMY_TEMPLATE 3 /* dummy template used in row_scan_and_check_index *//* Values for hint_need_to_fetch_extra_cols */#define ROW_RETRIEVE_PRIMARY_KEY 1#define ROW_RETRIEVE_ALL_COLS 2#ifndef UNIV_NONINL#include "row0mysql.ic"#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -