Drizzled Public API Documentation

row0mysql.h File Reference
#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_trow_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_trow_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_trow_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
 

Detailed Description

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.

Macro Definition Documentation

#define ROW_MYSQL_DUMMY_TEMPLATE
Value:
3 /* dummy template used in
row_scan_and_check_index */

Definition at line 782 of file row0mysql.h.

Function Documentation

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.

Returns
DB_SUCCESS if ok out: number of entries seen in the consistent read

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.

Returns
TRUE if ok
Parameters
prebuiltin: prebuilt struct in MySQL handle
indexin: index
n_rowsout: 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.

Returns
error number or DB_SUCCESS 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.

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.

Returns
error number or DB_SUCCESS
Parameters
indexin, own: index definition (will be freed)
trxin: transaction handle
field_lengthsin: 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 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().

Returns
error code or DB_SUCCESS in: transaction handle

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().

Returns
error code or DB_SUCCESS
Parameters
tablein, own: table definition (will be freed)
trxin: 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.

Returns
own: update node in: mem heap from which allocated

Creates an query graph node of 'update' type to be used in the MySQL interface.

Returns
own: update node
Parameters
tablein: table to update
heapin: 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.

Returns
error code or DB_SUCCESS in: transaction handle

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.

Returns
error code or DB_SUCCESS
Parameters
namein: table name
trxin: 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.

Returns
error code or DB_SUCCESS in: transaction handle

Drops a database for MySQL.

Returns
error code or DB_SUCCESS
Parameters
namein: database name which ends to '/'
trxin: 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.

Returns
error code or DB_SUCCESS in: TRUE=dropping whole database

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.

Returns
error code or DB_SUCCESS
Parameters
namein: table name
trxin: transaction handle
drop_dbin: 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.

Returns
how many tables dropped + remaining tables in list

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!

Returns
how many tables in list

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.

Returns
prebuilt update vector in: prebuilt struct in MySQL handle

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.

Returns
prebuilt update vector
Parameters
prebuiltin: 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.

Returns
error code or DB_SUCCESS in: transaction handle

Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary.

Returns
error code or DB_SUCCESS
Parameters
namein: table name
trxin: 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 ibool row_is_magic_monitor_table ( const char *  table_name)

Determines if a table is a magic monitor table.

Returns
TRUE if monitor table in: name of the table, in the form database/table_name

Determines if a table is a magic monitor table.

Returns
TRUE if monitor table
Parameters
table_namein: 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.

Returns
error code or DB_SUCCESS in: prebuilt struct in the MySQL table handle

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.

Returns
error code or DB_SUCCESS
Parameters
prebuiltin: 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.

Returns
error code or DB_SUCCESS in: lock mode of table (ignored if table==NULL)

Sets a table lock on the table mentioned in prebuilt.

Returns
error code or DB_SUCCESS
Parameters
prebuiltin: prebuilt struct in the MySQL table handle
tablein: table to lock, or NULL if prebuilt->table should be locked as prebuilt->select_lock_type
modein: 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_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.

Parameters
trxin/out: transaction
filein: file name
linein: 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.

Returns
TRUE if it was a lock wait and we should continue running the query thread in: savepoint

Handles user errors and lock waits detected by the database engine.

Returns
TRUE if it was a lock wait and we should continue running the query thread and in that case the thr is ALREADY in the running state.
Parameters
new_errout: possible new error encountered in lock wait, or if no new error, the value of trx->error_state at the entry of this function
trxin: transaction
thrin: query thread
saveptin: 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.

Parameters
trxin/out: transaction
filein: file name
linein: 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.

Parameters
mbminlenin: minimum size of a character, in bytes
padout: padded buffer
lenin: number of bytes to pad

Definition at line 255 of file row0mysql.cc.

References ut_a, and ut_error.

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.

Parameters
prebuiltin: 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.

Returns
pointer to BLOB data in: BLOB reference length (not BLOB length)

Reads a reference to a BLOB in the MySQL format.

Returns
pointer to BLOB data
Parameters
lenout: BLOB length
refin: BLOB reference in the MySQL format
col_lenin: 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.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len in: storage length of len: either 1 or 2 bytes

Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len
Parameters
lenout: variable-length field length
fieldin: field in the MySQL format
lenlenin: 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.

Parameters
destin: where to store
col_lenin: 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
datain: BLOB data; if the value to store is SQL NULL this should be NULL pointer
lenin: 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.

Returns
up to which byte we used buf in the conversion in: nonzero=compact format

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.

Returns
up to which byte we used buf in the conversion
Parameters
dfieldin/out: dfield where dtype information must be already set when this function is called!
bufin/out: buffer for a converted integer value; this must be at least col_len long then!
row_format_colTRUE 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_datain: 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_lenin: 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
compin: 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.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len in: storage length of len: either 1 or 2 bytes

Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len
Parameters
destin: where to store
lenin: length, must fit in two bytes
lenlenin: 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.

Parameters
trxin/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_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.

Parameters
prebuiltin: 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 ulint row_rename_table_for_mysql ( const char *  old_name,
const char *  new_name,
trx_t trx,
ibool  commit 
)

Renames a table for MySQL.

Returns
error code or DB_SUCCESS in: if TRUE then commit trx

Renames a table for MySQL.

Returns
error code or DB_SUCCESS
Parameters
old_namein: old table name
new_namein: new table name
trxin: transaction handle
commitin: 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.

Returns
error code or DB_SUCCESS in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found.

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.

Returns
error code or DB_SUCCESS
Parameters
trxin: transaction
sql_stringin: 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_lengthin: length of sql_string
namein: table full name in the normalized form database_name/table_name
reject_fksin: 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).

Returns
TRUE if the clustered index was generated automatically in: table

Checks if a table is such that we automatically created a clustered index on it (on row id).

Returns
TRUE if the clustered index was generated automatically
Parameters
tablein: 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.

Returns
error code or DB_SUCCESS in: transaction handle

Truncates a table for MySQL.

Returns
error code or DB_SUCCESS
Parameters
tablein: table handle
trxin: 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.

Returns
error code or DB_SUCCESS 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.

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.

Returns
error code or DB_SUCCESS
Parameters
prebuiltin/out: prebuilt struct in MySQL handle
has_latches_on_recsin: 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).

Parameters
trxin/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.

Returns
error code or DB_SUCCESS in: table where we do the operation

Does a cascaded delete or set null in a foreign key operation.

Returns
error code or DB_SUCCESS
Parameters
thrin: query thread
nodein: update node used in the cascade or set null operation
tablein: 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 
)
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.

Parameters
prebuiltin/out: prebuilt struct in MySQL handle
trxin: 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().

Variable Documentation

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().