#include "univ.i"
#include "data0data.h"
#include "que0types.h"
#include "dict0types.h"
#include "trx0types.h"
#include "row0types.h"
#include "btr0pcur.h"
Go to the source code of this file.
Classes | |
struct | mysql_row_templ_struct |
struct | row_prebuilt_struct |
Macros | |
#define | row0mysql_h |
#define | row_mysql_lock_data_dictionary(trx) row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__) |
#define | row_mysql_freeze_data_dictionary(trx) row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__) |
#define | MYSQL_FETCH_CACHE_SIZE 8 |
#define | MYSQL_FETCH_CACHE_THRESHOLD 4 |
#define | ROW_PREBUILT_ALLOCATED 78540783 |
#define | ROW_PREBUILT_FREED 26423527 |
#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 |
#define | ROW_RETRIEVE_PRIMARY_KEY 1 |
#define | ROW_RETRIEVE_ALL_COLS 2 |
#define | ROW_READ_WITH_LOCKS 0 |
#define | ROW_READ_TRY_SEMI_CONSISTENT 1 |
#define | ROW_READ_DID_SEMI_CONSISTENT 2 |
Typedefs | |
typedef struct row_prebuilt_struct | row_prebuilt_t |
typedef struct mysql_row_templ_struct | mysql_row_templ_t |
Functions | |
UNIV_INTERN void | row_mysql_prebuilt_free_blob_heap (row_prebuilt_t *prebuilt) |
UNIV_INTERN byte * | row_mysql_store_true_var_len (byte *dest, ulint len, ulint lenlen) |
UNIV_INTERN const byte * | row_mysql_read_true_varchar (ulint *len, const byte *field, ulint lenlen) |
UNIV_INTERN void | row_mysql_store_blob_ref (byte *dest, ulint col_len, const void *data, ulint len) |
UNIV_INTERN const byte * | row_mysql_read_blob_ref (ulint *len, const byte *ref, ulint col_len) |
UNIV_INTERN void | row_mysql_pad_col (ulint mbminlen, byte *pad, ulint len) |
UNIV_INTERN byte * | row_mysql_store_col_in_innobase_format (dfield_t *dfield, byte *buf, ibool row_format_col, const byte *mysql_data, ulint col_len, ulint comp) |
UNIV_INTERN ibool | row_mysql_handle_errors (ulint *new_err, trx_t *trx, que_thr_t *thr, trx_savept_t *savept) |
UNIV_INTERN row_prebuilt_t * | row_create_prebuilt (dict_table_t *table) |
UNIV_INTERN void | row_prebuilt_free (row_prebuilt_t *prebuilt, ibool dict_locked) |
UNIV_INTERN void | row_update_prebuilt_trx (row_prebuilt_t *prebuilt, trx_t *trx) |
UNIV_INTERN void | row_unlock_table_autoinc_for_mysql (trx_t *trx) |
UNIV_INTERN int | row_lock_table_autoinc_for_mysql (row_prebuilt_t *prebuilt) |
UNIV_INTERN int | row_lock_table_for_mysql (row_prebuilt_t *prebuilt, dict_table_t *table, ulint mode) |
UNIV_INTERN int | row_insert_for_mysql (byte *mysql_rec, row_prebuilt_t *prebuilt) |
UNIV_INTERN void | row_prebuild_sel_graph (row_prebuilt_t *prebuilt) |
UNIV_INTERN upd_t * | row_get_prebuilt_update_vector (row_prebuilt_t *prebuilt) |
UNIV_INTERN ibool | row_table_got_default_clust_index (const dict_table_t *table) |
UNIV_INTERN int | row_update_for_mysql (byte *mysql_rec, row_prebuilt_t *prebuilt) |
UNIV_INTERN int | row_unlock_for_mysql (row_prebuilt_t *prebuilt, ibool has_latches_on_recs) |
UNIV_INTERN upd_node_t * | row_create_update_node_for_mysql (dict_table_t *table, mem_heap_t *heap) |
UNIV_INTERN ulint | row_update_cascade_for_mysql (que_thr_t *thr, upd_node_t *node, dict_table_t *table) |
UNIV_INTERN void | row_mysql_lock_data_dictionary_func (trx_t *trx, const char *file, ulint line) |
UNIV_INTERN void | row_mysql_unlock_data_dictionary (trx_t *trx) |
UNIV_INTERN void | row_mysql_freeze_data_dictionary_func (trx_t *trx, const char *file, ulint line) |
UNIV_INTERN void | row_mysql_unfreeze_data_dictionary (trx_t *trx) |
UNIV_INTERN int | row_create_table_for_mysql (dict_table_t *table, trx_t *trx) |
UNIV_INTERN int | row_create_index_for_mysql (dict_index_t *index, trx_t *trx, const ulint *field_lengths) |
UNIV_INTERN int | row_table_add_foreign_constraints (trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks) |
UNIV_INTERN ulint | row_drop_tables_for_mysql_in_background (void) |
UNIV_INTERN ulint | row_get_background_drop_list_len_low (void) |
UNIV_INTERN int | row_truncate_table_for_mysql (dict_table_t *table, trx_t *trx) |
UNIV_INTERN int | row_drop_table_for_mysql (const char *name, trx_t *trx, ibool drop_db) |
UNIV_INTERN void | row_mysql_drop_temp_tables (void) |
UNIV_INTERN int | row_discard_tablespace_for_mysql (const char *name, trx_t *trx) |
UNIV_INTERN int | row_import_tablespace_for_mysql (const char *name, trx_t *trx) |
UNIV_INTERN int | row_drop_database_for_mysql (const char *name, trx_t *trx) |
UNIV_INTERN ulint | row_rename_table_for_mysql (const char *old_name, const char *new_name, trx_t *trx, ibool commit) |
UNIV_INTERN ulint | row_check_index_for_mysql (row_prebuilt_t *prebuilt, const dict_index_t *index, ulint *n_rows) |
UNIV_INTERN ibool | row_is_magic_monitor_table (const char *table_name) |
Variables | |
ibool | row_rollback_on_timeout |
Interface between Innobase row operations and MySQL. Contains also create table and other data dictionary operations.
Created 9/17/2000 Heikki Tuuri
Definition in file row0mysql.h.
#define ROW_MYSQL_DUMMY_TEMPLATE |
Definition at line 782 of file row0mysql.h.
UNIV_INTERN ulint row_check_index_for_mysql | ( | row_prebuilt_t * | prebuilt, |
const dict_index_t * | index, | ||
ulint * | n_rows | ||
) |
Checks that the index contains entries in an ascending order, unique constraint is not broken, and calculates the number of index entries in the read view of the current transaction.
Checks that the index contains entries in an ascending order, unique constraint is not broken, and calculates the number of index entries in the read view of the current transaction.
prebuilt | in: prebuilt struct in MySQL handle |
index | in: index |
n_rows | out: number of entries seen in the consistent read |
Definition at line 4071 of file row0mysql.cc.
References cmp_dtuple_rec_with_match(), dfield_get_len(), dict_index_get_n_ordering_defined_by_user(), dict_index_is_unique(), dict_index_name_print(), dtuple_print(), mach_read_from_4(), mem_free, mem_heap_create, mem_heap_dup(), mem_heap_empty(), mem_heap_free, rec_offs_get_n_alloc(), rec_print_new(), row_rec_to_index_entry(), row_search_for_mysql(), ROW_SEL_NEXT, row_prebuilt_struct::trx, trx_is_interrupted(), and ut_print_timestamp().
Referenced by ha_innobase::check().
UNIV_INTERN int row_create_index_for_mysql | ( | dict_index_t * | index, |
trx_t * | trx, | ||
const ulint * | field_lengths | ||
) |
Does an index creation operation for MySQL. TODO: currently failure to create an index results in dropping the whole table! This is no problem currently as all indexes must be created at the same time as the table.
Does an index creation operation for MySQL. TODO: currently failure to create an index results in dropping the whole table! This is no problem currently as all indexes must be created at the same time as the table.
index | in, own: index definition (will be freed) |
trx | in: transaction handle |
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. |
Definition at line 1965 of file row0mysql.cc.
References dict_index_get_n_fields(), dict_index_name_print(), DICT_MAX_INDEX_COL_LEN, dict_operation_lock, dict_sys, trx_struct::error_state, ind_create_graph_create(), mem_free, mem_heap_create, mem_strdup(), dict_sys_struct::mutex, trx_struct::op_info, os_thread_get_curr_id(), pars_complete_graph_for_exec(), que_fork_start_command(), que_graph_free(), que_node_get_parent(), que_run_threads(), row_drop_table_for_mysql(), row_mysql_drop_struct::table_name, dict_index_struct::table_name, trx_commit_for_mysql(), TRX_DICT_OP_TABLE, trx_general_rollback_for_mysql(), trx_set_dict_operation(), trx_start_if_not_started(), ut_a, ut_ad, ut_max(), ut_print_name(), ut_print_timestamp(), and ut_strcmp().
Referenced by create_clustered_index_when_no_primary(), and create_index().
UNIV_INTERN row_prebuilt_t* row_create_prebuilt | ( | dict_table_t * | table | ) |
Create a prebuilt struct for a MySQL table handle.
Create a prebuilt struct for a MySQL table handle.
table | in: Innobase table handle |
Definition at line 650 of file row0mysql.cc.
References row_prebuilt_struct::autoinc_error, row_prebuilt_struct::autoinc_increment, row_prebuilt_struct::autoinc_last_value, btr_pcur_create_for_mysql(), row_prebuilt_struct::clust_pcur, row_prebuilt_struct::clust_ref, dict_index_copy_types(), dict_index_get_n_unique(), dict_table_get_n_cols(), dtuple_create(), row_prebuilt_struct::heap, row_prebuilt_struct::magic_n, row_prebuilt_struct::magic_n2, mem_heap_create, mem_heap_zalloc(), dict_index_struct::n_fields, row_prebuilt_struct::pcur, row_prebuilt_struct::search_tuple, row_prebuilt_struct::select_lock_type, row_prebuilt_struct::sql_stat_start, row_prebuilt_struct::stored_select_lock_type, row_prebuilt_struct::table, and ut_a.
Referenced by ha_innobase::doOpen().
UNIV_INTERN int row_create_table_for_mysql | ( | dict_table_t * | table, |
trx_t * | trx | ||
) |
Creates a table for MySQL. If the name of the table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", "innodb_table_monitor", then this will also start the printing of monitor output by the master thread. If the table name ends in "innodb_mem_validate", InnoDB will try to invoke mem_validate().
Creates a table for MySQL. If the name of the table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", "innodb_table_monitor", then this will also start the printing of monitor output by the master thread. If the table name ends in "innodb_mem_validate", InnoDB will try to invoke mem_validate().
table | in, own: table definition (will be freed) |
trx | in: transaction handle |
Definition at line 1814 of file row0mysql.cc.
References dict_mem_table_free(), dict_operation_lock, trx_struct::dict_operation_lock_mode, dict_sys, dict_table_get_low(), trx_struct::error_state, mem_heap_create, dict_sys_struct::mutex, dict_table_struct::name, trx_struct::op_info, os_event_set(), os_thread_get_curr_id(), pars_complete_graph_for_exec(), que_fork_start_command(), que_graph_free(), que_node_get_parent(), que_run_threads(), row_drop_table_for_mysql(), tab_create_graph_create(), row_mysql_drop_struct::table_name, trx_commit_for_mysql(), TRX_DICT_OP_TABLE, trx_general_rollback_for_mysql(), trx_set_dict_operation(), trx_start_if_not_started(), ut_a, ut_ad, ut_print_name(), and ut_print_timestamp().
Referenced by create_table_def(), and row_merge_create_temporary_table().
UNIV_INTERN upd_node_t* row_create_update_node_for_mysql | ( | dict_table_t * | table, |
mem_heap_t * | heap | ||
) |
Creates an query graph node of 'update' type to be used in the MySQL interface.
Creates an query graph node of 'update' type to be used in the MySQL interface.
table | in: table to update |
heap | in: mem heap from which allocated |
Definition at line 1262 of file row0mysql.cc.
References btr_pcur_create_for_mysql(), dict_table_get_n_cols(), upd_node_struct::pcur, upd_node_struct::select, upd_node_struct::table, upd_create(), upd_node_create(), upd_node_struct::update, and UT_LIST_INIT.
Referenced by row_get_prebuilt_update_vector().
UNIV_INTERN int row_discard_tablespace_for_mysql | ( | const char * | name, |
trx_t * | trx | ||
) |
Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function deletes the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set TRUE.
Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function deletes the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set TRUE.
name | in: table name |
trx | in: transaction handle |
Definition at line 2351 of file row0mysql.cc.
References dict_hdr_get_new_id(), dict_table_change_id_in_cache(), dict_table_get_low(), trx_struct::error_state, fil_discard_tablespace(), dict_foreign_struct::foreign_table, dict_foreign_struct::foreign_table_name, dict_table_struct::ibd_file_missing, lock_remove_all_on_table(), dict_table_struct::n_foreign_key_checks_running, dict_table_struct::name, trx_struct::op_info, os_thread_get_curr_id(), pars_info_add_str_literal(), pars_info_add_ull_literal(), pars_info_create(), que_eval_sql(), dict_table_struct::referenced_list, row_mysql_unlock_data_dictionary(), dict_table_struct::space, dict_table_struct::tablespace_discarded, trx_commit_for_mysql(), trx_general_rollback_for_mysql(), trx_start_if_not_started(), ut_ad, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_print_name(), and ut_print_timestamp().
Referenced by ha_innobase::discard_or_import_tablespace().
UNIV_INTERN int row_drop_database_for_mysql | ( | const char * | name, |
trx_t * | trx | ||
) |
Drops a database for MySQL.
Drops a database for MySQL.
name | in: database name which ends to '/' |
trx | in: transaction handle |
Definition at line 3585 of file row0mysql.cc.
References dict_get_first_table_name_in_db(), dict_table_get_low(), mem_free, dict_table_struct::n_mysql_handles_opened, trx_struct::op_info, os_thread_get_curr_id(), os_thread_sleep(), row_drop_table_for_mysql(), row_mysql_unlock_data_dictionary(), row_mysql_drop_struct::table_name, trx_commit_for_mysql(), trx_start_if_not_started(), ut_a, ut_ad, ut_print_name(), and ut_print_timestamp().
Referenced by InnobaseEngine::doDropSchema().
UNIV_INTERN int row_drop_table_for_mysql | ( | const char * | name, |
trx_t * | trx, | ||
ibool | drop_db | ||
) |
Drops a table for MySQL. If the name of the dropped table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", "innodb_table_monitor", then this will also stop the printing of monitor output by the master thread. If the data dictionary was not already locked by the transaction, the transaction will be committed. Otherwise, the data dictionary will remain locked.
Drops a table for MySQL. If the name of the dropped table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", "innodb_table_monitor", then this will also stop the printing of monitor output by the master thread. If the data dictionary was not already locked by the transaction, the transaction will be committed. Otherwise, the data dictionary will remain locked.
name | in: table name |
trx | in: transaction handle |
drop_db | in: TRUE=dropping whole database |
Definition at line 3033 of file row0mysql.cc.
References DICT_ERR_IGNORE_INDEX_ROOT, DICT_ERR_IGNORE_NONE, dict_load_table(), dict_operation_lock, trx_struct::dict_operation_lock_mode, dict_sys, dict_table_get_low_ignore_err(), dict_table_remove_from_cache(), dict_tables_have_same_db(), DICT_TF2_SHIFT, DICT_TF2_TEMPORARY, dict_table_struct::dir_path_of_temp_table, fil_delete_tablespace(), fil_space_for_table_exists_in_mem(), dict_table_struct::flags, dict_foreign_struct::foreign_table, dict_foreign_struct::foreign_table_name, dict_foreign_struct::foreign_table_name_lookup, dict_table_struct::id, lock_remove_all_on_table(), mem_heap_create, mem_heap_free, mem_heap_strdup(), dict_sys_struct::mutex, dict_table_struct::n_foreign_key_checks_running, dict_table_struct::n_mysql_handles_opened, dict_table_struct::name, trx_struct::op_info, pars_info_add_str_literal(), pars_info_create(), que_eval_sql(), dict_table_struct::referenced_list, row_mysql_handle_errors(), row_mysql_unlock_data_dictionary(), dict_table_struct::space, srv_wake_master_thread(), trx_struct::table_id, row_mysql_drop_struct::table_name, trx_commit_for_mysql(), TRX_DICT_OP_TABLE, trx_set_dict_operation(), trx_start_if_not_started(), ut_a, ut_ad, ut_error, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_print_name(), and ut_print_timestamp().
Referenced by dict_create_or_check_foreign_constraint_tables(), InnobaseEngine::doDropTable(), row_create_index_for_mysql(), row_create_table_for_mysql(), row_drop_database_for_mysql(), row_merge_drop_table(), row_mysql_drop_temp_tables(), and row_table_add_foreign_constraints().
UNIV_INTERN ulint row_drop_tables_for_mysql_in_background | ( | void | ) |
The master thread in srv0srv.c calls this regularly to drop tables which we must drop in background after queries to them have ended. Such lazy dropping of tables is needed in ALTER TABLE on Unix.
Definition at line 2203 of file row0mysql.cc.
References dict_sys, dict_table_get_low(), mem_free, dict_sys_struct::mutex, row_mysql_drop_struct::table_name, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, UT_LIST_INIT, UT_LIST_REMOVE, ut_print_name(), and ut_print_timestamp().
Referenced by srv_master_thread().
UNIV_INTERN ulint row_get_background_drop_list_len_low | ( | void | ) |
Get the background drop list length. NOTE: the caller must own the kernel mutex!
Definition at line 2277 of file row0mysql.cc.
References ut_ad, UT_LIST_GET_LEN, and UT_LIST_INIT.
Referenced by srv_master_thread().
UNIV_INTERN upd_t* row_get_prebuilt_update_vector | ( | row_prebuilt_t * | prebuilt | ) |
Gets pointer to a prebuilt update vector used in updates. If the update graph has not yet been built in the prebuilt struct, then this function first builds it.
Gets pointer to a prebuilt update vector used in updates. If the update graph has not yet been built in the prebuilt struct, then this function first builds it.
prebuilt | in: prebuilt struct in MySQL handle |
Definition at line 1299 of file row0mysql.cc.
References row_prebuilt_struct::heap, pars_complete_graph_for_exec(), que_node_get_parent(), row_create_update_node_for_mysql(), que_fork_struct::state, row_prebuilt_struct::table, row_prebuilt_struct::trx, row_prebuilt_struct::upd_graph, row_prebuilt_struct::upd_node, upd_node_struct::update, and ut_ad.
Referenced by ha_innobase::doDeleteRecord(), and ha_innobase::doUpdateRecord().
UNIV_INTERN int row_import_tablespace_for_mysql | ( | const char * | name, |
trx_t * | trx | ||
) |
Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary.
Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary.
name | in: table name |
trx | in: transaction handle |
Definition at line 2542 of file row0mysql.cc.
References dict_table_get_low(), DICT_TF_COMPACT, fil_open_single_table_tablespace(), fil_reset_too_high_lsns(), dict_table_struct::flags, dict_table_struct::ibd_file_missing, ibuf_delete_for_discarded_space(), log_get_lsn(), dict_table_struct::name, trx_struct::op_info, os_thread_get_curr_id(), row_mysql_unlock_data_dictionary(), dict_table_struct::space, dict_table_struct::tablespace_discarded, trx_commit_for_mysql(), trx_start_if_not_started(), ut_ad, ut_print_name(), and ut_print_timestamp().
Referenced by ha_innobase::discard_or_import_tablespace().
UNIV_INTERN int row_insert_for_mysql | ( | byte * | mysql_rec, |
row_prebuilt_t * | prebuilt | ||
) |
Does an insert for MySQL.
Does an insert for MySQL.
mysql_rec | in: row in the MySQL format |
prebuilt | in: prebuilt struct in MySQL handle |
Definition at line 1103 of file row0mysql.cc.
References trx_struct::error_state, dict_table_struct::ibd_file_missing, row_prebuilt_struct::ins_graph, row_prebuilt_struct::ins_node, que_thr_struct::lock_state, row_prebuilt_struct::magic_n, mem_analyze_corruption(), dict_table_struct::name, trx_struct::op_info, os_thread_get_curr_id(), que_thr_struct::prev_node, que_fork_get_first_thr(), que_thr_move_to_run_state_for_mysql(), que_thr_stop_for_mysql(), que_thr_stop_for_mysql_no_error(), ins_node_struct::row, row_ins_step(), row_mysql_handle_errors(), que_thr_struct::run_node, row_prebuilt_struct::sql_stat_start, dict_table_struct::stat_n_rows, ins_node_struct::state, row_prebuilt_struct::table, row_prebuilt_struct::trx, trx_savept_take(), trx_start_if_not_started(), ut_ad, ut_error, ut_print_name(), and ut_print_timestamp().
Referenced by ha_innobase::doInsertRecord().
UNIV_INTERN ibool row_is_magic_monitor_table | ( | const char * | table_name | ) |
Determines if a table is a magic monitor table.
Determines if a table is a magic monitor table.
table_name | in: name of the table, in the form database/table_name |
Definition at line 4223 of file row0mysql.cc.
References ut_a.
UNIV_INTERN int row_lock_table_autoinc_for_mysql | ( | row_prebuilt_t * | prebuilt | ) |
Sets an AUTO_INC type lock on the table mentioned in prebuilt. The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table.
Sets an AUTO_INC type lock on the table mentioned in prebuilt. The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table.
prebuilt | in: prebuilt struct in the MySQL table handle |
Definition at line 950 of file row0mysql.cc.
References dict_table_struct::autoinc_trx, trx_struct::error_state, row_prebuilt_struct::ins_graph, row_prebuilt_struct::ins_node, lock_table(), trx_struct::op_info, os_thread_get_curr_id(), que_thr_struct::prev_node, que_fork_get_first_thr(), que_thr_move_to_run_state_for_mysql(), que_thr_stop_for_mysql(), que_thr_stop_for_mysql_no_error(), row_mysql_handle_errors(), que_thr_struct::run_node, row_prebuilt_struct::table, row_prebuilt_struct::trx, trx_start_if_not_started(), and ut_ad.
Referenced by ha_innobase::reset_auto_increment().
UNIV_INTERN int row_lock_table_for_mysql | ( | row_prebuilt_t * | prebuilt, |
dict_table_t * | table, | ||
ulint | mode | ||
) |
Sets a table lock on the table mentioned in prebuilt.
Sets a table lock on the table mentioned in prebuilt.
prebuilt | in: prebuilt struct in the MySQL table handle |
table | in: table to lock, or NULL if prebuilt->table should be locked as prebuilt->select_lock_type |
mode | in: lock mode of table (ignored if table==NULL) |
Definition at line 1026 of file row0mysql.cc.
References que_thr_struct::common, trx_struct::error_state, lock_table(), trx_struct::op_info, os_thread_get_curr_id(), que_common_struct::parent, que_thr_struct::prev_node, que_fork_get_first_thr(), que_thr_move_to_run_state_for_mysql(), que_thr_stop_for_mysql(), que_thr_stop_for_mysql_no_error(), row_mysql_handle_errors(), row_prebuild_sel_graph(), que_thr_struct::run_node, row_prebuilt_struct::sel_graph, row_prebuilt_struct::select_lock_type, row_prebuilt_struct::table, row_prebuilt_struct::trx, trx_start_if_not_started(), and ut_ad.
Referenced by ha_innobase::doInsertRecord().
UNIV_INTERN void row_mysql_drop_temp_tables | ( | void | ) |
Drop all temporary tables during crash recovery.
Definition at line 3440 of file row0mysql.cc.
References btr_pcur_close(), btr_pcur_commit_specify_mtr(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_at_index_side(), btr_pcur_store_position(), BTR_SEARCH_LEAF, DICT_ERR_IGNORE_NONE, dict_load_table(), dict_sys, DICT_TF2_TEMPORARY, mach_read_from_4(), mem_heap_create, mem_heap_free, mem_heap_strdupl(), mtr_commit(), mtr_start(), trx_struct::op_info, row_drop_table_for_mysql(), row_mysql_unlock_data_dictionary(), dict_sys_struct::sys_tables, row_mysql_drop_struct::table_name, trx_allocate_for_background(), trx_commit_for_mysql(), and trx_free_for_background().
Referenced by recv_recovery_rollback_active().
UNIV_INTERN void row_mysql_freeze_data_dictionary_func | ( | trx_t * | trx, |
const char * | file, | ||
ulint | line | ||
) |
Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. in: line number
Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL.
trx | in/out: transaction |
file | in: file name |
line | in: line number |
Definition at line 1735 of file row0mysql.cc.
References dict_operation_lock, trx_struct::dict_operation_lock_mode, rw_lock_s_lock_func(), and ut_a.
UNIV_INTERN ibool row_mysql_handle_errors | ( | ulint * | new_err, |
trx_t * | trx, | ||
que_thr_t * | thr, | ||
trx_savept_t * | savept | ||
) |
Handles user errors and lock waits detected by the database engine.
Handles user errors and lock waits detected by the database engine.
new_err | out: possible new error encountered in lock wait, or if no new error, the value of trx->error_state at the entry of this function |
trx | in: transaction |
thr | in: query thread |
savept | in: savepoint or NULL |
Definition at line 533 of file row0mysql.cc.
References DICT_FK_MAX_RECURSIVE_LOAD, trx_struct::error_state, que_thr_stop_for_mysql(), row_rollback_on_timeout, srv_suspend_mysql_thread(), trx_general_rollback_for_mysql(), ut_a, and ut_error.
Referenced by row_drop_table_for_mysql(), row_insert_for_mysql(), row_lock_table_autoinc_for_mysql(), row_lock_table_for_mysql(), row_merge_lock_table(), row_search_for_mysql(), and row_update_for_mysql().
UNIV_INTERN void row_mysql_lock_data_dictionary_func | ( | trx_t * | trx, |
const char * | file, | ||
ulint | line | ||
) |
Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. in: line number
Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation.
trx | in/out: transaction |
file | in: file name |
line | in: line number |
Definition at line 1768 of file row0mysql.cc.
References dict_operation_lock, trx_struct::dict_operation_lock_mode, dict_sys, dict_sys_struct::mutex, rw_lock_x_lock_func(), and ut_a.
UNIV_INTERN void row_mysql_pad_col | ( | ulint | mbminlen, |
byte * | pad, | ||
ulint | len | ||
) |
Pad a column with spaces. in: number of bytes to pad
Pad a column with spaces.
mbminlen | in: minimum size of a character, in bytes |
pad | out: padded buffer |
len | in: number of bytes to pad |
Definition at line 255 of file row0mysql.cc.
UNIV_INTERN void row_mysql_prebuilt_free_blob_heap | ( | row_prebuilt_t * | prebuilt | ) |
Frees the blob heap in prebuilt when no longer needed. in: prebuilt struct of a ha_innobase:: table handle
Frees the blob heap in prebuilt when no longer needed.
prebuilt | in: prebuilt struct of a ha_innobase:: table handle |
Definition at line 127 of file row0mysql.cc.
References row_prebuilt_struct::blob_heap, and mem_heap_free.
Referenced by ha_innobase::extra(), and ha_innobase::reset().
UNIV_INTERN const byte* row_mysql_read_blob_ref | ( | ulint * | len, |
const byte * | ref, | ||
ulint | col_len | ||
) |
Reads a reference to a BLOB in the MySQL format.
Reads a reference to a BLOB in the MySQL format.
len | out: BLOB length |
ref | in: BLOB reference in the MySQL format |
col_len | in: BLOB reference length (not BLOB length) |
Definition at line 234 of file row0mysql.cc.
References mach_read_from_n_little_endian().
Referenced by calc_row_difference(), row_mysql_store_col_in_innobase_format(), and ha_innobase::store_key_val_for_row().
UNIV_INTERN const byte* row_mysql_read_true_varchar | ( | ulint * | len, |
const byte * | field, | ||
ulint | lenlen | ||
) |
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data.
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data.
len | out: variable-length field length |
field | in: field in the MySQL format |
lenlen | in: storage length of len: either 1 or 2 bytes |
Definition at line 172 of file row0mysql.cc.
References mach_read_from_1(), mach_read_from_2_little_endian(), and ut_a.
Referenced by calc_row_difference(), row_mysql_store_col_in_innobase_format(), and ha_innobase::store_key_val_for_row().
UNIV_INTERN void row_mysql_store_blob_ref | ( | byte * | dest, |
ulint | col_len, | ||
const void * | data, | ||
ulint | len | ||
) |
Stores a reference to a BLOB in the MySQL format. in: BLOB length; if the value to store is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header!
Stores a reference to a BLOB in the MySQL format.
dest | in: where to store |
col_len | in: dest buffer size: determines into how many bytes the BLOB length is stored, the space for the length may vary from 1 to 4 bytes |
data | in: BLOB data; if the value to store is SQL NULL this should be NULL pointer |
len | in: BLOB length; if the value to store is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header! |
Definition at line 196 of file row0mysql.cc.
References mach_write_to_n_little_endian(), and ut_a.
Referenced by innobase_col_to_mysql().
UNIV_INTERN byte* row_mysql_store_col_in_innobase_format | ( | dfield_t * | dfield, |
byte * | buf, | ||
ibool | row_format_col, | ||
const byte * | mysql_data, | ||
ulint | col_len, | ||
ulint | comp | ||
) |
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.c.
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.c.
dfield | in/out: dfield where dtype information must be already set when this function is called! |
buf | in/out: buffer for a converted integer value; this must be at least col_len long then! |
row_format_col | TRUE if the mysql_data is from a MySQL row, FALSE if from a MySQL key value; in MySQL, a true VARCHAR storage format differs in a row and in a key value: in a key value the length is always stored in 2 bytes! |
mysql_data | in: MySQL column value, not SQL NULL; NOTE that dfield may also get a pointer to mysql_data, therefore do not discard this as long as dfield is used! |
col_len | in: MySQL column length; NOTE that this is the storage length of the column in the MySQL format row, not necessarily the length of the actual payload data; if the column is a true VARCHAR then this is irrelevant |
comp | in: nonzero=compact format |
Definition at line 301 of file row0mysql.cc.
References dfield_set_data(), dtype_get_len(), dtype_get_mbmaxlen(), dtype_get_mbminlen(), dtype_get_mysql_type(), dtype_struct::mtype, dtype_struct::prtype, row_mysql_read_blob_ref(), row_mysql_read_true_varchar(), ut_a, and ut_error.
Referenced by calc_row_difference(), and row_sel_convert_mysql_key_to_innobase().
UNIV_INTERN byte* row_mysql_store_true_var_len | ( | byte * | dest, |
ulint | len, | ||
ulint | lenlen | ||
) |
Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format.
Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format.
dest | in: where to store |
len | in: length, must fit in two bytes |
lenlen | in: storage length of len: either 1 or 2 bytes |
Definition at line 143 of file row0mysql.cc.
References mach_write_to_1(), mach_write_to_2_little_endian(), and ut_a.
Referenced by innobase_col_to_mysql(), and ha_innobase::store_key_val_for_row().
UNIV_INTERN void row_mysql_unfreeze_data_dictionary | ( | trx_t * | trx | ) |
Unlocks the data dictionary shared lock. in/out: transaction
Unlocks the data dictionary shared lock.
trx | in/out: transaction |
Definition at line 1752 of file row0mysql.cc.
References dict_operation_lock, trx_struct::dict_operation_lock_mode, and ut_a.
Referenced by srv_suspend_mysql_thread().
UNIV_INTERN void row_mysql_unlock_data_dictionary | ( | trx_t * | trx | ) |
Unlocks the data dictionary exclusive lock. in/out: transaction
Unlocks the data dictionary exclusive lock.
trx | in/out: transaction |
Definition at line 1790 of file row0mysql.cc.
References dict_operation_lock, trx_struct::dict_operation_lock_mode, dict_sys, dict_sys_struct::mutex, and ut_a.
Referenced by ha_innobase::can_switch_engines(), dict_create_or_check_foreign_constraint_tables(), InnobaseEngine::doCreateTable(), innobase_rename_table(), row_discard_tablespace_for_mysql(), row_drop_database_for_mysql(), row_drop_table_for_mysql(), row_import_tablespace_for_mysql(), row_merge_drop_temp_indexes(), row_mysql_drop_temp_tables(), row_truncate_table_for_mysql(), and srv_suspend_mysql_thread().
UNIV_INTERN void row_prebuild_sel_graph | ( | row_prebuilt_t * | prebuilt | ) |
Builds a dummy query graph used in selects. in: prebuilt struct in MySQL handle
Builds a dummy query graph used in selects.
prebuilt | in: prebuilt struct in MySQL handle |
Definition at line 1234 of file row0mysql.cc.
References row_prebuilt_struct::heap, pars_complete_graph_for_exec(), que_node_get_parent(), row_prebuilt_struct::sel_graph, sel_node_create(), que_fork_struct::state, row_prebuilt_struct::trx, and ut_ad.
Referenced by row_lock_table_for_mysql(), and row_search_for_mysql().
UNIV_INTERN void row_prebuilt_free | ( | row_prebuilt_t * | prebuilt, |
ibool | dict_locked | ||
) |
Free a prebuilt struct for a MySQL table handle. in: TRUE=data dictionary locked
Free a prebuilt struct for a MySQL table handle.
prebuilt | in, own: prebuilt struct |
dict_locked | in: TRUE=data dictionary locked |
Definition at line 712 of file row0mysql.cc.
References row_prebuilt_struct::blob_heap, btr_pcur_free_for_mysql(), row_prebuilt_struct::clust_pcur, dict_table_decrement_handle_count(), row_prebuilt_struct::fetch_cache, row_prebuilt_struct::heap, row_prebuilt_struct::ins_graph, mach_read_from_4(), row_prebuilt_struct::magic_n, row_prebuilt_struct::magic_n2, mem_analyze_corruption(), mem_free, mem_heap_free, row_prebuilt_struct::mysql_row_len, row_prebuilt_struct::mysql_template, dict_table_struct::name, row_prebuilt_struct::old_vers_heap, row_prebuilt_struct::pcur, que_graph_free_recursive(), row_prebuilt_struct::sel_graph, row_prebuilt_struct::table, row_prebuilt_struct::upd_graph, ut_error, and ut_print_name().
Referenced by ha_innobase::close().
UNIV_INTERN ulint row_rename_table_for_mysql | ( | const char * | old_name, |
const char * | new_name, | ||
trx_t * | trx, | ||
ibool | commit | ||
) |
Renames a table for MySQL.
Renames a table for MySQL.
old_name | in: old table name |
new_name | in: new table name |
trx | in: transaction handle |
commit | in: if TRUE then commit trx |
Definition at line 3754 of file row0mysql.cc.
References dict_foreign_parse_drop_constraints(), dict_get_db_name_len(), dict_load_foreigns(), dict_table_get_low(), dict_table_rename_in_cache(), trx_struct::error_state, dict_table_struct::ibd_file_missing, mem_heap_create, mem_heap_free, mem_heap_strdupl(), trx_struct::op_info, os_thread_get_curr_id(), pars_info_add_str_literal(), pars_info_create(), que_eval_sql(), trx_commit_for_mysql(), trx_general_rollback_for_mysql(), trx_start_if_not_started(), ut_a, ut_ad, ut_print_name(), and ut_print_timestamp().
Referenced by innobase_rename_table().
UNIV_INTERN int row_table_add_foreign_constraints | ( | trx_t * | trx, |
const char * | sql_string, | ||
size_t | sql_length, | ||
const char * | name, | ||
ibool | reject_fks | ||
) |
Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in bot participating tables. The indexes are allowed to contain more fields than mentioned in the constraint.
Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in both participating tables. The indexes are allowed to contain more fields than mentioned in the constraint. Check also that foreign key constraints which reference this table are ok.
trx | in: transaction |
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 |
sql_length | in: length of sql_string |
name | in: table full name in the normalized form database_name/table_name |
reject_fks | in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. |
Definition at line 2096 of file row0mysql.cc.
References dict_create_foreign_constraints(), dict_load_foreigns(), dict_operation_lock, dict_sys, trx_struct::error_state, dict_sys_struct::mutex, trx_struct::op_info, row_drop_table_for_mysql(), trx_commit_for_mysql(), TRX_DICT_OP_TABLE, trx_general_rollback_for_mysql(), trx_set_dict_operation(), trx_start_if_not_started(), ut_a, and ut_ad.
Referenced by InnobaseEngine::doCreateTable().
UNIV_INTERN ibool row_table_got_default_clust_index | ( | const dict_table_t * | table | ) |
Checks if a table is such that we automatically created a clustered index on it (on row id).
Checks if a table is such that we automatically created a clustered index on it (on row id).
table | in: table |
Definition at line 1719 of file row0mysql.cc.
References dict_index_get_nth_col().
Referenced by ha_innobase::doOpen(), and innobase_get_mysql_key_number_for_index().
UNIV_INTERN int row_truncate_table_for_mysql | ( | dict_table_t * | table, |
trx_t * | trx | ||
) |
Truncates a table for MySQL.
Truncates a table for MySQL.
table | in: table handle |
trx | in: transaction handle |
Definition at line 2679 of file row0mysql.cc.
References BTR_MODIFY_LEAF, btr_pcur_close(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), dfield_set_data(), dict_hdr_get_new_id(), dict_index_copy_types(), dict_operation_lock, trx_struct::dict_operation_lock_mode, dict_sys, dict_table_autoinc_initialize(), dict_table_autoinc_lock(), dict_table_autoinc_unlock(), dict_table_change_id_in_cache(), dict_table_x_lock_indexes(), dict_table_x_unlock_indexes(), dict_truncate_index_tree(), dict_update_statistics(), dict_table_struct::dir_path_of_temp_table, dtuple_create(), trx_struct::error_state, fil_create_new_single_table_tablespace(), fil_discard_tablespace(), FIL_IBD_FILE_INITIAL_SIZE, FIL_NULL, fil_space_get_flags(), dict_foreign_struct::foreign_table, dict_foreign_struct::foreign_table_name, fsp_header_init(), dict_table_struct::ibd_file_missing, dict_table_struct::id, lock_remove_all_on_table(), mach_write_to_8(), mem_heap_alloc(), mem_heap_create, mem_heap_free, mtr_commit(), mtr_start(), dict_sys_struct::mutex, dict_table_struct::n_foreign_key_checks_running, dict_table_struct::name, trx_struct::op_info, os_thread_get_curr_id(), page_rec_write_index_page_no(), pars_info_add_int4_literal(), pars_info_add_ull_literal(), pars_info_create(), que_eval_sql(), rec_get_deleted_flag(), dict_table_struct::referenced_list, row_mysql_unlock_data_dictionary(), dict_index_struct::space, dict_table_struct::space, srv_wake_master_thread(), dict_sys_struct::sys_indexes, trx_struct::table_id, trx_commit_for_mysql(), trx_general_rollback_for_mysql(), trx_start_if_not_started(), ut_a, ut_ad, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_print_name(), and ut_print_timestamp().
Referenced by ha_innobase::delete_all_rows().
UNIV_INTERN int row_unlock_for_mysql | ( | row_prebuilt_t * | prebuilt, |
ibool | has_latches_on_recs | ||
) |
This can only be used when srv_locks_unsafe_for_binlog is TRUE or this session is using a READ COMMITTED or READ UNCOMMITTED isolation level. Before calling this function row_search_for_mysql() must have initialized prebuilt->new_rec_locks to store the information which new record locks really were set. This function removes a newly set clustered index record lock under prebuilt->pcur or prebuilt->clust_pcur. Thus, this implements a 'mini-rollback' that releases the latest clustered index record lock we set.
This can only be used when srv_locks_unsafe_for_binlog is TRUE or this session is using a READ COMMITTED or READ UNCOMMITTED isolation level. Before calling this function row_search_for_mysql() must have initialized prebuilt->new_rec_locks to store the information which new record locks really were set. This function removes a newly set clustered index record lock under prebuilt->pcur or prebuilt->clust_pcur. Thus, this implements a 'mini-rollback' that releases the latest clustered index record lock we set.
prebuilt | in/out: prebuilt struct in MySQL handle |
has_latches_on_recs | in: TRUE if called so that we have the latches on the records under pcur and clust_pcur, and we do not need to reposition the cursors. |
Definition at line 1510 of file row0mysql.cc.
References BTR_SEARCH_LEAF, row_prebuilt_struct::clust_pcur, dict_index_is_clust(), trx_struct::id, lock_rec_unlock(), mem_heap_free, mtr_commit(), mtr_start(), row_prebuilt_struct::new_rec_locks, trx_struct::op_info, os_thread_get_curr_id(), row_prebuilt_struct::pcur, row_get_rec_trx_id(), row_prebuilt_struct::select_lock_type, srv_locks_unsafe_for_binlog, row_prebuilt_struct::trx, dict_index_struct::trx_id_offset, trx_read_trx_id(), and ut_ad.
Referenced by row_search_for_mysql(), and ha_innobase::unlock_row().
UNIV_INTERN void row_unlock_table_autoinc_for_mysql | ( | trx_t * | trx | ) |
Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd). in/out: transaction
Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd).
trx | in/out: transaction |
Definition at line 928 of file row0mysql.cc.
References lock_release_autoinc_locks(), and lock_trx_holds_autoinc_locks().
Referenced by InnobaseEngine::doCommit(), InnobaseEngine::doRollback(), InnobaseEngine::doXaPrepare(), and innobase_rollback_trx().
UNIV_INTERN ulint row_update_cascade_for_mysql | ( | que_thr_t * | thr, |
upd_node_t * | node, | ||
dict_table_t * | table | ||
) |
Does a cascaded delete or set null in a foreign key operation.
Does a cascaded delete or set null in a foreign key operation.
thr | in: query thread |
node | in: update node used in the cascade or set null operation |
table | in: table where we do the operation |
Definition at line 1634 of file row0mysql.cc.
References trx_struct::error_state, que_thr_struct::fk_cascade_depth, FK_MAX_CASCADE_DEL, que_thr_struct::prev_node, que_thr_stop_for_mysql(), row_upd_step(), que_thr_struct::run_node, srv_suspend_mysql_thread(), dict_table_struct::stat_n_rows, and thr_get_trx().
UNIV_INTERN int row_update_for_mysql | ( | byte * | mysql_rec, |
row_prebuilt_t * | prebuilt | ||
) |
Does an update or delete of a row for MySQL.
Does an update or delete of a row for MySQL.
mysql_rec | in: the row to be updated, in the MySQL format |
prebuilt | in: prebuilt struct in MySQL handle |
Definition at line 1333 of file row0mysql.cc.
References btr_pcur_struct::btr_cur, btr_pcur_copy_stored_position(), row_prebuilt_struct::clust_pcur, trx_struct::error_state, que_thr_struct::fk_cascade_depth, dict_table_struct::ibd_file_missing, btr_cur_struct::index, que_thr_struct::lock_state, row_prebuilt_struct::magic_n, mem_analyze_corruption(), dict_table_struct::name, trx_struct::op_info, os_thread_get_curr_id(), upd_node_struct::pcur, row_prebuilt_struct::pcur, que_thr_struct::prev_node, que_fork_get_first_thr(), que_thr_move_to_run_state_for_mysql(), que_thr_stop_for_mysql(), que_thr_stop_for_mysql_no_error(), btr_pcur_struct::rel_pos, row_mysql_handle_errors(), row_upd_step(), que_thr_struct::run_node, row_prebuilt_struct::sql_stat_start, dict_table_struct::stat_n_rows, upd_node_struct::state, row_prebuilt_struct::table, row_prebuilt_struct::trx, trx_savept_take(), trx_start_if_not_started(), row_prebuilt_struct::upd_graph, row_prebuilt_struct::upd_node, ut_a, ut_ad, ut_error, UT_NOT_USED, ut_print_name(), and ut_print_timestamp().
Referenced by ha_innobase::doDeleteRecord(), and ha_innobase::doUpdateRecord().
UNIV_INTERN void row_update_prebuilt_trx | ( | row_prebuilt_t * | prebuilt, |
trx_t * | trx | ||
) |
Updates the transaction pointers in query graphs stored in the prebuilt struct. in: transaction handle
Updates the transaction pointers in query graphs stored in the prebuilt struct.
prebuilt | in/out: prebuilt struct in MySQL handle |
trx | in: transaction handle |
Definition at line 798 of file row0mysql.cc.
References row_prebuilt_struct::ins_graph, row_prebuilt_struct::magic_n, mem_analyze_corruption(), dict_table_struct::name, row_prebuilt_struct::sel_graph, row_prebuilt_struct::table, que_fork_struct::trx, row_prebuilt_struct::trx, row_prebuilt_struct::upd_graph, ut_error, and ut_print_name().
Referenced by ha_innobase::update_session().
ibool row_rollback_on_timeout |
Provide optional 4.x backwards compatibility for 5.0 and above
Definition at line 58 of file row0mysql.cc.
Referenced by convert_error_code_to_mysql(), innobase_init(), and row_mysql_handle_errors().