#include "univ.i"
#include "data0data.h"
#include "que0types.h"
#include "dict0types.h"
#include "trx0types.h"
#include "row0types.h"
#include "pars0sym.h"
#include "btr0pcur.h"
#include "read0read.h"
#include "row0mysql.h"
Go to the source code of this file.
enum open_node_op |
enum row_sel_direction |
enum row_sel_match_mode |
enum sel_node_state |
UNIV_INTERN que_thr_t* fetch_step | ( | que_thr_t * | thr | ) |
Performs a fetch for a cursor.
Performs a fetch for a cursor.
thr | in: query thread |
Definition at line 2118 of file row0sel.cc.
References pars_user_func_struct::arg, sel_node_struct::common, fetch_node_struct::cursor_def, trx_struct::error_state, fetch_step(), fetch_node_struct::func, pars_user_func_struct::func, fetch_node_struct::into_list, que_common_struct::parent, que_thr_struct::prev_node, que_node_get_parent(), que_node_get_type(), que_thr_struct::run_node, SEL_NODE_CLOSED, SEL_NODE_NO_MORE_ROWS, sel_node_struct::state, thr_get_trx(), and ut_ad.
Referenced by fetch_step().
Performs an execution step of an open or close cursor statement node.
UNIV_INTERN void* row_fetch_print | ( | void * | row, |
void * | user_arg | ||
) |
Sample callback function for fetch that prints each row.
Sample callback function for fetch that prints each row.
row | in: sel_node_t* |
user_arg | in: not used |
Definition at line 2181 of file row0sel.cc.
References dfield_get_len(), que_node_get_next(), que_node_get_val(), row_fetch_print(), sel_node_struct::select_list, UT_NOT_USED, and ut_print_buf().
Referenced by row_fetch_print().
UNIV_INTERN que_thr_t* row_printf_step | ( | que_thr_t * | thr | ) |
Prints a row in a select result.
Prints a row in a select result.
thr | in: query thread |
Definition at line 2225 of file row0sel.cc.
References que_thr_struct::prev_node, que_node_get_next(), que_node_get_parent(), que_node_get_type(), que_node_get_val(), row_printf_step(), que_thr_struct::run_node, row_printf_node_struct::sel_node, SEL_NODE_FETCH, SEL_NODE_NO_MORE_ROWS, SEL_NODE_OPEN, sel_node_struct::select_list, sel_node_struct::state, and ut_ad.
Referenced by row_printf_step().
UNIV_INTERN ibool row_search_check_if_query_cache_permitted | ( | trx_t * | trx, |
const char * | norm_name | ||
) |
Checks if MySQL at the moment is allowed for this table to retrieve a consistent read result, or store it to the query cache.
Checks if MySQL at the moment is allowed for this table to retrieve a consistent read result, or store it to the query cache.
trx | in: transaction object |
norm_name | in: concatenation of database name, '/' char, table name |
Definition at line 4708 of file row0sel.cc.
References trx_struct::id, dict_table_struct::locks, dict_table_struct::query_cache_inv_trx_id, trx_struct::read_view, read_view_open_now(), row_search_check_if_query_cache_permitted(), trx_start_if_not_started_low(), and UT_LIST_GET_LEN.
Referenced by row_search_check_if_query_cache_permitted().
UNIV_INTERN ulint row_search_for_mysql | ( | byte * | buf, |
ulint | mode, | ||
row_prebuilt_t * | prebuilt, | ||
ulint | match_mode, | ||
ulint | direction | ||
) |
Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next and fetch prev. NOTE that if we do a search with a full key value from a unique index (ROW_SEL_EXACT), then we will not store the cursor position and fetch next or fetch prev must not be tried to the cursor!
Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next and fetch prev. NOTE that if we do a search with a full key value from a unique index (ROW_SEL_EXACT), then we will not store the cursor position and fetch next or fetch prev must not be tried to the cursor!
buf | in/out: buffer for the fetched row in the MySQL format |
mode | in: search mode PAGE_CUR_L, ... |
prebuilt | in: prebuilt struct for the table handle; this contains the info of search_tuple, index; if search tuple contains 0 fields then we position the cursor at the start or the end of the index, depending on 'mode' |
match_mode | in: 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX |
direction | in: 0 or ROW_SEL_NEXT or ROW_SEL_PREV; NOTE: if this is != 0, then prebuilt must have a pcur with stored position! In opening of a cursor 'direction' should be 0. |
Definition at line 3346 of file row0sel.cc.
References btr_cur_get_block(), btr_pcur_get_block(), btr_pcur_get_rec(), btr_pcur_move_to_last_on_page(), btr_pcur_move_to_next(), btr_pcur_open_at_index_side(), BTR_SEA_TIMEOUT, btr_search_latch, BTR_SEARCH_LEAF, row_prebuilt_struct::clust_index_was_generated, cmp_dtuple_is_prefix_of_rec(), cmp_dtuple_rec(), trx_struct::conc_state, DB_SUCCESS_LOCKED_REC, dict_index_get_n_unique(), dict_index_is_clust(), dict_index_is_unique(), dict_table_is_comp(), dtuple_contains_null(), dtuple_get_n_fields(), dtuple_get_n_fields_cmp(), trx_struct::error_state, row_prebuilt_struct::fetch_cache_first, row_prebuilt_struct::fetch_direction, dict_table_struct::ibd_file_missing, row_prebuilt_struct::index, row_prebuilt_struct::index_usable, lock_cancel_waiting_and_release(), lock_clust_rec_cons_read_sees(), LOCK_GAP, LOCK_ORDINARY, LOCK_REC_NOT_GAP, lock_sec_rec_cons_read_sees(), que_thr_struct::lock_state, lock_table(), mach_write_to_4(), row_prebuilt_struct::magic_n, mem_analyze_corruption(), mem_heap_free, mtr_commit(), mtr_start(), row_prebuilt_struct::mysql_row_len, trx_struct::mysql_thd, row_prebuilt_struct::n_fetch_cached, row_prebuilt_struct::n_rows_fetched, dict_table_struct::name, row_prebuilt_struct::need_to_access_clustered, row_prebuilt_struct::new_rec_locks, trx_struct::op_info, os_thread_get_curr_id(), page_align(), page_get_page_no(), page_offset(), page_rec_get_next_const(), page_rec_is_comp(), page_rec_is_infimum(), page_rec_is_supremum(), row_prebuilt_struct::pcur, 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(), trx_struct::read_view, rec_get_deleted_flag(), rec_get_next_offs(), rec_offs_extra_size(), rec_offs_size(), rec_offs_validate(), rec_validate(), row_mysql_handle_errors(), row_prebuild_sel_graph(), row_prebuilt_struct::row_read_type, row_search_for_mysql(), ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX, ROW_SEL_NEXT, row_unlock_for_mysql(), rw_lock_get_writer(), rw_lock_s_lock, btr_pcur_struct::search_mode, row_prebuilt_struct::search_tuple, row_prebuilt_struct::sel_graph, row_prebuilt_struct::select_lock_type, row_prebuilt_struct::sql_stat_start, srv_locks_unsafe_for_binlog, dict_index_struct::table, row_prebuilt_struct::table, row_prebuilt_struct::templ_contains_blob, row_prebuilt_struct::template_type, thd_is_select(), row_prebuilt_struct::trx, trx_assign_read_view(), btr_pcur_struct::trx_if_known, trx_print(), trx_start_if_not_started(), ut_a, ut_ad, ut_error, ut_print_name(), ut_print_timestamp(), and trx_struct::wait_lock.
Referenced by ha_innobase::general_fetch(), ha_innobase::index_read(), row_check_index_for_mysql(), and row_search_for_mysql().
UNIV_INTERN ulint row_search_max_autoinc | ( | dict_index_t * | index, |
const char * | col_name, | ||
ib_uint64_t * | value | ||
) |
Read the max AUTOINC value from an index.
Read the max AUTOINC value from an index.
index | in: index to search |
col_name | in: name of autoinc column |
value | out: AUTOINC value read |
Definition at line 4844 of file row0sel.cc.
References btr_pcur_close(), btr_pcur_get_page(), btr_pcur_open_at_index_side(), BTR_SEARCH_LEAF, dict_field_struct::col, dict_index_get_n_ordering_defined_by_user(), mtr_commit(), mtr_start(), dict_col_struct::mtype, dict_field_struct::name, page_get_n_recs(), dict_col_struct::prtype, and row_search_max_autoinc().
Referenced by ha_innobase::innobase_initialize_autoinc(), and row_search_max_autoinc().
UNIV_INTERN void row_sel_convert_mysql_key_to_innobase | ( | dtuple_t * | tuple, |
byte * | buf, | ||
ulint | buf_len, | ||
dict_index_t * | index, | ||
const byte * | key_ptr, | ||
ulint | key_len, | ||
trx_t * | trx | ||
) |
Converts a key value stored in MySQL format to an Innobase dtuple. The last field of the key value may be just a prefix of a fixed length field: hence the parameter key_len. But currently we do not allow search keys where the last field is only a prefix of the full key field len and print a warning if such appears. in: transaction
Converts a key value stored in MySQL format to an Innobase dtuple. The last field of the key value may be just a prefix of a fixed length field: hence the parameter key_len. But currently we do not allow search keys where the last field is only a prefix of the full key field len and print a warning if such appears. A counterpart of this function is ha_innobase::store_key_val_for_row() in ha_innodb.cc.
tuple | in/out: tuple where to build; NOTE: we assume that the type info in the tuple is already according to index! |
buf | in: buffer to use in field conversions |
buf_len | in: buffer length |
index | in: index of the key value |
key_ptr | in: MySQL key value |
key_len | in: MySQL key value length |
trx | in: transaction |
Definition at line 2292 of file row0sel.cc.
References dict_field_struct::col, dfield_get_len(), dfield_set_data(), dfield_set_len(), dfield_set_null(), dict_table_is_comp(), dtype_get_mysql_type(), dict_col_struct::mtype, dict_field_struct::prefix_len, row_mysql_store_col_in_innobase_format(), row_sel_convert_mysql_key_to_innobase(), dict_index_struct::table, ut_a, ut_print_buf(), and ut_print_timestamp().
Referenced by ha_innobase::index_read(), ha_innobase::records_in_range(), and row_sel_convert_mysql_key_to_innobase().
UNIV_INTERN que_thr_t* row_sel_step | ( | que_thr_t * | thr | ) |
Performs a select step. This is a high-level function used in SQL execution graphs.
Performs a select step. This is a high-level function used in SQL execution graphs.
thr | in: query thread |
Definition at line 2015 of file row0sel.cc.
References sel_node_struct::consistent_read, sel_node_struct::copy_variables, trx_struct::error_state, sel_node_struct::explicit_cursor, sel_node_struct::fetch_table, que_thr_struct::graph, sel_node_struct::into_list, sel_node_struct::is_aggregate, que_fork_struct::last_sel_node, lock_table(), que_thr_struct::prev_node, que_node_get_next(), que_node_get_parent(), que_node_get_type(), sel_node_struct::read_view, row_sel_step(), que_thr_struct::run_node, SEL_NODE_FETCH, sel_node_get_nth_plan(), SEL_NODE_OPEN, sel_node_struct::set_x_locks, sel_node_struct::state, sym_node_struct::table, sel_node_struct::table_list, thr_get_trx(), trx_assign_read_view(), trx_start_if_not_started(), ut_ad, and UT_LIST_GET_FIRST.
Referenced by row_sel_step().
UNIV_INTERN void sel_col_prefetch_buf_free | ( | sel_buf_t * | prefetch_buf | ) |
Frees a prefetch buffer for a column, including the dynamically allocated memory for data stored there. in, own: prefetch buffer
Frees a prefetch buffer for a column, including the dynamically allocated memory for data stored there.
prefetch_buf | in, own: prefetch buffer |
Definition at line 505 of file row0sel.cc.
References sel_buf_struct::data, mem_free, sel_col_prefetch_buf_free(), and sel_buf_struct::val_buf_size.
Referenced by sel_col_prefetch_buf_free(), and sym_tab_free_private().
UNIV_INTERN sel_node_t* sel_node_create | ( | mem_heap_t * | heap | ) |
Creates a select node struct.
Creates a select node struct.
heap | in: memory heap where created |
Definition at line 255 of file row0sel.cc.
References sel_node_struct::common, mem_heap_alloc(), sel_node_struct::plans, sel_node_create(), SEL_NODE_OPEN, sel_node_struct::state, and que_common_struct::type.
Referenced by pars_select_list(), row_prebuild_sel_graph(), and sel_node_create().
UNIV_INTERN void sel_node_free_private | ( | sel_node_t * | node | ) |
Frees the memory private to a select node when a query graph is freed, does not free the heap where the node was originally created. in: select node struct
Frees the memory private to a select node when a query graph is freed, does not free the heap where the node was originally created.
node | in: select node struct |
Definition at line 275 of file row0sel.cc.
References btr_pcur_close(), plan_struct::clust_pcur, mem_heap_free, sel_node_struct::n_tables, plan_struct::old_vers_heap, plan_struct::pcur, sel_node_struct::plans, sel_node_free_private(), and sel_node_get_nth_plan().
Referenced by que_graph_free_recursive(), and sel_node_free_private().
UNIV_INLINE plan_t* sel_node_get_nth_plan | ( | sel_node_t * | node, |
ulint | i | ||
) |
Gets the plan node for the nth table in a join.
node | in: select node |
Referenced by opt_print_query_plan(), pars_update_statement(), row_sel_step(), and sel_node_free_private().