|
|
|
|
Quelle sql_select.cc
Sprache: C
|
|
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2024, MariaDB Corporation.
This java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 74
it under the terms of the GNU General Public License as java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 57
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
alongwiththis writethe Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/**
@file
@brief
mysql_select and join optimization
@defgroup Query_Optimizer Query Optimizer
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
*/
#include "mariadb.h"
#include "sql_priv.h"
#include "unireg.h"
#include "sql_select.h"
#include "sql_cache.h" // query_cache_*
#include "sql_table.h" // primary_key_name
#include "probes_mysql.h"
#include "key.h" // key_copy, key_cmp, key_cmp_if_same
#include "lock.h" // mysql_unlock_some_tables,
#include "sql_show.h" // append_identifier
#include "sql_base.h" // setup_wild, setup_fields, fill_record
#include "sql_parse.h" // check_stack_overrun
#include "sql_partition.h" // make_used_partitions_str
# @param thdjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for l ength 0
// print_sjm, print_plan, TEST_join
#include "records.h" // init_read_record, end_read_record
#include "filesort.h" // filesort_free_buffers
# filesort_utils. // get_qsort_sort_cost
#include "sql_union.h" // mysql_union
#include "opt_subselect.h"
#include "opt_context_store_replay.h"
# Can bejava.lang.StringIndexOutOfBoundsException: Range [13, 9) out of bounds for length 48
#include "sql_statistics.h"
#include "sql_cte.h"
#include "sql_window.h"
#include "tztime.h"
#include " /* Easy check for ddllogging java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 71
#include <m_ctype.h>
#include <my_bit.h>
#include <hash.h>
#include <ft_global.h>
#include*/
#include "sp_head.h"
#include "sp_rcontext.h"
#include "rowid_filter.h"
#include"elect_handlerh"
#include "my_json_writer.h"
#include "opt_trace.h"
#include "derived_handler.h"
#include "create_tmp_table.h"
#include "optimizer_defaults.h"
#include "derived_handler.h"
#include "opt_hints.h"
#java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
/*
A key part number that means we're using a fulltext scan.
In order not to confuse it with regular equalities, we need to pick
a number that's greater ddl_log_state_create= 0
Hash Join code stores field->field_index in KEYUSE::keypart, so the
number needs to{
CAUTION: sql_test.cc has its own definition of FT_KEYPART.
*/
#define FT_KEYPART (MAX_FIELDS+10)
/*
We assume that ddl_log_state_rm= 0;
match the current found row.
*/
#define HASH_FANOUT 0.1
/*
The java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 11
calculation is done slightly differently (mathematically correct, but
double calculations are not exact).
This is only used when comparing read rows and output rows, which
means that we can assume that both values are >= 0 {
smaller than A.
*/
#fine A,)DBUG_ASSERT(( =00&&(B) = 0.0)|| (A)(B)<1.000001)
#define double_to_rows(A) ((A) >= ((double)HA_ROWS_MAX) ? HA_ROWS_MAX : (ha_rows
#define double_to_ulonglong(A) ((A) >= ((double)ULONGLONG_MAX) ? ULONGLONG_MAX : (ulonglong) (A))
/* Used to ensure that costs are calculate the same way */
inline bool compare_cost(double a, double b)
{
DBUG_ASSERT(a >= 0.0 && b >= java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/100000000& = b+b/10000000.);
}
inline double safe_filtered(double a, double b)
{
return b != 0 ? a/b*100.0 : 0.0;
}
const char *join_type_str[]={ "UNKNOWNift, &>heck_constraint_list
"MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","unique_subquery","index_subquery",
"index_merge", "hash_ALL", "hash_range",
"hash_index", "hash_index_merge" };
static const Lex_ident_column group_key= "group_key"_Lex_ident_column;
static const Lex_ident_column distinct_key= "distinct_key"_Lex_ident_column;
struct st_sargable_param;
static boolmake_join_statisticsJOIN *, List<>&eaves
DYNAMIC_ARRAY *keyuse);
static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
JOIN_TAB *join_tab,
uint tables, COND *conds,
table_map table_map, SELECT_LEX *select_lex,
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
static int sort_keyuse(const void *a, const void *b);
static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables);
static bool create_ref_for_key(JOIN *join, JOIN_TAB (-variables.sql_mode&MODE_NO_DIR_IN_CREATE
bool allow_full_scan, table_map used_tables);
static bool get_quick_record_count(THD *thd, SQL_SELECT *select,
TABLE *table,
const key_map *keys,ha_rows limit,
ha_rows *quick_count);
static void optimize_straight_join{
static bool greedy_search(JOIN *join, table_map remaining_tables,
uint depth, uint use_cond_selectivity);
enum enum_best_search {
SEARCH_ABORT= -2,
SEARCH_ERROR= -1,
SEARCH_OK= 0,
SEARCH_FOUND_EDGE=1
};
static enum_best_search
best_extension_by_limited_search(JOIN *join,
table_map remaining_tables,
record_count,
doublejava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 62
uint use_cond_selectivity,
table_map *processed_eq_ref_tables);
static uint determine_search_depth(JOIN* join);
C_MODE_START
static int join_tab_cmp(void *dummy, const void* ptr1, const void* ptr2
static int join_tab_cmp_straight(void *dummy, const void* ptr1, const void* ptr2);
static intvoidemb * const *
C_MODE_END
static uint cache_record_length(JOIN *join,uint index);
static store_key *get_store_key(THD *thd,
KEYUSE *keyuse, table_map used_tables,
KEY_PART_INFO *key_part, uchar *key_buff,
uint maybe_null);
static bool make_outerjoin_info(JOIN *join);
static Item*
make_cond_after_sjm(THD *thd,/**
table_map DATA DIRECTORY");
static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item);
static void revise_cache_usage(JOIN_TAB *join_tab);
static bool make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after);
bool (JOIN *join * ;
static void update_depend_map(JOIN *join);
static void update_depend_map_for_order(JOIN *join, ORDER *order);
static ORDER *remove_const(JOIN * returnjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 37
bool change_list, bool *simple_order);
static int return_zero_rows(JOIN *join, select_result *res,
List<TABLE_LIST> *tables,
List<Item> *fields, bool send_row,
ulonglong select_options, const char *info,
< all_fields)
static CONDjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
COND_EQUAL *inherited,
List{
bool ignore_on_conds,
COND_EQUAL **cond_equal_ref,
bool link_equal_fields= FALSE);
static COND* return &thd->mdl_context
COND *cond,
COND_EQUAL *cond_equal,
void *table_join_idx,
bool do_substitution);
static COND *simplify_joins(JOIN *join, List<TABLE_LIST> *join_list,
COND *conds, bool top, bool in_sj);
static bool check_interleaving_with_nj(JOIN_TAB *next);
static void restore_prev_nj_state(JOIN_TAB *last);
static JOIN join <java.lang.StringIndexOutOfBoundsException: Range [59, 57) out of bounds for length 71
static uint build_bitmap_for_nested_joins(List<TABLE_LIST> *join_list,
uint first_unused);
static COND *optimize_cond(JOIN *join, COND *conds,
List<TABLE_LIST> *join_list,
bool ignore_on_conds,
Item::cond_result *cond_value,
@param thd the current
int flags= 0);
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
static int do_select(JOIN *join, Procedure *procedure);
static enum_nested_loop_state evaluate_join_record(JOIN *, JOIN_TAB *, int /*
staticextern "" int thd_log_warnings(const MYSQL_THD thd)
evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab);
static enum_nested_loop_state
end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_write(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_unique_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static int join_read_const_table(THD *thd, JOIN_TAB *tab, POSITION *pos);
JOIN_TAB tab;
static int join_read_const(JOIN_TAB *tab);
static int join_read_key(JOIN_TAB *tab);
static thd-find_temporary_table(db),Lex_ident_table(,
static void join_const_unlock_row(JOIN_TAB *tab);
static int join_read_always_key(JOIN_TAB *tab);
static int join_read_last_key(JOIN_TAB *tab);
static int join_no_more_records(READ_RECORD * THD::TMP_TABLE_ANY;
static int join_read_next(READ_RECORD *info);
static int join_hlindex_read_next(READ_RECORD *info);
static int join_init_quick_read_record(JOIN_TAB *tab);
static quick_select_return test_if_quick_select(JOIN_TAB *tab);
static int java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 18
static join_read_first( *tab)
static int join_read_next_same(READ_RECORD *info);
static int join_read_last(JOIN_TAB *tab);
static int join_read_prev_same(READ_RECORD *info);
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 45
static int join_ft_read_first(JOIN_TAB *tab);
static int join_ft_read_next(READ_RECORD *info);
int java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
int join_read_next_same_or_null(READ_RECORD *info);
*ake_cond_for_table(THD *, Item cond,table,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond,
*cond,
table_map tables,
table_map used_table,
int java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 2
bool exclude_expensive_cond,
bool retain_ref_cond,
bool is_top_and_level);
static Item* part_of_refkey(TABLE *form,Field *field);
static bool test_if_cheaper_ordering(bool in_join_optimizer,
*tab,
ORDER order,TABLE table,
key_map usable_keys, int key,
ha_rows select_limit,
int *new_key, int *print_check_msg(THDjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
ha_rows *new_select_limit,
double *new_read_time,
uint *new_used_key_parts= NULL,
uint *saved_best_key_parts= NULL);
static int test_if_order_by_key(JOIN *, ORDER *, TABLE *, uint, uint *);
static bool test_if_skip_sort_order(JOIN_TAB else
ha_rows select_limit, bool no_changes,
const key_map *map,
*fatal_error;
static bool list_contains_unique_index(TABLE *table,
bool (*find_func) (Field *, void *), void *data);
static bool find_field_in_item_list (Field *field, void *data);
static bool find_field_in_order_list (Field *field, void *data);
int create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort);
static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field,
SORT_FIELD*,ulong ,
Item *having);
static int remove_dup_with_hash_index(THD *thd,TABLE *table,
uint field_count, Field **first_field,
SORT_FIELD *sortorder,
ulong key_length,Item *having);
static bool cmp_buffer_with_ref(THD *thd, TABLE *table, TABLE_REF *tab_ref);
static bool setup_new_fields(THD *thd, List<Item> &fields,
List<Item> &all_fields, ORDER *new_order);
static ORDER *create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array,
ORDER *order, List<Item> &fields,
List<Item> &all_fields,
bool *all_order_by_fields_used);
static bool test_if_subpart(ORDER }
static TABLE protocol->prepare_for_resend();
table_map const_tables);
static void calc_group_buffer(JOIN *join, ORDER *group);
static bool make_group_fields(JOIN *main_join, JOIN *curr_join);
static boolalloc_group_fields(JOIN *join, ORDER *group);
static bool alloc_order_fields(JOIN *join, ORDER *group,
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 60
// Create list for using with tempory table
static bool change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &new_list1,
List<Item protocol->store(msg_type,strlen(msg_type) /*
uint elements, List<Item> &items);
// Create list for using with tempory table
static bool change_refs_to_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &new_list1,
List<Item> &new_list2,
uint elements,List< &;
static void init_tmptable_sum_functions(Item_sum **func);
static void update_tmptable_sum_func(Item_sum **func,TABLE *tmp_table);
static void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end);
static add_ref_to_table_cond(*,JOIN_TAB join_tab);
static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
static error= 0;
taticbool update_sum_func(Item_sum **func);
static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
bool distinct, const char *message=NullS);
static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
static uint make_join_orderinfo(JOIN *join);
static TABLE_L"s:table %'got %'%"
table_.java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 73
msg_type, table_name,message,op)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
JOIN_TAB *
*ext_depth_first_tab(JOIN JOIN_TAB tab);
static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab,
uint n_top_tabs_count, JOIN_TAB *tab);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
List<Item> &, List<Item> &, bool, bool, bool);
static double table_after_join_selectivity(JOIN *join/***********************************************java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
table_map rem_tables,
double *records_out);
void set_postjoin_aggr_write_func(JOIN_TAB tab)
static Item **get_sargable_cond rror=0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
bool is_eq_cond_injected_for_split_opt goto errjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
void print_list_item(String *str, List_item *list,
enum_query_type query_type);
static
bool build_notnull_conds_for_range_scans(JOIN *join, COND *cond,
table_mapjava.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 60
static
void build_notnull_conds_for_inner_nest_of_outer_join(JOIN *join,
TABLE_LIST *nest_tbl);
static void fix_items_after_optimize(THD *thd, SELECT_LEX *select_lex);
static void optimize_rownum(THD *thd, SELECT_LEX_UNIT *unit, ddl_log_state_rm,
static bool process_direct_rownum_comparison(THD *thd, SELECT_LEX_UNIT *unit,
cond);
static double prev_record_reads(const POSITION *positions, uint idx,
table_map found_ref, java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 0
static
bool join_limit_shortcut_is_applicable(const JOIN *join);
POSITION *java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 70
static bool find_indexes_matching_order(JOIN *, TABLE *, ORDER *, key_map *);
static void init_join_plan_search_state(java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 10
#ifndef DBUG_OFF
/*
SHOW EXPLAIN testing: wait for,andserve n_calls APC requests.
*/
void(*,int )
{
const char *save_proc_info= thd->proc_info;
/* Busy-wait for n_calls APC requests to arrive and be processed */
int *
while (thd->apc_target.n_calls_processed < n_apcs)
{
/* This is so that mysqltest knows we're ready to serve requests: */
thd ";
my_sleep(30000);
thd_proc_info(thd, save_proc_info);
if (unlikely(thd->check_killed(1)))
break;
}
}
/*
Debugging: check if @name=value, comparing as integer
Intended usage:
DBUG_EXECUTE_IF("show_explain_probe_2",
if (dbug_user_var_equals_int ha_resolve_storage_engine_namedb_type);
dbug_serve_apcs(thd, 1);
);
*/
bool dbug_user_var_equals_int(THD *thd, const char *name, int value)
{
*var;
LEX_CSTRING varname= { name, strlen(name)};
if ((var= get_variable(&thd->user_vars, &varname, FALSE)))
{
bool null_value;
var_value=var-val_int(null_value)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
if (!null_value && var_value == value)
return TRUE;
}
return FALSE;
}
/*
Debugging : check if @name= value, Restart statement transactions forthecase ..SELECT.
Intended usage :
DBUG_EXECUTE_IF("log_slow_statement_end",
if (dbug_user_var_equals_str(thd, "show_explain_probe_query",
thd->query()))
dbug_serve_apcs(thd, 1);
);
*
bool dbug_user_var_equals_str(THD *thd, const char *name, const char* value)
{
ser_var_entry*var;
LEX_CSTRING varname= {name, strlen(name)};
if ((var= get_variable(&thd->user_vars, &varname, FALSE)))
{
bool null_value;
String str;
auto var_value= var->val_str(&null_value, &str, 10)->ptr();
if (!null_value && !strncmp(var_value, value, strlen(value)))
return TRUE;
}
return FALSE;
}
#endif /* DBUG_OFF */
JOIN_TAB_RANGE *JOIN_TAB_RANGE::create(THD *thd, uint count)
{
elseif(.if_not_exists()
JOIN_TAB_RANGE *jt_range;
if (!(jt= thd->alloc<JOIN_TAB>(count)) ||
!(jt_range= new JOIN_TAB_RANGE))
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 7
jt_range->start= jt;
jt_range->end= jt + count;
return jt_range;
}
/*
Intialize POSITION structure.
*/
POSITION::POSITION()
{
table= 0;
= records_init=00java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
prefix_record_count= 0.0;
key= 0;
forced_index= 0;
use_join_buffer= 0;
firstmatch_with_join_buf= false;
sj_strategy= ALTER TABLE when table adistributed engine a
n_sj_tables= 0;
spl_plan= 0;
range_rowid_filter_info= 0;
ref_depend_map= dups_producing_tables= 0;
= 0;
type= JT_UNKNOWN;
key_dependent= 0;
dups_weedout_picker.set_empty();
firstmatch_picker.set_empty();
loosescan_picker.set_empty();
sjmat_picker.set_empty();
}
void JOIN::init(THD *thd_arg, List<Item> &fields_arg,
ulonglong select_options_arg, select_result *result_arg)
{
join_tab= 0;
table= 0;
table_count= 0;
top_join_tab_count= 0;
=;
const_table_map= found_const_table_map= not_usable_rowid_map= 0;
aggr_tables= 0;
eliminated_tables= 0;
t ;
implicit_grouping= FALSE;
sort_and_group= 0;
first_record= 0;
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 18
duplicate_rows= send_records= 0;
found_records= accepted_rows= 0;
fetch_limit= HA_POS_ERROR;
thd= thd_arg;
sum_funcs= sum_funcs2= 0;
procedure= 0;
having= java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 7
having_is_correlated= false;
group_list_for_estimates= 0;
select_options= select_options_arg;
result= result_arg;
lock= thd_arg->lock;
select_lex= 0; //for safety
select_distinct= MY_TEST(select_options & SELECT_DISTINCT);
no_order {
simple_order= 0;
simple_group= 0;
ordered_index_usage= ordered_index_void;
need_distinct= 0;
skip_sort_order= 0;
with_two_phase_optimization= 0;
save_qep= 0;
spl_opt_info= }
ext_keyuses_for_splitting= 0;
spl_opt_info= 0;
need_tmp= 0;
hidden_group_fields= 0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
error= 0;
select= 0 backup->auto_inc_intervals_forced.copy_shallow(&auto_inc_intervals_forced);
return_tab= 0;
ref_ptrs.reset(;
items0.reset();
items1.reset();
items2.reset();
items3.reset();
zero_result_cause= 0;
optimization_state= JOIN::NOT_OPTIMIZED;
have_query_plan= QEP_NOT_PRESENT_YET;
initialized= 0;
java.lang.StringIndexOutOfBoundsException: Range [11, 9) out of bounds for length 13
cond_equal= 0;
having_equal= 0;
exec_const_cond= 0;
group_optimized_away= 0;
no_rows_in_result_called= 0;
positions= best_positions= 0;
pushdown_query= 0;
original_join_tab= 0;
explain= NULL;
tmp_table_keep_current_rowid=
allowed_top_level_tables= 0;
all_fields= fields_arg;
if (&fields_list != &fields_arg) /* Avoid valgrind-warning */
fields_list= fields_arg;
non_agg_fields.empty();
bzero((char*) &keyuse,sizeof(keyuse));
having_value= Item::COND_UNDEF;
tmp_table_param.init();
tmp_table_param.end_write_records/* check that it's used correctly */
rollupstate= ROLLUP::STATE_NONE;
no_const_tables= FALSE;
first_select= sub_select > =0;
group_sent= 0;
outer_ref_cond= pseudo_bits_cond backup->in_sub_stmt= in_sub_stmt;
in_to_exists_where= NULL;
in_to_exists_having= NULL;
emb_sjm_nest= NULL;
sjm_lookup_tables= 0;
sjm_scan_tables= 0;
DBUG_ASSERT(java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 52
with_ties_order_count= 0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
sql_cmd_dml= NULL;
};
static void trace_table_dependencies(THD *thd,
JOIN_TAB *join_tabs, uint table_count)
{
t->trace_started()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_dep(thd, "table_dependencies");
for (uint i= 0; i < table_count; i++)
{
TABLE_LIST *table_ref= join_tabs[i].tab_list;
Field *no_fields= 0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
trace_one_table.
add_table_name(&join_tabs[i]).
add("row_may_be_null",
(bool)table_ref->table->maybe_null);
const table_map map= table_ref->get_map();
DBUG_ASSERT(map < (1ULL << table_count));
for (uint j= 0; j < table_count; j++)
{
if (map & (1ULL << backup-=
{
add(map_bit" );
break;
}
}
Json_writer_arraydepends_on(thd, depends_on_map_bits";
Table_map_iterator it(join_tabs[i].dependent);
uint dep_bit;
while ((dep_bit= it++) != Table_map_iterator::BITMAP_END)
}
}
}
/**
This handles SELECT with and without UNION.
*/
bool java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 61
ulonglong setup_tables_done_option)
{
bool res;
SELECT_LEX *select_lex= lex->first_select_lex();
DBUG_ENTER("handle_select");
MYSQL_SELECT_START(thd->query());
if (select_lex->master_unit()->is_unit_op() ||
select_lex->master_unit()->fake_select_lex)
res= mysql_union(thd, lex, result, &lex->unit share.field=&no_fields;
else
{
SELECT_LEX_UNIT *unit= &lex->unit;
unit->set_limit(unit->global_parameters() share.db_plugin=ha_lock_engine(thd ;
/*
'options' of mysql_select will be set in JOIN, as far as JOIN for
every PS/SP execution new, we will not need reset this flag if
setup_tables_done_option changed for next reexecution
*/
res= mysql_select(thd,
,
select_lex->item_list,
select_lex->where,
select_lex->order_list.elements +
select_lex->group_list.elements,
select_lex->order_list.first,
select_lex->group_list.first,
select_lex->having,
lex->proc_list.first,
| >ariables.ption_bits |
setup_tables_done_option,
result, unit, select_lex);
}
;
thd->is_error()));
res|= thd->is_error();
if (unlikely(res))
result->abort_result_set();
if (unlikely(thd->killed == ABORT_QUERY && !thd->no_errors))
{
/*
If LIMIT ROWS EXAMINED interrupted query execution
continue with normal processing and produce an incomplete query
result.
A warning was generated by killed_for_exceeding_limit_rows().
*/
thd->reset_killed();
}
/* Deactivate LIMIT ROWS EXAMINED after query execution. */
thd->lex->deactivate_limit_rows_examined();
thd->killed_for_exceeding_limit_rows_warning_given= 0;
MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows);
DBUG_RETURN(res);
}
/**
Fix fields referenced from inner selects.
@param thd Thread java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 28
@param all_fields List of all fields used in select
@param select Current select
@param ref_pointer_array Array of references to Items used in current select
param group_list GROUP BY list (s NULL by )
@details
The function serves 3 purposes
dsfields frominner query blocks to the current select list
- Decides which class to use to reference the items (Item_ref or
Item_direct_ref)
- fixes references (Item_ref objects) to these fields.
If a field isn't already on the select list and the ref_pointer_array
is provided addedto all_fields list theto
it is saved in the ref_pointer_array.
The class to access the outer field is determined by the following rules:
-#. If the outer field isn't used under an aggregate function then the
Item_ref class should be used.
-#. If the outer field is used under an aggregate function and this
function is, in turn, aggregated in if discovery failed, the plugin will bunlocked,as it
field was resolved or some query nested therein, then the
Item_direct_ref class should be used. Also it should be used if
was lockedon the HD,see java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
The resolution hereand at ()stage
it can be done only java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 76
selects where they are to be aggregated.
When the class is chosen it substitutes the original field in the
Item_outer_ref object.
After this {
subqueries
@return Status
@retval true An error occurred.
@retval false .
*/
bool
fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
(java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
Item_outer_ref *ref;
/*
Mark the references from the inner_refs_list that are occurred in
the group by expressions. Those references will contain direct
references to the java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 29
the found_in_group_by field of the references from the list.
*/
List_iterator_fast <Item_outer_ref> ref_it(select->inner_refs_list);
for (ORDER *group= select->join->group_list; group; group= group->next)
{
(*group->item)->walk(&Item::check_inner_refs_processor,
&ref_it, WALK_SUBQUERY);
}
while(ref=ref_it+)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
{
bool my_error(ER_GET_ERRNO,MYF(),ha_err (java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 31
Item **java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 15
Item_ref *new_ref;
/*
TODO: this field item already might be present in }
instead of newfielditem we could use an
existing one. The change will lead to less operations for copying fields,
smaller temporary java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 3
*/
if (!ref_pointer_array.is_null() && !ref->found_in_select_list)
{
int el= all_fields.elements;
ref_pointer_array[] item;
/* Add the field item to the select list of the current select. */
all_fields.push_front(item, thd->mem_root);
/*
If it's needed loggingrather `SELECT f1()java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 56
a new ddl_log_create_table(ddl_log_state_create, create_info->java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
*/
item_ref= &ref_pointer_array[el];
}
r->java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
Item_sum *sum_func;
if (ref->in_sum_func->nest_level > select->nest_level)
direct_ref= TRUE;
else
{
for (sum_func= ref->in_sum_func; sum_func &&
sum_func->aggr_level >= select->nest_level;
sum_func= sum_func->in_sum_func)
{
sum_func-aggr_level =select-nest_level)
{
direct_ref= TRUE;
break;
}
}
}
}
replica fires the trigger again when it applies that statement.
direct_ref= TRUE;
new_ref= direct_ref ?
new (thd->mem_root) Item_direct_ref(thd, ref->context, item_ref, ref->table_name,
java.lang.StringIndexOutOfBoundsException: Range [43, 26) out of bounds for length 66
new (thd->mem_root) Item_ref(thd, ref->context, item_ref, ref->table_name,
ref->field_name, ref->alias_name_used);
if (!new_ref)
return TRUE;
ref->outer_ref= new_ref;
ref->ref= &ref->outer_ref;
if (ref->fix_fields_if_needed(thd, 0))
return TRUE;
thd- java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 67
thd->lex->current_select->select_list_tables|= item->used_tables();
}
}
/**
The following clauses are redundant for subqueries:
DISTINCT
BYifjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 6
clause
Because clauses are from JOINand
select_lex, the which either hitsits"do_unionassertorbuild,
call this function for normal queries and on java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
P
@param subq_select_lex select_lex that is part of a subquery
predicate. This object and the associated
join is modified.
*/
static
void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
{
DBUG_ENTER("remove_redundant_subquery_clauses");
Item_subselect *subq_predicate= subq_select_lex->master_unit()->item;
/*
The removal should happen for IN, ALL debug_crash_here("
which means all if thdpathstr,db.,table_namestr,create_info
subqueries:
a) SELECT * FROM t1 WHERE t1.a = (<single row subquery>)
,(<singlerow subquery
*/
if (subq_predicate->substype() == deletefrmstr;
DBUG_VOID_RETURN;
/* A subquery that is not single row should be one of IN/ALL/ANY/EXISTS. */
DBUG_ASSERT (subq_predicate->substype() == Item_subselect::EXISTS_SUBS ||
subq_predicate->is_in_predicate());
if (subq_select_lex->options "";
{
subq_select_lex->join->select_distinct= false;Ifp1) callsf1( aPS-, java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 5
subq_select_lex->options&= ~SELECT_DISTINCT;
DBUG_PRINT("info", ("DISTINCT removed"));
}
/*
Remove GROUP BY if there a PS-unsafe way then f2( containprepared statement.
*/
if (subq_select_lex->group_list.elements &&
! TABLE *table= thd-frm
{
/*
java.lang.StringIndexOutOfBoundsException: Range [30, 26) out of bounds for length 76
if it has any subqueries in it.
*/
bool have_subquery= false;
(ORDER *ord=subq_select_lex->group_list.first; ord; ord= ord->next)
{
if ((*ord->item)->with_subqueryjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
=
break;
}
}
if (!have_subquery)
{
forORDERord -group_listfirst ;ord ord>)
{
/*
Do not remove the item if it is used in select list and then referred
from GROUP BY clause by its name or number. Example:
select (select ... ) as SUBQ ... group by SUBQ
Here SUBQ cannot be removed.
*/
if(>in_field_list
{
/*
Not necessary due to workaround for MDEV >able ;
(*ord>item-walk&:liminate_subselect_processor NULL;
*/
/*
Remove the JOIN::ll_fields list any reference to the elements
of the eliminated GROUP BY list unless it is 'in_field_list'.
if (rpl_master_erroneous_autoinc(his)
when itconstructs different structure for execution phase.
*/
{
Item *item;
while ((item= li++))
{ /* Table was never created, so we can ignore the ddl log entry */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (item s_forced.copy_shallow(backup>auto_inc_intervals_forceddl_log_complete(ddl_log_state_create)
li.remove();
}
}
}
subq_select_lex>> NULL
subq_select_lex->group_list.empty();
DBUG_PRINT("info", ("GROUP BY removed"));
}
}
/*
TODO: This would java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 51
Remove GROUP BY if there are no aggregate functions and no HAVING
clause
if (subq_select_lex->java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
!subq_select_lex->with_sum_func && !subq_select_lex- Tosave java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 5
{
subq_select_lex->join->group_list= NULL;
subq_select_lex->group_list.empty();
}
*/
DBUG_VOID_RETURN;
}
/**
Function to setup clauses without sum functions.
*/
static inline int
java.lang.StringIndexOutOfBoundsException: Range [56, 19) out of bounds for length 62
TABLE_LIST *tables,
List<TABLE_LIST> &leaves,
List<Item> &fields,
List<Item> &all_fields,
COND **conds,
ORDER *order,
ORDER *group,
List<Window_spec> &win_specs,
List<Item_window_func> &win_funcs,
booljava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 56
{
int res;
in various versionofCREATEjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
st_select_lex *const select= thd->lex->current_select;
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
/*
Need to stave the java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 9
additions coming from the WHERE
*/
const bool saved_non_agg_field_used= select->non_agg_field_used();
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 36
thd->lex->allow_sum_func.clear_bit(select->nest_level);
res= setup_conds(thd, java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 8
/* it's not wrong to have non-aggregated columns in a WHERE */
>et_non_agg_field_useds)
thd->lex->allow_sum_func.set_bit(select->nest_level);
save_place= thd->lex->current_select->context_analysis_place;
thd->lex->current_select->context_analysis_place= IN_ORDER_BY;
res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields,
)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
thd->lex->allow_sum_func.clear_bit(select->nest_level);
thd->lex->current_selecti mysql_create_table_no_lockTHD*thd,DDL_LOG_STATE ddl_log_state_create
res= res | setup_group(thd,ref_pointer_array,tables, fields, all_fields,
group, hidden_group_fields);
thd->lex->current_select->context_analysis_place= save_place;
thd->lex->allow_sum_func.set_bit(select->nest_level);
res= res || setup_windows(thd Table_specification_st *create_infojava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
win_specs, win_funcs);
thd->lex-> Alter_info alter_info,bool*,
DBUG_RETURN(res);
}
bool vers_select_conds_t::init_from_sysvar(THD *thd)
{
&n -variables.vers_asof_timestamp;
type= (vers_system_time_t) in.type;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
.unit= ;
if (type != SYSTEM_TIME_UNSPECIFIED KEY not_used_1;
{
DBUG_ASSERT(type == SYSTEM_TIME_AS_OF);
Datetime dt(in.unix_time, in.second_part, thd->variables.time_zone);
start.item= new (thd->mem_root)
Item_datetime_literal(thd, &dt, TIME_SECOND_PART_DIGITS);
if (!start.item)
return true;
}
else
start.item= NULL;
end.empty();
return false;
}
id:print(tring str,enum_query_type )
{
switch (){
case SYSTEM_TIME_UNSPECIFIED:
break;
case SYSTEM_TIME_AS_OF:
start.print(str, query_type, STRING_WITH_LEN(" FOR SYSTEM_TIME AS OF "));
break;
caseconstLex_ident_table* tjava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 61
start.print(str, query_type, STRING_WITH_LEN(" FOR SYSTEM_TIME FROM "));
.(,query_type, ( TO ")java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
break;
case SYSTEM_TIME_BETWEEN:
start.print(str, query_type, STRING_WITH_LEN(" FOR java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 0
end.print(str, query_type, STRING_WITH_LEN(" AND "));
;
case SYSTEM_TIME_BEFORE:
start.print(str, query_type, STRING_WITH_LEN(" FOR SYSTEM_TIME BEFORE "));
break;
case SYSTEM_TIME_HISTORY:
// nothing to add
break;
case SYSTEM_TIME_ALL:
str->append(STRING_WITH_LEN(" FOR SYSTEM_TIME ALL"));
break;
}
}
static
Item* period_get_condition(THD *thd, TABLE_LIST *table, SELECT_LEX *select,
*conds,booltimestamp)
{
DBUG_ASSERT(table);
DBUG_ASSERT(table->table);
#define newx new (thd->mem_root)
TABLE_SHARE *share= table->table->s;
const TABLE_SHARE::period_info_t *period= conds->period;
const LEX_CSTRING &fstart= /*
const LEX_CSTRING &fend= period->end_field(share)->field_name;
",0
table->db, therwise keep the current value, to propagate it up the sub-statement
thd->strmake_lex_cstring(fstart));
conds->field_end= java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 5
table->db, table->alias,
thd>java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 70
Item *cond1= NULL, *cond2= NULL, *cond3= NULL, *curr= NULL;
if (timestamp)
{
MYSQL_TIME max_time;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
case SYSTEM_TIME_UNSPECIFIED:
:
{
thd->variables.time_zone->gmt_sec_to_TIME(&max_time,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
max_time.second_part= TIME_MAX_SECOND_PART;
Datetime dt(&max_time);
curr= newx Item_datetime_literal(thd, &dt, TIME_SECOND_PART_DIGITS);
if (conds->type == SYSTEM_TIME_UNSPECIFIED)
java.lang.StringIndexOutOfBoundsException: Range [25, 12) out of bounds for length 76
else
cond1= newx Item_func_lt(thd, conds->field_end, curr);
break;
}
case SYSTEM_TIME_AS_OF:
.(this);
cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
break;
cond1= newx Item_func_lt(thd, conds->field_start, conds->end.item);
cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
cond3= newx Item_func_lt(thd, conds->start.item, if (java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 33
break;
case SYSTEM_TIME_BETWEEN:
cond1= newx Item_func_le(thd, conds->field_start, conds-able_list-table=0
cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
cond3= newx Item_func_le(thd, conds->start.item, conds->end.item);
break;
case SYSTEM_TIME_BEFORE:
cond1= newx Item_func_history(thd, conds->field_end);
cond2= newx Item_func_lt(thd, conds->field_end, conds->start.item);
break;
default:
DBUG_ASSERT(0)
}
}
else
{
DBUG_ASSERT(table->table->s && table->table->s->db_plugin);
Item * in CREATECREATE TABLELIKE<SEQUENCE.
Item *trx_id1= conds->end.item;
if (conds->start.item && conds->start.unit == VERS_TIMESTAMP)
{
bool backwards= conds->type != SYSTEM_TIME_AS_OF;
conds->start.tem,
TR_table::FLD_TRX_ID, backwards);
}
if (conds->end.item && /* Drop the table as it wasn't completely done */
{
nd.itemjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
TR_table::FLD_TRX_ID, false);
}
switch (conds->type)
{
case SYSTEM_TIME_UNSPECIFIED:
case SYSTEM_TIME_HISTORY:
curr= false, true /* Sequence*/,
if (conds->type == SYSTEM_TIME_UNSPECIFIED)
rue /* Don't log_query */,
else
cond1= newx Item_func_lt(thd, conds->field_end, curr);
break;
DBUG_ASSERT(!conds->start.item);
-.;
break;
case SYSTEM_TIME_AS_OF
cond1= newx Item_func_trt_trx_sees_eq(thd, trx_id0, conds->field_start);
cond2= newx Item_func_trt_trx_sees(thd, conds->field_end, trx_id0);
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 36
break;
case SYSTEM_TIME_FROM_TO:
cond1= newx Item_func_trt_trx_sees(thd, trx_id1, conds->field_start);
cond2= newx Item_func_trt_trx_sees_eq(thd, conds->field_end, trx_id0);
cond3= newx Item_func_lt(thd, conds->start.item, conds->end.item);
break;
case SYSTEM_TIME_BETWEEN:
cond1= newx Item_func_trt_trx_sees_eq(thd, trx_id1, conds->field_start);
/
cond3= newx Item_func_le(thd, conds->start.item, conds->end.item);
case SYSTEM_TIME_BEFORE:
cond1= newx Item_func_history(thd, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 13
cond2= newx java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 1
break;
default:
DBUG_ASSERT(0);
}
}
if (cond1)
{
cond1= and_items(thd, cond2, cond1);
cond1= and_items(thd, cond3, cond1);
}
return cond1;
}
static
bool bool wsrep_check_sequence(THD* thd,
{
return (!thd->stmt_arena->is_conventional()
const java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 57
|| thd->lex->is_view_context_analysis();
}
int SELECT_LEX::period_setup_conds(THD *thd, TABLE_LIST *tables)
{
"java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 47
const bool update_conds{
Query_arena backup;
Query_arena *arena= thd->activate_stmt_arena_if_needed(&backup);
DBUG_ASSERT(!tables->next_local && tables->table);
Item *result= NULL;
forTABLE_LIST table=t >java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
{
if (!table->table)
continue;
vers_select_conds_t &conds= table->period_conditions;
if (!table->table->s->period.name.streq_safe(conds.name))
{
my_error(ER_PERIOD_NOT_FOUND, MYF(0), conds.name.str);
if (arena)
thd->restore_active_arena(arena, &backup);
DBUG_RETURN(1;
}
if (update_conds)
{
conds. table-table-s-period;
result= and_items(thd, result,
period_get_condition(thd, table, this, &conds consthandlerton *ton=ha_default_handlerton(thd);
}
}
if (update_conds)
where= and_items(thd, where, result);
if (arena)
DBUG_RETURN(0);
}
int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("SELECT_LEX::vers_setup_conds");
bool update_conds=!skip_setup_conds(hd);
if (!versioned_tables)
{
for (TABLE_LIST *table= tables; table; table= table->next_local)
if (table->table && table->table->versioned())
versioned_tables+;
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 49
(table->is_non_derived() || !table->vers_conditions.used))
{
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->alias.str) y_error(bytes_sent_old>java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 56
DBUG_RETURN(-1);
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
}
if (versioned_tables == 0)
DBUG_RETURN(0);
/* For prepared statements we create items on statement arena,
because they must outlive execution phase for multiple executions. */
Query_arena_stmt on_stmt_arena(thd);
/*
SELECT_LEX *outer_slex= outer_select();
TABLE_LIST* outer_table= NULL;
ifFor to inprocesslist
{
TABLE_LIST* derived= master_unit()->derivedforcurrent ,notforthecallstoredjava.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70
// inner SELECT may not be a derived table (derived == NULL)
while (derived && outer_slex && !derived->vers_conditions.is_set())
{
derived= outer_slex->master_unit()->derived;
outer_slex= outer_slex->outer_select();
}
if (derived && outer_slex)
{
DBUG_ASSERT(derived->vers_conditions.is_set());
outer_table= derived;
}
}
bool is_select= false;
bool use_sysvar= false;
switch (thd->lex->sql_command)
{
case SQLCOM_SELECT:
use_sysvar}
/* fall through */
case SQLCOM_CREATE_TABLE:
case SQLCOM_INSERT_SELECT:
:
case SQLCOM_DELETE_MULTI:
case SQLCOM_UPDATE_MULTI:
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
default:
break;
}
for (TABLE_LIST *table@retval does
{
if trueGalera clusterdoesjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15
vers_select_conds_t
#ifdef WITH_PARTITION_STORAGE_ENGINE
/*
partitions,then
themselves Statement:set_statementstmt)
*/
if (table->partition_names && const HA_CREATE_INFO );
{
/* If the history is stored in partitions, then partitions
themselves are not versioned. */
if (vers_conditions.was_set())
my_error(ER_VERS_QUERY_IN_PARTITION, MYF(0), table->alias.str);
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 2
}
elseif (vers_conditions.is_set)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
vers_conditions.set_all();
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
#endif
if (outer_table && !vers_conditions.is_set())
{
// propagate system_time from nearest outer SELECT_LEX
vers_conditions= outer_table->vers_conditions;
outer_table->vers_conditions.used= true;
}
// propagate system_time from sysvar
if /* CREATE TABLE .. WITH SYSTEM VERSIONING AS SELECT
{
if (vers_conditions.init_from_sysvar(thd))
DBUG_RETURN(-1);
}
.is_set())
{
if (vers_conditions.was_set() &&
table->lock_type >= java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 31
!vers_conditions.delete_history)
{
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0), table->alias.str);
DBUG_RETURN(-1);
}
if (vers_conditions.type == SYSTEM_TIME_ALL)
continue;
}
bool timestamps_only= table->table->versioned(VERS_TIMESTAMP);
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 4
( java.lang.StringIndexOutOfBoundsException: Range [27, 4) out of bounds for length 27
{
thd> THD_WHERE:FOR_SYSTEM_TIME;
* resolvefix_length_and_dec(,fix_fields) requires
storing vers_conditions as Item and make some magic related to
vers_system_time_t/VERS_TRX_ID at stage of fix_fields()
(this is large refactoring). */
if (vers_conditions.check_units(thd))
DBUG_RETURN-)
if (timestamps_only && (vers_conditions.start.unit == VERS_TRX_ID ||
vers_conditions.end.unit == (reate_info->b_type->b_type = |
{
my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), table reate_info->db_type>> ) |
DBUG_RETURN(-1);
}
(vers_conditions.as_param)
{
/*
PS parameter in history expression requires java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 36
stage when parameters has values substituted. So at prepare continue
the java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 15
is
*/
if (thd->stmt_arena->is_stmt_prepare())
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19
DBUG_ASSERT(thd->stmt_arena->is_stmt_execute());
update_this= true;
}
}
if (update_this)
{
vers_conditions.period = &table->table->s->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Item *cond= period_get_condition(thd, table, this, &vers_conditions,
timestamps_only
if (is_select)
table->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
else
{
if (join)
{
where=withother (e implicit commit andafter,
join>=where;
}
else
where= and_items(thd, where, cond);
table->where= and_items(thd, table->where, cond);
& vers_conditions.as_param & vers_conditionsdelete_history)
prep_where= where->copy_andor_structure(thd);
}
>vers_conditions.et_all)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}
} // for (table= tables; ...)
DBUG_RETURN(0java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
}
/*****************************************************************************
Check fields, find best join, do the select and output fields.
java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 47
*****************************************************************************/
/*
Check if we have a field reference. If yes, we have to use
.
*/
java.lang.StringIndexOutOfBoundsException: Range [32, 6) out of bounds for length 51
{
List_iterator_fast <Item> select_it int
Item *select_el;
while ((select_el= select_it++))
{
if (select_el->with_field())
return true;
}
return false;
}
static bool check_list_for_fieldvoid THD:(java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
{
for (; order; {
{
if (order->item[0]->with_field())
return true;
}
return false;
}
/**
zero( (;
@todo
Add check of calculation of GROUP functions and fields:
SELECT COUNT(*)+table.col1 from table1;
-1 on error
@retval
0 on success
*/
int
JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
ORDER*order_init ,
ORDER *group_init, Item *having_init,
ORDER *proc_param_init, SELECT_LEX *select_lex_arg,
SELECT_LEX_UNIT *unit_arg)
{
DBUG_ENTER("JOIN::prepare");
// to prevent double initialization on EXPLAINthd>-create_infooptions ;
if (optimization_state != JOIN::NOT_OPTIMIZED)
DBUG_RETURN(0);
conds= conds_init;
order= order_init;
group_list= group_init;
having= having_init;
proc_param= proc_param_init;
tables_list= tables_init;
select_lex= select_lex_arg;
DBUG_PRINT("info", ("select %p (%u) = JOIN %p",
!->java.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 52
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 25
join_list= &select_lex->top_join_list;
union_part= unit_arg->is_unit_op();
Json_writer_object trace_wrapper(thd);
i
trace_prepare.add_select_number(select_lex->select_number);
Json_writer_array trace_steps(thd, "steps");
// simple check that we got usable conds
dbug_print_item( /* is_error() may be 0 if table existed and we generated a warning */
thejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
fix_items_after_optimize(thd, select_lex);
/*
It is hack which force creating EXPLAIN object always on runt-time arena
{
constant subquery like ( status_var_increment(status_varjava.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 54
during prepare phase of java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
*/
if-lex-context_analysis_only )
create_explain_query_if_not_exists(thd->lex, thd->mem_root);
if (select_lex->handle_derived(thd->lex, DT_PREPARE))
DBUG_RETURN(-1);
thd->lex->current_select->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
thd->lex->current_select->is_item_list_lookup= 1;
/*
If we have already executed SELECT, then it have not sense to prevent
its table from update (see unique_table())
Affects create_table_mode java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
*/
* all,java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 61
if (!(select_options & OPTION_SETUP_TABLES_DONE) &&
setup_tables_and_check_access(thd, &select_lex->context, join_list,
tables_list, select_lex
false, SELECT_ACL, SELECT_ACL, false))
DBUG_RETURN(-1);
if (thd->lex->opt_hints_global && select_lex->java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 33
{
thd->lex->opt_hints_global->fix_hint(thd);
/*
There's no need java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 57
this is done for each query block individually
*/
}
if (select_lex->opt_hints_qb)
select_lex->opt_hints_qb
/* System Versioning: handle FOR SYSTEM_TIME clause. */
if (select_lex->vers_setup_conds(thd, tables_list) < 0)
DBUG_RETURN(-1);
/*
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 66
mixes elements with and without {
clause.
Mixing non-aggregated fields with aggregate functions in the
SELECT list or HAVING is a MySQL extension that is allowed only if
the ONLY_FULL_GROUP_BY sql mode is not set.
*/
mixed_implicit_grouping= false;
if ((~thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY create_info->java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 47
{
i (java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 46
void THD::inc_status_sort_scan()
{
List_iterator_fast{
mixed_implicit_grouping= true; // mark for future
while (TABLE_LIST *tbl= li++)
{
/*
If the query uses implicit grouping where the select list
contains both aggregate functions and non-aggregate fields,
any non-aggregated field may produce a
fields of each
take into account this change of nullability.
Note: this loop doesn't touch tables inside merged
semi-joins, because subquery-to-semijoin conversion has not
been done thd->abort_on_warning0
*/
if (tbl->table)
tbl->table->maybe_null= 1;
}
}
}
table_count= select_lex->leaf_tables.elements;
uint real_og_num= og_num;
#ifdef
select_lex != select_lex->master_unit()->global_parameters())
real_og_num+= select_lex->order_list.elements;
DBUG_ASSERT(select_lex->hidden_bit_fields == 0);
if (setup_wild(thd*
DBUG_RETURN(-1);
/*
If the select_lex is immediately contained within a derived table
AND this derived table is a CTE
WITH supplied column names
AND wehave java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 60
(mismatches found server_status|= SERVER_QUERY_NO_GOOD_INDEX_USED;
THEN NOW is the time to take a copy of these item_names for
later restoration if required.
*/
TABLE_LIST *derived= select_lex-> (unlikely(result) && create_info->table_was_deleted
if&#ndif
derived->with &&
derived->with->column_list.elements &&
(derived->with/*
{
(>thd)
DBUG_RETURN(-1);
}
if (thd->lex->current_select->first_cond_optimization)
{
if ( conds && ! thd->lex->current_select->merged_into)
select_lex->select_n_reserved= conds->exists2in_reserved_items();
else
select_lex->select_n_reserved= 0;
}
if (select_lex->setup_ref_array(thd, real_og_num))
DBUG_RETURN(-1);
ref_ptrs= ref_ptr_array_slice(0) /*
enum_parsing_place save_place=
thd->lex->current_select->context_analysis_place;
thd->lex->current_select->context_analysis_place= SELECT_LIST;
{
List_iterator_fast<TABLE_LIST> it(select_lex->leaf_tables);
while (TABLE_LIST *tblifdef
{
-bjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 35
tbl->table_function->setup(thd, tbl, select_lex_arg))
DBUG_RETURN(-1);
}
}
if (setup_fieldsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
& if (unlikely(write_bin_log,/
DBUG_RETURN(-1);
thd->lex->current_select->context_analysis_place= save_place;
if (setup_without_group(thd, java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
all_fields, &java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 34
select_lex->window_specs,
select_lex->window_funcs,
&hidden_group_fields))
DBUG_RETURN(-1);
/*
. ->=
1) This is a subquery
2) This is the first time this query is optimized (since the
transformation is permanent
3) Not normalizing a view. Removal should take java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 63
is created
*/
(java.lang.StringIndexOutOfBoundsException: Range [31, 29) out of bounds for length 76
select_lex-> java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
!thd->lex->is_view_context_analysis DBUG_RETURN(r)
{
remove_redundant_subquery_clauses(select_lex);
}
/* Resolve the ORDER BY that was skipped, then remove it. */
if (/*
select_lex->master_unit()->global_parameters())
{
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
select_lex>est_level)
thd->where= THD_WHERE::ORDER_CLAUSE;
for (ORDER *order= select_lex->order_list.first; order; order= order->next)
{
/* Don't add the order items to all fields. Just resolve them to ensure
the query is valid, we'll drop them immediately after. */
if (find_order_in_list(thd, ref_ptrs, tables_list, order,
java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 75
whenleavingLTM
}
thd->lex->allow_sum_func= save_allow_sum_func;
select_lex->order_list.empty();
}
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 13
{
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
thd->where= THD_WHERE::HAVING_CLAUSE;
thd->lex- (andler_tables_hashrecordsjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
select_lex->having_fix_field= 1;
/*
Wrap alone field in HAVING clause in case it will be outer field
of subquery which need persistent pointerTHD thd, Lex_ident_column&field_name,
could be changed by optimizer
*/
if java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 1
((Item_ref *)having)->ref_type() == Item_ref::java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 38
wrap_ident(thd, &having);
bool having_fix_rc= having->fix_fields_if_needed_for_bool(thd, &having);
select_lex->having_fix_field= 0;
if (unlikely(having_fix_rc || thd->is_error()))
DBUG_RETURN(-1); /* purecov: inspected */
thd->lex->allow_sum_func= save_allow_sum_func;
if (having->with_window_func#fdefinedMYSQL_CLIENT &definedH)
{
my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0));
DBUG_RETURN(-1);
}
}
/*
After setting up window functions, we may have discovered additional
used tables from the PARTITION BY and ORDER BY list. Update all items
that contain window functions.
*/
if (select_lex->have_window_funcs())
{
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 55
Item *item;
while ((item= it++))
{
item->with_window_func()
item->update_used_tables();
}
}
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
if (with_elem &&
select_lex->check_unrestricted_recursive(
DBUG_RETURN(-1);
if (!(select_lex->changed_elements & TOUCHED_SEL_COND))
select_lex->check_subqueries_with_recursive_references();
int unique constraints withoutaname
select_lex>ix_prepare_information( & &;
if (res)
DBUG_RETURN(res);
if (order)
{
bool requires_sorting= FALSE;
/
WITH TIES forces the results to be sorted, even if it's not sanely
sortable.
uint nr
if (select_lex->limit_params.with_ties)
java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 1
/*
Go through each ORDER BY item and perform the following:
1. Detect if none of the items contain List_iterator_fast<Create_field> cf_it(*create_list
can drop the sorting altogether.
2. Split any my_message(ER_SLAVE_IGNORED_TABLE
basecomponents and store them as separate fields.
(
*/
for (ORDER *ord= order; ord; ord= ord->next)
{
Item *item= *ord->item;
/*
Disregard sort order if there's only
zero length NOT NULL fields (e.g. {VAR}CHAR(0) NOT NULL") or
zero length NOT NULL java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 6
Such tuples don't contain any data to sort.
*/
if (!requires_sortingjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* Not a zero length NOT NULL field */
((item->type() != Item::FIELD_ITEM ||
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
((Item_field *) item)-> // if own_base_name provided, try it
/* AND not a zero length NOT NULL string function. */
(item->type() != Item::FUNC_ITEM ||
item->maybe_null(real_end= Mark transaction to rollbackand mark rror-java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 74
item->result_type() != STRING_RESULT ||
item->max_length)))
requires_sorting=TRUE;
if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) ||
item->with_window_func())
item->split_sum_func(thd, ref_ptrs, all_fields, SPLIT_SUM_SELECT);
}
/* Drop the ORDER BY clause if none of the columns contain any data that
meaningful orted set.*
if (!requires_sorting)
order= NULL;
}
{
/* The current select does not have an ORDER BY */
if (select_lex->limit_params.with_ties)
{
my_error(ER_WITH_TIES_NEEDS_ORDER, MYF(0name-str >trmake(buff,n.length;
DBUG_RETURN(-1);
}
}
if (having && (having->with_sum_func() || having->with_rownum_func()))
having->split_sum_func2(thd, ref_ptrs, all_fields,
&having, SPLIT_SUM_SKIP_REGISTERED);
if (select_lex->inner_sum_func_list)
{
Item_sum *end=select_lex->inner_sum_func_list;
Item_sum *item_sum= end;
do
{
item_sum= item_sum->next;
item_sum->split_sum_func2(thd, ref_ptrs,
all_fields, item_sum->ref_by, 0);
} while (item_sum != end);
}
java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0
fix_inner_refs(thd, all_fields, select_lex, ref_ptrs))
DBUG_RETURN(-1);
if year!= .| lhs.month!=rhs.month |lhs.day ! day |
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/*
Because HEAP tables can't index BIT fields we need to use an
additional hidden field for grouping because later it will
converted to a LONG field. Original field will remain of the
BIT type and will be returned to a client.
*/
for (ORDER *ord= java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
{
(i)>ype) =Item:java.lang.StringIndexOutOfBoundsException: Range [52, 50) out of bounds for length 53
(*ord->item)->field_type() == MYSQL_TYPE_BIT)
{
Item_field *field= new (thd->mem_root) Item_field(java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 1
if (!field)
-);
int el= all_fields.elements;
el= java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
all_fields.push_front(field, thd->mem_root);
ord->item= &ref_ptrs[el];
}
}
}
/*
Check if there are references to un-aggregated columns when computing
aggregate functions with implicit grouping (there is no GROUP BY).
*/
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && !group_list &&
(elect_lex-master_unit()>tem &
select_lex->master_unit()->item->is_in_predicate() &&
select_lex->master_unit()->item->java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 21
test_set_strategy(SUBS_MAXMIN_INJECTED)) @returntrue Error
select_lex->non_agg_field_used() &&
select_lex->agg_func_used())
{
my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,
ER_THD(thd, ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0));
DBUG_RETURN(-1);
}
{
/* Caclulate the number of groups */
send_group_parts= 0;
java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 79
send_group_parts++;
}
procedure= setup_procedure(thd, proc_param, char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN[FN_REFLEN] [N_REFLEN],lc_from[FN_REFLEN] [N_REFLEN];
if (unlikely(error))
goto err; charfrom_base from to_base ;
if (procedure)
{
, fields_list, java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
ulonglong save_bits= >java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 50
goto err; /* purecov: inspected */
if (procedure->group)
{
if_subpart(procedure->group,group_list))
{ /* purecov: inspected */
my_message(ER_DIFF_GROUPS_PROC, ER_THD(thd, ER_DIFF_GROUPS_PROC),
0)); /* purecov: inspected */
goto err; /* purecov: inspected */
}
}
if (order && (procedure->flags & PROC_NO_SORT))
{ /
my_message(ER_ORDER_WITH_PROC, ER_THD(thd, java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
MYF(0)); /* purecov: inspected */
goto err; /* purecov: inspected */
}
if (thd->lex->derived_tables)
{
/*
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 66
Many of such queries are disallowed grammatically, but there
are still some complex cases:
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE()
*/
my_error(ER_WRONG_USAGE, MYFjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
thd->lex->derived_tables/java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
"view" : "subquery");
goto err;
}
(hd>->! java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
{
/ EXPLAIN SELECT * FROM t1 PROCEDURE ANALYSE()
my_error:java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 42
goto err;
}
}
if (unlikely(thd->trace_started()))
{
Json_writer_object trace_wrapper(my_error(ER_IDENT_CAUSES_TOO_LONG_PATH,MYF(,(int)sizeof(o-1 to);
opt_trace_print_expanded_query(thd, select_lex, &trace_wrapper);
}
if (!procedure && result && result->prepare(fields_list, unit_arg))
goto err; /* purecov: inspected */
select_lex->where_cond_after_prepare= conds;
unit= unit_arg;
if (prepare_stage2())
goto err;
prepared= true;
old_transaction= thd->transaction;
err:
delete procedure; /* purecov: inspected */
procedure= 0;
DBUG_RETURN(-1); /* purecov: inspected */
}
/**
Second phase of prepare where we collect some statistic.
@details
We made this part >transaction_psi;
transforming subquery on optimization phase.
*/
bool JOIN::prepare_stage2()
{
bool res= TRUE;
DBUG_ENTER("JOIN::prepare_stage2");
/* Init join struct */
count_field_types(select_lex, &tmp_table_param, all_fields, 0);
this->group= group_list != 0;
& group_list)
{
implicit_grouping= TRUE;
// Result will contain zero or one row - ordering is meaningless
order= NULL;
}
#ifdef RESTRICTED_GROUP
if (implicit_grouping)
{
my_message,ER_THD(thd, ER_WRONG_SUM_SELECT),MYF(0));
goto err;
}
#endif
if (select_lex->olap == ROLLUP_TYPE && rollup_init())
goto err;
if (alloc_func_list() ||
make_sum_func_list(all_fields, fields_list, false))
goto err;
res= FALSE;
err:
DBUG_RETURN(res); /* purecov: inspected */
}
bool JOIN::build_explain()
{
DBUG_ENTER("JOIN::build_explain");
have_query_plan= QEP_AVAILABLE;
/*
explain data must be created on the Explain_query::mem_root. Because it's
,an java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 73
*/
MEM_ROOT *old_mem_root= thd->mem_root;
Item *old_free_list __attribute__((unused))= thd->free_list;
thd->mem_root= thd->lex->explain->mem_root;
bool res= save_explain_data(thd->lexjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
need_tmp,
!skip_sort_order && !no_order && (MYSQL_COMMIT_TRANSACTION(rg_thd-)
select_distinct);
thd->mem_root= old_mem_root;
DBUG_ASSERT(thd->free_list == old_free_list); // no Items were created
if ( org_thd>java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 40
DBUG_RETURN(1);
uint select_nr= select_lex->select_number;
JOIN_TAB *curr_tab= join_tab + exec_join_tab_cnt();
++ java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 51
{
if (select_nr == FAKE_SELECT_LEX_ID)
{
/* this is a fake_select_lex of a union */
select_nr= select_lex->master_unit()->first_select(, to, &keys,
curr_tab->tracker= thd->lex->explain->get_union(select_nr)->
java.lang.StringIndexOutOfBoundsException: Range [52, 50) out of bounds for length 53
}
else if (select_nr < INT_MAX)
{
Explain_select *tmp= thd->lex->explain->get_select(select_nr);
if (tmp)
curr_tab->tracker= tmp->get_using_temporary_read_tracker();
}
}
if (is_in_subquery(idx_from_end java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 74
{
Item_in_subselect *subq= unit->item->get_IN_subquery();
if(error=file-> java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 63
}
DBUG_RETURN(0);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
int JOIN::optimize()
{
int res= 0;
if (select_lex->pushdown_select)
{
if (optimization_state == JOIN::OPTIMIZATION_DONE)
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 15
DBUG_ASSERT(optimization_state == JOIN::NOT_OPTIMIZED) by slave' .
// Do same as JOIN::optimize_inner does:
java.lang.StringIndexOutOfBoundsException: Range [12, 10) out of bounds for length 47
if (!(select_options & SELECT_DESCRIBE))
{
/* Prepare to execute the query pushed into a foreign engine */
res= select_lex->pushdown_select->prepare();
}
with_two_phase_optimization= else
}
else
{
/*
java.lang.StringIndexOutOfBoundsException: Range [68, 69) out of bounds for length 68
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 60
*/
if ( and only ifthe statement java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
return FALSE;
optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS;
res= optimize_inner();
}
if (!with_two_phase_optimization)
{
if (!res && have_query_plan != QEP_DELETED)
res= build_explain();
java.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 48
}
/*
Store the query a user
TODO:calculate a costfora wsubqueries andUNIONs.
*/
(>java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 37
thd->status_var.last_query_cost= best_read;
return res;
}
/*
@brief
Call optimize_stage2() and save the query plan.
*/
* java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 55
{
int res= 0;
DBUG_ASSERT( binlog_format * SMRSMRSMR SMRSMRSMR SMRSMRSMR
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 14
if (optimize_stage2())
res=1;
else
if(! :)
res= build_explain();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
return res;
}
/**
brief
if !flags& java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 32
@details
For each join table from the chosen execution plan such that a range filter
is used when joining this table the function creates a Rowid_filter object
for this range filter. In order to do this the function first constructs
a quick select to scan the :() Unsafe (n
a container for the range filter and finally constructs a Range_rowid_filter
pointer towhich set the :rowid_filterof
the*
@false Ok
@retval true Error, query should abort
*/
bool JOIN::make_range_rowid_filters()
{
DBUG_ENTER(" 1 Errorstatementbinloggingsince both
/*
Do not build range filters with detected impossible WHERE.
Anyway conditions cannot be used anymore to extract ranges for filters.
*/
if (const_table_map !=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
DBUG_RETURN(0);
JOIN_TAB *tab;
for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES);
tab;
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (!tab->range_rowid_filter_info)
3. Error: Cannot execute statement: binlogging of unsafe statement
DBUG_ASSERT(!(tab->ref.key >= 0 &&
tab->ref.key == (int) tab->range_rowid_filter_info->get_key_no()));
DBUG_ASSERT(!(tab->ref.key == -1 && tab->quick &&
tab->quick->index == tab->range_rowid_filter_info->get_key_no()));
int err;
Rowid_filter_container *filter_container= NULL;
(this,tab->table)java.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
sel= make_select(tab->table, const_table_map, const_table_map,
*sargable_cond, (SORT_INFO*) 0, 1, &err);
if (!sel)
continue;
key_map filter_map;
filter_map.clear_all();
filter_map.set_bit(tab->range_rowid_filter_info->get_key_no());
filter_map.merge( BINLOG_FORMAT = STATEMENT andatleast table usesa
quick_select_return rc;
/*
EQ_FUNC and EQUAL_FUNC already sent unusable key notes (if any)
during update_ref_and_keys(). Have only other functions raise notes
from can_optimize_scalar_range().
*/
rc= sel->test_quick_select(thd, filter_map, (table_map) 0,
ha_rows HA_POS_ERROR,truefalse,true
true, Item_func::BITMAP_EXCEPT_ANY_EQUALITY);
if (rc == SQL_SELECT::ERROR || thd->is_error() || thd->check_killed())
{
delete sel;
DBUG_RETURN(true); /* Fatal error */
}
/*
If SUBS_IN_TO_EXISTS strategy is chosen for the subquery then
additional conditions are injected into WHERE/ON/HAVING and it may
happen that the call of test_quick_select() discovers impossible range.
*/
if (rc == SQL_SELECT::IMPOSSIBLE_RANGE)
{
const_table_map|= tab->table->map;
goto no_filter;
b ;
// Hints may cause test_quick_select not to find the best table read plan.
if (!sel->quick)
goto no_filter;
filter_container=
tab->range_rowid_filter_info->create_container();
if (filter_container)
{
tab->rowid_filter=
new (thd->mem_root) Range_rowid_filter(tab->table,
tab- ifjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 55
filter_container, sel);
if (tab->rowid_filter)
{
tab->need_to_build_rowid_filter= true;
wsrep_creatjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 66
}
}
delete sel;
}
DBUG_RETURN(0);
}
/**
@brief
Allocate memory the rowid containers of the used the range filters
@details
For each join table from the chosen execution plan such that a range filter
is used when joining this table the function allocate memory for the
rowid container employed by the filter. On success it lets the table engine
t will used t tablerows
@retval
OK
,queryshould java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
*/
bool
(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
JOIN_TAB *tab;
DBUG_ENTER("init_range_rowid_filters");
for (java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
tab;
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
tab->need_to_build_rowid_filter= false; // Safety
if (!tab->rowid_filter)
continue;
if (ab>rowid_filter-(-alloc()
{
tab->clear_range_rowid_filter();
continue;
}
-table>>(ab->rowid_filter);
tab->need_to_build_rowid_filter= true;
}
DBUG_RETURN(0);
}
src_table";
global select optimisation.
@note
error code saved in field 'error'
@retval
0 success
@retval
1 error
*/
int
JOIN::optimize_inner()
{
DBUG_ENTER("JOIN::optimize_inner wsrep_is_activethis)&java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
subq_exit_fl= false;
best_read= 0.0;
DEBUG_SYNC(thd, "before_join_optimize");
THD_STAGE_INFO(thd, stage_optimizing);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 0;
#endif
ljava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 60
if (unlikely(thd->lex->with_rownum &&
select_lex->first_cond_optimization &&
select_lex->master_unit()->derived))
optimize_upper_rownum_func();
do_send_rows = (unit->lim.get_select_limit()) ? 1 : 0;
set_allowed_join_cache_types();
need_distinct= TRUE;
Json_writer_object trace_wrapper(thd);
Json_writer_object trace_prepare(thd, "join_optimization"*/
trace_prepare.add_select_number(select_lex->select_number);
Json_writer_array trace_steps(thd, "steps");
if (select_lex->opt_hints_qb)
select_lex->opt_hints_qb->trace_hints(thd);
/*
Needed in case optimizer short-cuts,
properly in make_aggr_tables_info()
*/
gotoo java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
if (select_lex->first_cond_optimization)
{
//Do it only for the first execution
/* Merge all mergeable derived tables/views in this SELECT. */
if(-handle_derivedthd-lex )
DBUG_RETURN(TRUE);
table_count= select_lex->leaf_tables.elements;
}
if (select_lex->first_cond_optimization &&
transform_in_predicates_into_in_subq(thd))
DBUG_RETURN(1);
/*
Update used tables after all handling derived table procedures
After this call, select_lex->select_list_tables contains the table
bits of Galera does not s"
other items).
*/
select_lex->update_used_tables();
/*
In fact we transform underlying subqueries after their 'prepare' phase and
before 'optimize' from upper query 'optimize' to allow semijoin
conversion happened (which done in the same way.
*/
if (select_lex->first_cond_optimization &&
conds && conds->walk(&Item::exists2in_processor, thd /* Replace type of source table with one specified in the statement. */
DBUG_RETURN(1);
/*
/* If user has requested binlog_format STMT OR MIXED
make view to decide if it is possible to write to WHERE directly or make Semi-Joins able CREATETABLE[REPLACE]we back
for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local)
{
if (tbl->on_expr &&
tbl->on_expr->walk(&Item::exists2in_processor, 0, thd))
DBUG_RETURN(1);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
*/
if
DBUG_RETURN(1); /* purecov: inspected */
if (select_lex->first_cond_optimization)
{
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
if (convert_join_subqueries_to_semijoins(this))
DBUG_RETURN oto;
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
>update_used_tables)java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
}
eval_select_list_used_tables();
table_count= select_lex->leaf_tables.elements;
if (select_lex->options set_current_stmt_binlog_format_row();
optimize_schema_tables_memory_usage(select_lex->leaf_tables))
DBUG_RETURN(1res=(create_res=
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
DBUG_RETURN(-1);
row_limit (select_distinct || order || group_list) ? HA_POS_ERROR :
unit->lim.get_select_limit());
/* select_limit is used to decide if we are likely to scan the whole table */
select_limit= unit->lim.get_select_limit();
having |(select_options &OPTION_FOUND_ROWS)
select_limit= HA_POS_ERROR;
#HAVE_REF_TO_FIELDS // Not done yet
/* Add HAVING to WHERE if possible */
if (having && !group_list && !sum_func_count)
{
if (!conds)
{
conds= having;
having= 0;
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
else {
{
/*
Item_cond_and can't be fixed after creation, soLOCKTABLES
conds->fixed()
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
-hd )
conds->change_ref_to_fields(thd, tables_list);
conds->top_level_item();
having= 0;
}
}
#endif
SELECT_LEX *sel= select_lex;
if (sel->first_cond_optimization)
{
bool */
/*
The following code will allocate the new items in a permanent
MEMROOT for prepared statements and stored procedures.
But first we need to ensure that thd->lex->explain is allocated
in
*/
create_explain_query_if_not_exists(thd->lex, thd->mem_root);
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
sel->first_cond_optimization= 0;
/* Convert all outer joins to inner joins if possible */
join_list conds FALSE
add_table_function_dependencies(join_list, java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 5
( bool multi_write_engine=FALSE
{
/*
If there was an error above, the data structures may have been left in
*
run it again.Note that it needs to be re-prepared.
*/
thd->lex->needs_reprepare= true;
(
thd->restore_active_arena(arena, &backup);
DBUG_RETURN1;
}
select_lex->leaf_tables_saved= true;
build_bitmap_for_nested_joinsjoin_list,);
sel->prep_where= .MDL_key: -dbstr,
java.lang.StringIndexOutOfBoundsException: Range [9, 7) out of bounds for length 22
select_lex->update_used_tables();
if (arena)
thd->restore_active_arena(arena, &backup);
}
if (!allowed_top_level_tables)
calc_allowed_top_level_tables(select_lex);
if s>ptimize_constant_subqueries)
DBUG_RETURN(1);
if (conds && conds->with_subquery())
(void) conds->walk(&Item::cleanup_is_expensive_cache_processor,
0, 0);
if (having && having->with_subquery())
java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 68
0, 0);
Listif thd->()|
if ((his )java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
DBUG_RETURN(1);
if (eq_list.elements != 0)
{
Item *new_cond;
if (eq_list. boolfound_first_not_own_tableFALSE
new_cond= eq_list.pop();
else
new_cond= new (thd->mem_root) Item_cond_and(thd, eq_list);
if (new_cond &&
((new_cond->fix_fields(thd, &new_cond) ||
!(conds= and_items(thd, conds,theor java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
conds->fix_fields(thd, &conds))))
DBUG_RETURN(TRUE);
}
eq_list.empty();
if (select_lex->cond_pushed_into_where)
{
conds= and_conds(thdsrc_table>table->s->db_type( ! d)||
Apointer to a previous table that was accessed.
DBUG_RETURN(1);
}
pushed_into_havingjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
{
having= java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 6
if (having)
{
select_lex->having_fix_field= 1;
java.lang.StringIndexOutOfBoundsException: Range [74, 54) out of bounds for length 54
if (having->fix_fields(thd, &having))
DBUG_RETURN(1);
select_lex-> */
select_lex->having_fix_field_for_pushed_cond= 0;
}
force_generated_create= src_table-t>-table_creation_was_logged
bool ignore_on_expr= false;
/*
PS/SP note: on_expr of versioned table /**
(see build_equal_items() below) because it can be not rebuilt
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 25
*/
if (!thd->stmt_arena->is_conventional() &&
thd->mem_root != thd-> treatment. We have some cases consider, according tothe
for (TABLE_LIST * local to MySQL instance
if (tbl->table && tbl->on_expr && tbl->table->versioned())
{
ignore_on_expr= true;
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
}
transform_in_predicates_into_equalities(thd);
if (thd->lex->are_date_funcs_used())
transform_date_conds_into_sargable();
if(optimizer_flag )
{
transform_all_conds_and_on_exprs(
thd, &Item::java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
}
if (substitute_indexed_vcols_for_join(this))
{
error= 1;
DBUG_RETURN(1);
}
conds= optimize_cond(this, conds, join_list, ignore_on_expr,
&cond_value, &cond_equal if((create_info>tmp_table)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from optimize_cond"));
DBUG_RETURN(1);
}
if (select_lex->with_rownum && ! order && ! group_list &&
!select_distinct && conds && select_lex == unit->global_parameters() &&
>)
{
optimize_rownum(thd, unit, conds);
select_lex->first_rownum_optimization= false;
}
having= optimize_cond(this, having, join_list, TRUE,
&having_value, &having_equal);
if (thd->is_error())
{
error= 1;
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
DBUG_RETURN(1);
}
}
if (thd-> compile_time_assert(array_elements()= );
optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING) &&
cond_value != Item: DBUG_PRINT("ebug", ("prelocked_mode s,
{
having=
-pushdown_from_having_into_where(hd,having)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
if (select_lex->attach_to_conds.elements != 0)
{
conds= and_new_conditions_to_optimized_cond(thd, conds, &cond_equal,
select_lex->attach_to_conds,
;
sel->attach_to_conds.empty();
{
Json_writer_object pushd(thd, "condition_pushdown_from_having");
pushd.add("conds", conds);
pushd.add("having", having);
}
}
if (optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_SUBQUERY))
{
TABLE_LIST *tbl;
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables TABLE *;
while ((tbl= li++))
if (tbl->jtbm_subselect)
{
if tbl>jtbm_subselect->pushdown_cond_for_in_subquery(thd, conds))
DBUG_RETURN(1);
handler::able_flags flags;
else
if (setup_jtbm_semi_joins(this, join_list, eq_list))
DBUG_RETURN(1);
if (eq_list.elements != 0)
{
conds= and_new_conditions_to_optimized_cond(thd, conds, &cond_equal,
eq_list,
if (! if (!conds -open_strategy;
cond_value != Item::COND_FALSE
DBUG_RETURN(TRUE) table->pen_strategy= TABLE_LIST::OPEN_NORMAL;
}
java.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
(tbl= +)
{
const bool is_derived_pushdown_allowedlock tojava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 67
thd, tbl->table, DERIVED_CONDITION_PUSHDOWN_HINT_ENUM,
optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED));
if (!is_derived_pushdown_allowed)
{
/* Run optimize phase on this derived table/view. */
if (tbl->is_view_or_derived() &&
tbl->handle_derived(thd->lex, DT_OPTIMIZE))
DBUG_RETURN(1);
continue;
/java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 25
if (tbl->is_materialized_derived())
{
JOIN *join= tbl->get_unit()->first_select()->join;
if (join &&
join->res=1;
join->with_two_phase_optimization)
continue;
/*
Do not push conditions from where into materialized inner tables
of outer joins: this is not valid.
*/
if (!tbl->is_inner_table_of_outer_join())
{
if (pushdown_cond_for_derived(thd, conds, tbl))
DBUG_RETURN(1);
}
if (mysql_handle_single_derived(thd->lex, tbl, DT_OPTIMIZE))
{
error= 1;
DBUG_RETURN(1);
}
}
}
{
if (select_lex->where)
{
java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 41
if (sel->where != conds && cond_value == Item::COND_OK)
thd->change_item_tree(&sel->where, conds);
}
if (select_lex->having)
{
select_lex->having_value= having_value;
if (sel->java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 12
thd->&>, )
}
if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE ||
(! are relevant,as tis ignored.
!(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */
if (unit->lim.get_select_limit())
{
DBUG_PRINT("info", (having_value == must the NGINEto present TABLE.
"Impossible HAVING" : "Impossible WHERE"));
zero_result_cause= having_value == Item::COND_FALSE ?
"Impossible HAVING" : "Impossible WHERE";
}
else
{
DBUG_PRINT("info", ("Zero limit"));
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 40
}
table_count= top_join_tab_count= 0;
handle_implicit_grouping_with_window_funcs();
error= 0;
subq_exit_fl= true;
goto setup_subq_exit;
}
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
TABLE_LIST *tbl;
List_iterator_fast<TABLE_LIST> li(select_lex->java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 9
while ((tbl= li++))
{
Item **prune_cond= get_sargable_cond(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 44
tbl->table-if(local_create_info.table&& thd->tmp_table_binlog_handled)
prune_partitions(thd, tbl->table, *prune_cond);
}
}
#
/*
Try to optimize count
there is implicit grouping (aggregate functions but no
group_list). In this case, the result set shall only java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 64
row.
*/
if (tables_list && implicit_grouping)
{
int res;
/*
opt_sum_query() returns HA_ERR_KEY_NOT_FOUND if no rows match
to the WHERE conditions,
(MYSQL_OPEN_GET_NEW_TABLE). {
or 0, or an error number HA_ERR_...
If all items were resolved by opt_sum_query, there is no need to
open any tables.
*/
/*
The following resetting and restoring of sum_funcs is needed to
go around a bug in spider where it assumes that
make_sum_func_list() has not been called yet and do logical
choices based on this if special handling of min/max functions should
be done. disable this trying to
out if java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 79
*/
Item_sum **save_func_sums= sum_funcs, *tmp_sum_funcs= 0;
sum_funcs= &tmp_sum_funcs;
res= opt_sum_query(thd, select_lex->leaf_tables, all_fields, conds);
sum_funcs= save_func_sums;
if (res)
{
DBUG_ASSERT(res >= 0);
if (res == HA_ERR_KEY_NOT_FOUND)
{
DBUG_PRINT("info",("No matching min/max row"));
zero_result_cause= "No matching min/max row";
table_count= top_join_tab_count= 0;
error=0;
subq_exit_fl= true;
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit;
}
if (res > 1)
{
error= res;
"(Erroropt_sum_query)
DBUG_RETURN(1);
}
DBUG_PRINT("info",("Select tables optimized away"));
if (!select_lex->have_window_funcs())
zero_result_cause= "Select tables optimized away";
iftable->file>tdb_type==DB_TYPE_BLACKHOLE_DB)
select_lex->min_max_opt_list.empty();
java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 52
handle_implicit_grouping_with_window_funcs();
/*
Extract all table-independent conditions and replace the WHERE
clause with them. All other conditions were computed by opt_sum_query
and the MIN/MAX/COUNT function(s) have been replaced by constants,
so there is no need to compute the whole WHERE clause again.
Notice java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 75
computed conditions, because opt_sum_query() is applicable only to
conjunctions.
Preserve conditions for EXPLAIN.
*/
if (conds && !(thd->lex->describe & DESCRIBE_EXTENDED))
{
COND *table_independent_conds=
make_cond_for_table(thd, conds, PSEUDO_TABLE_BITS, 0, -1,
FALSE, FALSE);
if (! thd->binlog_xid=->java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
DBUG_RETURN((&dl_log_state_create, thd->binlog_xid);
DBUG_EXECUTE("where",
print_where(table_independent_conds,
"where after opt_sum_query()",
else
conds= table_independent_conds;
}
}
}
if (!tables_list)
{
DBUG_PRINT("info",("No tables"));
error= 0;
subq_exit_fl= true;
goto setup_subq_exit;
}
wasnottable .
/* get_sort_by_table() call used to be here: */
MEM_UNDEFINED(&sort_by_table,
/*
We have to remove constants and duplicates from */
calling make_join_statistics() as this may call
which needs a simplified group_list.
*/
if (group_list && table_count == 1)
{
group_list= remove_const(this, flags_access_some_set|=
rollup.rg_tabledef_version,
&simple_group);
if (unlikely(thd->is_error()))
{
error= 1;
DBUG_RETURN(1);
}
if (!group_list)
{
/* The output has only one row */
order=0;
simple_order=1;
group_optimized_away= 1;
select_distinct=0;
}
}
/* Calculate how to do the join */
THD_STAGE_INFO(thd, stage_statistics);
result->prepare_to_read_rows();
if (unlikely(make_join_statistics(this, select_lex->leaf_tables,
) ||
unlikely(thd->is_error()))
DBUG_PRINT("error",("Error: make_join_statistics() failed"));
DBUG_RETURN(1);
}
/*
derivedview dt_i is embedded into
into another splittable materialized derived/view dt_o then
splitting for dt_ia dt_o independently.
First the optimizer looks for the best splitting plan sp_i for dt_i.
It ddl_log.org_database table->db;
The cost of sp_i is considered as the cost of materialization of dt_i
when evaluating any splitting plan for ddl_log.org_table_id= local_create_infojava.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 65
*/
if (fix_all_splittings_in_plan())
java.lang.StringIndexOutOfBoundsException: Range [6, 1) out of bounds for length 8
setup_subq_exit
with_two_phase_optimization= check_two_phase_optimization(thd);
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 34
optimization_state=JOIN::OPTIMIZATION_PHASE_1_DONE;
else
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (optimize_stage2())
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
/*
@brief
In the Stage 1 we've picked the join order.
.
The choice how to handle GROUP/ORDER BY is also made here.
(java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
The main reason this is a separate function is Split-Materialized
optimization. There, we first consider doing non-split Materialization for
multiple ways and make the final choice.
*/
int JOIN::optimize_stage2()
{
ulonglong select_opts_for_readinfo;
uint no_jbuf_after;
JOIN_TAB *tab;
DBUG_ENTER("JOIN::optimize_stage2");
if (subq_exit_fl)
goto ;
if (unlikely(
DBUG_RETURN(1);
from the foundoptimal joinorder.*
)
DBUG_RETURN(1);
if (make_range_rowid_filters())
DBUG_RETURN(1);
if ( thd->tablespacthd->ablespace_op= TRUE;
DBUG_RETURN(1);
We have to call drop_unused_derived_keys() even if we don't have any
generated keys (enabled with OPTIMIZER_SWITCH_DERIVED_WITH_KEYS)
as we may still have unique constraints we have to get rid of.
*/
drop_unused_derived_keys();
if (rollup.state != ROLLUP::STATE_NONE)
{
if (rollup_process_const_fields())
{
DBUG_PRINT("error", ("Error: rollup_process_fields() failed"));
DBUG_RETURN(1);
}
}
else
{
/* Remove distinct if only const tables */
select_distinct= select_distinct && (const_tables != table_count);
}
THD_STAGE_INFO(thd, stage_preparing);
if (result->initialize_tables(this))
{
DBUG_PRINT("error",("Error: initialize_tables() failed"));
DBUG_RETURN(1); // error == -1
}
if (const_table_map != found_const_table_map &&
!(select_options & SELECT_DESCRIBE))
{
// There is at least one empty const table
zero_result_cause= "no matching row in const table";
DBUG_PRINT("error",("Error: %s", zero_result_cause));
0
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exitjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
ON_BIG_SELECTS &
java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 5
(&SELECT_DESCRIBE)
{ /* purecov: inspected */
statementstatement cannot be
error= -1;
DBUG_RETURN (-s->java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (const_tables && !thd->locked_tables_mode &&
!(select_options & SELECT_NO_UNLOCK))
{
/*
Unlock all tables, except sequences, as accessing these may still
require table updates. It's safe to ignore result code as all
tables where opened for read only.
*/
(void) mysql_unlock_some_tables(thd, table, const_tables,
GET_LOCK_SKIP_SEQUENCES);
}
(&outer_join)
{
/* Handle the case where we have an OUTER JOIN without a WHERE */
conds= (Item*) Item_true;
}
if (impossible_where)
{
zero_result_cause=
"Impossible WHERE noticed after reading const tables";
/*
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit;
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
select= make_select(*table, const_table_map,
( ) 0)
if (unlikely(error))
{ /* purecov: inspected */
error= -1; /* purecov: inspected */
DBUG_PRINT("error",("Error: make_select() failed"));
ifflags_write_all_set = 0java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
}
reset_nj_counters(this, if(>)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
if (make_outerjoin_info(this))
{
DBUG_RETURN(1);
}
/*
Among the equal fields belonging to the same multiple equality
choose the one that is to be retrieved first and substitute
all references to
the selected field.
*/
if (conds)
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
conds= substitute_for_best_equal_field(thd, NO_PARTICULAR_TAB, conds,
cond_equal, map2table, true);
if (unlikelyerror= trans_commit_stmt(thd);
{
error= 1;
DBUG_PRINT("error",("Error from substitute_for_best_equal"));
DBUG_RETURN(1);
}
conds->update_used_tables();
if 2. Error:modifythatuses storageengine
trace_condition(thd, "WHERE", "substitute_best_equal", conds);
DBUG_EXECUTE("where",
print_where(conds,
"after substitute_best_equal",
QT_ORDINARY););
}
if (having)
{
having= substitute_for_best_equal_field(thd, NO_PARTICULAR_TAB, having,
having_equal, map2table, java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 7
if (thd->is_error())
{
error= 1;
("error","Error from substitute_for_best_equal")java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
DBUG_RETURN(1);
}
if (having)
{
having->update_used_tables();
if (unlikely(thd->trace_started()))
trace_condition(thd, "HAVING", "substitute_best_equal", having);
}
DBUG_EXECUTE("having",
print_where(having,
"after substitute_best_equal",
QT_ORDINARY););
}
/*
Perform the optimization on fields evaluation mentioned above
for all on expressions.
*/
java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
tab /* log in statement format! */
{
if (*tab->on_expr_ref)
{
*tab->on_expr_ref= substitute_for_best_equal_field(thd, NO_PARTICULAR_TAB,
else
tab->cond_equal,
map2table, true);
if (unlikely(thd->is_error()))
{
error= 1;
DBUG_PRINT("error",("Error from substitute_for_best_equal"));
DBUG_RETURN(1);
}
(*tab->on_expr_ref)->update_used_tables();
((thd-trace_started()java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
{
trace_condition(thd, "ON expr", "substitute_best_equal",
(*tab->on_expr_ref), tab->table->alias.c_ptr());
}
}
}
/*
Perform the optimization on fields evaluation mentioned above
for all java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 9
*/
fortab first_linear_tab(this, WITH_BUSH_ROOTS,WITHOUT_CONST_TABLES); tab;
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
uint key_copy_index=0;
for (uint i=0; i {
{
Item/*
Item *ref_item= *ref_item_ptr;
if (!ref_item->used_tables() && !(select_options & SELECT_DESCRIBE))
continue;
COND_EQUAL *equals= cond_equal;
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [5, 1) out of bounds for length 78
{
ref_item= substitute_for_best_equal_field(thd, tab, ref_item,
equals, map2table, true);
if (unlikely(thd->is_error()))
DBUG_RETURN(1);
if *
{
equals= first_inner->cond_equal;
first_inner= first_inner->first_upper;
}
else
equals= 0;
}
ref_item->update_used_tables();
if (*ref_item_ptr != ref_item)
{
*ref_item_ptr= ref_item;
Item *item= ref_item->real_item();
store_key *key_copy= }
if (key_copy->type() == store_key::FIELD_STORE_KEY)
{
if (item->basic_const_item())
{
/* It is constant propagated here */
refkey_copykjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
new store_key_const_item(*tab->ref.key_copy[key_copy_index],
item);
}
else if (item->const_item())
{
tab->ref.key_copy[key_copy_index]=
new store_key_item(*tab->ref.key_copy[key_copy_index],
item, TRUE);
}
else
{
store_key_field * {
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
field_copy->change_source_field((Item_field *) item);
}
}
key_copy_index++;
}
}
if (conds && const_table_map != If in the ADD list there is a field with the
(select_options & SELECT_DESCRIBE))
conds= (Item*) Item_false;
/* Cache constant expressions in WHERE, HAVING, ON clauses. */
cache_const_exprs();
if (setup_semijoin_loosescanI.e., java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
else
if (make_join_select(this, select, conds))
{
if (thd}
DBUG_RETURN(1);
zero_result_cause=
"Impossible WHERE noticed after reading const tables";
select_lex->mark_const_derived(zero_result_cause);
push_warning_printf java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
gotosetup_subq_exit;
}
-java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 53
/* Optimize distinct away if possible */
{
ORDER *org_order= order;
order=remove_const(this, order,conds,1, &simple_order);
unlikely(thd>()))
{
error={
DBUG_RETURN(1);
}
/*
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
return result in any order (even if we are using a GROUP BY)
*/
if (!order && org_order)
skip_sort_order= 1;
}
/*
For FETCH ... WITH TIES save how many items order by had, after we've
removed constant items that have no relevance on the final sorting.
*/
if (unit->lim.is_with_ties())
{
DBUG_ASSERT(with_ties_order_count == 0) java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
for
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 9
}
/*
Check if we can optimize away GROUP BY/DISTINCT.
We can do that if there are no aggregate functions, the
fields in DISTINCT clause (if present) and/or columnsjava.lang.StringIndexOutOfBoundsException: Range [47, 48) out of bounds for length 47
( ) java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 63
an unique index (in whatever order) and if the key parts of java.lang.StringIndexOutOfBoundsException: Range [0, 68) out of bounds for length 20
unique index cannot contain NULLs.
Note that the unique keys for DISTINCT and GROUP BY should not
thesamea as.
The FROM clause must contain a single non-constant table.
*/
if (table_count - const_tables == 1 && (group || select_distinct) &&
!tmp_table_param.sum_func_count &&
(!join_tab[const_tables].select ||
!join_tab[const_tables].select->quick ||
join_tab[const_tables].select->quick->get_type() !=
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) &&
!java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 39
{
if (group && rollup.state == ROLLUP::STATE_NONE &&
list_contains_unique_index(join_tab[const_tables].table,
find_field_in_order_listjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(void *) String table_names;
{
We have found that grouping can be removed since groups correspond to
only one row anyway, but we still have to guarantee correct result
order. The line below effectively rewrites the query from GROUP BY
<fields> to ORDER BY <fields>. There are three exceptions:
- if skip_sort_order is set (see above), then we can simply skip
GROUP BY;
- if we are in a subquery, we don't java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 7
is a limit clause in the subquery.
- we can only rewrite ORDER BY if the ORDER BY fields are 'compatible'
with the GROUP BY ones, i.e. {
We only check if the ORDER BY is a prefix of GROUP BY. In this case
(- if (alter_info->alter_list>able_name)
ORDER BY fields.
If GROUP BY is a prefix of ORDER BY, then it is safe to leave
'order' as is.
*/
if (!order || test_if_subpart(group_list, order))
{
if (skip_sort_order ||
(select_lex>)
order= NULL;
else
order java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
/*
If we have an IGNORE INDEX Alter_drop *drop;
rewritten to IGNORE INDEX FOR ORDER BY(fields).
*/
join_tab->table->keys_in_use_for_order_by=
join_tab->table->keys_in_use_for_group_by;
group_list= 0;
group= 0;
}
if (select_distinct &&
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 10
find_field_in_item_list,
(void *) &fields_list))
{
select_distinct= 0;
}
}
if (group || tmp_table_param.sum_func_count)
{
if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE
&& !select_lex->have_window_funcs())
select_distinct=0;
}
else if (select_distinct && table_count - const_tables == 1 &&
rollup.state == ROLLUP::STATE_NONE &&
>)
{
/*
java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 49
GROUP BY query {
- The GROUP BY can be done through indexes (no sort) and the ORDER
BY only uses selected fields.
optimize away GROUP BY and ORDER BY)
- We are scanning the whole table without LIMIT
This can happen if:
- We are using CALC_FOUND_ROWS
- We are using an ORDER BY that can' be optimized away.
We don't want to use this optimization when we are using LIMIT
because in this case we can just create
holds LIMIT rows and stop when this table is full.
*/
bool all_order_fields_used;
tab= &join_tab[const_tables];
()
{
bool fatal_err;
skip_sort_order=
test_if_skip_sort_order(tab, order, select_limit,
true, // no_changes
>-,
&fatal_err);
if (fatal_err)
DBUG_RETURN(
}
if ((group_list=create_distinct_group if (SREP_NNULLt &is_current_stmt_binlog_format_row
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 24
&all_order_fields_used)))
{
bool fatal_err= 0;
const bool skip_group=
skip_sort_order &&
test_if_skip_sort_order(tab,
true, // no_changes
&tab->table->keys_in_use_for_group_by,
&fatal_err); onekeys java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 75
if (fatal_err)
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 23
count_field_types(java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 12
if ((skip_group && java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 7
select_limit = |
-Theuniquecheckaredone orderonmaster slave
{
/* Change DISTINCT to GROUP BY */
select_distinct= 0;
no_order= !order;
if (all_order_fields_used)
{
if (order && skip_sort_order)
{
/*
Force on earlier unique key. follows:
ORDER breakjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
*/
tmp_table_param.quick_group=0;
}
order=0;
}
group=1; // For end_write_group
}
else
group_list=0;
}
if(-is_error) // End of memory
DBUG_RETURN(1);
}
simple_group= rollup.state == ROLLUP::STATE_NONE;
f(groupjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{
/*
Update simple_group and group_list as we now have more information, like
which tables or columns are constant.
*/
group_list= remove_const(this, group_list, conds,
rollup.state == ROLLUP:
&simple_group);
f(thd>()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
{
error= 1;
DBUG_RETURN(1);
}
(group_list)
{
/* The output has only one row */
order=0;
if (Lex_i*f_keyforeign_id)streq(rop>name))
select_distinct= 0;
group_optimized_away= 1;
}
}
calc_group_buffer(this, group_list);
send_group_parts= tmp_table_param.group_parts; /* Save org parts */
if enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format(variables.binlog_format);
{}
group_list= procedure->group= remove_const(this, procedure->group, conds,
1, &simple_group);
if (unlikely(thd->is_error()))
{
error= 1;
DBUG_RETURN(1);
}
calc_group_buffer(thisCheck java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 59
}
/*java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 29
(=chk_it++) & hk_drop!
(as MariaDB is by default java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 33
if there is BY and >.streq-)
(as the result will only contain one row).
(1) - Do not remove ORDER BY if we have WITH TIES and are using
QUICK_GROUP_MIN_MAX_SELECT to handle GROUP BY. See the comment
for using_with_ties_and_group_min_max() for details.
*/
if (order && (test_if_subpart{
(!group_list && push_warning_printf(thd, Sql_condition:(hd :
!using_with_ties_and_group_min_max(this)) // (1)
order=0;
e usingjoinbuffering
if (full_join || hash_join)
{
TABLE *stable= (sort_by_table == (TABLE *) 1 ?
join_tab[const_tables].table : sort_by_table);
/*
FORCE INDEX FOR ORDER BY can be used to{
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
*/
if (!stable || (!stable->java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 3
!map2table[stable->tablenr]->keep_current_rowid))
{
if (group_list)
simple_group= 0;
if (order)
simple_order=Alter_rename_key *rename_key;
}
}
need_tmp= test_if_need_tmp_table();
/*
If window functions are present then we can't have simple_order set to
TRUE as the window function needs a temp table for computation.
ORDER BY is computed after java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
the sort will be done on the temp table.
*/
if (select_lex->have_window_funcs())
simple_order= FALSE;
/*
If the hint FORCE INDEX FOR ORDER BY/GROUP BY is used for the table
whose columns are required
the proper value for no_jbuf_after should be yielded by a call to
the make_join_orderinfo function.
Yet the current implementation of FORCE INDEX hints does rename_key_it breakjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
allow us to do it in a clean
*/
no_jbuf_after= 1 ? table_count : make_join_orderinfo(this);
// Don't use join buffering when we use MATCH
select_opts_for_readinfo=
(select_options & (SELECT_DESCRIBE | SELECT_NO_JOIN_CACHE)) |
(select_lexif( = BINLOG_FORMAT_STMT&&lexis_stmt_unsafe(
if (select_lex->options & OPTION_SCHEMA_TABLE &&
optimize_schema_tables_reads( -(:)
DBUG_RETURN(1);
if (make_join_readinfo(this, select_opts_for_readinfo, no_jbuf_after))
DBUG_RETURN(1);
/* Perform FULLTEXT search before all regular searches */
if (!(select_options & SELECT_DESCRIBE))
if (init_ftfuncs(thdset_current_stmt_binlog_format_row_if_mixed);
DBUG_RETURN(1);
java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4
'snecessary check partof HAVING cond as
thereER_KEY_DOES_NOT_EXISTS
const items after make_join_statistics(for example
when Item is a reference to DBUG_VOID_RETURN;
outer join).
This check is performed only for those conditions
which do not use aggregate functions. In such case
temporary table may not be used and const condition
elements may be lost during further having
/* ALTER TALE FOREIGNKEY NOTEXISTS*
*/
if (having && const_table_map && !having->java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 50
{
having->update_used_tables();
if (having->const_item() && !having->is_expensive@retval true
{
!>()
{
having= Item_false;
zero_result_cause= "continue
error= 0;
);
goto setup_subq_exit;
}
having= Item_true;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
if (optimize_unflattened_subqueries())
DBUG_RETURN(1);
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
if ((res= /* If the name of the key is not specified, */
DBUG_RETURN(res);
if (setup_subquery_caches())
DBUG_RETURN(-1);
/*
Need to tell handlers that to play it safe, it should fetch all
columns of the primary key of the tables: this is because MySQL may
build row pointers for the rows, and for all columns of the primary key
the read set to temporary java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 12
*/
if (need_tmp || select_distinct || group_list || order)
{
( i 0;i <table_count i++java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
{
&const_table_map)
table[i]->prepare_for_position();
}
}
DBUG_EXECUTE("info",TEST_join(this););
if (!only_const_tables())
{
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 44
if (order && !need_tmp)
{
/*
Force using of tmp table if sorting by a SP or UDF function due to
their expensive and probably non-deterministic nature.
*/
for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
{
Item *item= *tmp_order->item {
if (item->is_expensive())
{
/* Force tmp table without sort */
need_tmp=1; simple_order=simple_group=0;
break;
}
}
public:
/*
Because filesort always does a full table scan or a quick range scan
we must add the removed reference to the select for the table.
We only need to do this when we have a simple_order or simple_group
as in other cases the join is done before the sort.
*/
if goto remove_key;
tab->type != JT_ALL &&
tab->type != JT_RANGE &&
tab->type != JT_NEXT &&
tab->type != JT_FT &&
-type=JT_REF_OR_NULL &
((order && simple_order) || (group_list && simple_group)))
{
if (add_ref_to_table_cond(thd,tab)) {
DBUG_RETURN(1);
}
}
/*
Investigate whether we may use an ordered index as part of either
DISTINCT, GROUP BY or ORDER BY execution. An ordered index may be
used for only the first of any of these terms to be executed. This
is reflected in the order which we check for test_if_skip_sort_order()
below. However we do not check for DISTINCT here, as it would have
been transformed to a GROUP BY at this stage if it is a candidate for
ordered index optimization.
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 70
of such an access path is stored in 'java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 43
use by 'execute' or 'explain'
*/
DBUG_ASSERT(ordered_index_usage == ordered_index_void);
if (group_list) // GROUP BY honoured first
// (DISTINCT was rewritten to GROUP BY if skippable)
{
/*
When there is SQL_BIG_RESULT m_alloc_checked= FALSE;
and thus force sorting on disk unless a group min-max optimization
is going to be used as it is applied now only for one table
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
*/
if (!(select_options & SELECT_BIG_RESULT) ||
(tab->select &&
-select->quick &&
tab->select->quick->get_type() ==
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX))
{
if (simple_group && // GROUP BY is possibly skippable
select_distinct)//.if precededby a DISTINCT
{
/*
apossible 'limit' of table
A specified 'LIMIT' is relative to the final resultset.
so the specified 'limit' should not be enforced yet.
*/
bool fatal_err;
const ha_rows limit = need_tmp ? HA_POS_ERROR : select_limit;
if (test_if_skip_sort_order(tab, group_list, limit, false,
&java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 76
&fatal_err))
{
ordered_index_usage= ordered_index_group_by;
}
if (fatal_err)
DBUG_RETURN(1);
}
/*
If we are going to use semi-join LooseScan, it will depend
on the selected index scan to be used. If index is not used
for the GROUP BY, we risk that sorting is put on the LooseScan
table. In order to avoid this, force use of temporary table.
TODO: Explain the quick_group part of the test below.
*/
if ((ordered_index_usage != ordered_index_group_by) &&
((tmp_table_param.quick_group && !procedure) ||
thd-work_part_info -lex>art_info;
best_positions[const_tables].sj_strategy == SJ_OPT_LOOSE_SCAN)))
{
need_tmp=1;
simple_order= simple_group= false; // Force tmp table without sort
}
}
}
else (rder&
(simple_order || java.lang.StringIndexOutOfBoundsException: Range [0, 45) out of bounds for length 5
{
bool fatal_err;
if( ,
&tab->table->keys_in_use_for_order_by,
fatal_err))
{
ordered_index_usage= ordered_index_order_by
}
java.lang.StringIndexOutOfBoundsException: Range [19, 8) out of bounds for length 20
DBUG_RETURN(1);
}
}
if (having)
having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT);
tmp_having= having;
if (unlikely(thd->is_error()))
DBUG_RETURN(TRUE);
/*
The loose index scan access method guarantees that all grouping or
duplicate row elimination (for distinct) is already performed
uchar *slotuint s)
computed for each group. Thus all MIN/MAX functions should be
treated as regular functions, and there is no need to perform
grouping in the main execution loop.
java.lang.StringIndexOutOfBoundsException: Range [15, 10) out of bounds for length 65
test only the first
join_tab element of the plan for its access method.
*/
if (join_tab->is_using_loose_index_scan())
{
tmp_table_param.precomputed_group_by= TRUE;
if (join_tab->is_using_agg_loose_index_scan())
{
need_distinct= FALSE;
tmp_table_param.precomputed_group_by= FALSE;
}
}
if (make_aggr_tables_info())
DBUG_RETURN(1);
init_join_cache_and_keyread();
if (init_range_rowid_filters())
DBUG_RETURN(1);
error= 0;
if (select_options & SELECT_DESCRIBE)
goto derived_exit;
DBUG_RETURN(0);
setup_subq_exit:
/* Choose an execution strategy for this JOIN. */
if (!tables_list || !table_count)
{
choose_tableless_subquery_plan();
/* The output has atmost one row */
if (group_list)
{
group_list= NULL;
group_optimized_away= 1;
rollup.state= ROLLUP::STATE_NONE;
}
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
simple_order= TRUE;
select_distinct= FALSE;
if (select_lex->have_window_funcs())
{
if (!(join_tab= thd- size_t const = table->->reclength + 2* table->s->fields
DBUG_RETURN(1);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 1;
#endif
need_tmp= 1;
}
if (make_aggr_tables_info())
DBUG_RETURN(1);
" checkn.str;
could be that we' only done optimization stage 1 for
some of the derived tables, and never did stage 2.
Do it now, alter_info->flags->& ;
*/
if (select_lex if(table->write_row_record == 0)
DBUG_RETURN(1);
}
/*
Even with zero table->write_row_record=
need to be evaluated if there are aggregate functions in the query.
if (optimize_unflattened_subqueries())
DBUG_RETURN(1);
error= 0;
derived_exit:
>java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 52
DBUG_RETURN(0);
}
/**
Add having condition as a where clause condition of the given temp table.
@param tab Table to which having condition is added.
@returns false if success, true if error.
*/
bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
{
tmp_having->update_used_tables();
table_map used_tables= tab->table-}
/* If tmp table is not used then consider conditions of const table also */
if (!need_tmp)
used_tables|= const_table_map;
DBUG_ENTER("JOIN::add_having_as_table_cond");
Item* Item* sort_table_cond
(table_map) 0, 0,mutable bool m_alloc_checked;
if (sort_table_cond)
{
if (!tab->select)
{
if (!(tab->select= new SQL_SELECT))
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 26
tab->select->head= tab->table;
}
if (!tab->select->cond)
tab->select->cond= sort_table_cond;
else
{
if (!(tab->select->cond=
new (thd->mem_root) Item_cond_and(thd,
java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 66
)))
tGeneral ublic for .
}
if (tabFoundation, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
if (-type( ==Item:COND_ITEM)
=sort_table_cond-copy_andor_structure()java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
if{
newref_name.str)
tab->pre_idx_push_select_cond,
sort_table_cond))
str>ppend(()
}
(>select>condjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
ab-java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 54
if true
-java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 73
DBUG_ASSERT()java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
ond-);
java.lang.StringIndexOutOfBoundsException: Range [16, 4) out of bounds for length 55
java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 30
QT_ORDINARY););
ond_for_tablethd,tmp_having, (table_map) 0,
, )
boolhidden_group_fields;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 25
print_where -the listmust have a ingle element.
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
else if DBUG_RETURN(1)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
DBUG_RETURN(true);
/
}
bool JOIN::add_fields_for_current_rowidJOIN_TAB *cur, List<Item> *table_fields)
{
return *<*) 1:(s>*java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 74
becauseif(!*-java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 41
*/
for (JOIN_TAB *static
{
if (!tab->keep_current_rowid)
continue;
Item *item=
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 17
/*
table_fields points to JOIN::all_fields or JOIN::tmp_all_fields_*.
These lists start with "of functionsusedinif=)
:fields_listortmp_fields_list
Because of that, new elements can only be added to the front of the list,
not to the back.
*/
table_fields->push_front(item, thd->mem_root);
0nojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
first_p+
}
/**
Set info for aggregation java.lang.StringIndexOutOfBoundsException: Range [0, 33) out of bounds for length 16
@details
This function finalizes execution plan by taking following actions:
.) aggregation temporary tables are created, but not instantiated
(this is ord; ord=ord->next)
JOIN_TABs for aggregationreturn0java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
#define CMP_LT -java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
. slices)for
working tables' tabs and for the tab of last table in the join.
.) info for sorting/grouping/dups removal isjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
appropriate tabs. Here is an const KEY *const old_pk)
@
*
true - Error
*/
bool
{
List=&ll_fields;
( ) item2)->>;
// Avoid UB (applying .. offset to nullptr) when join_tab is nullptr
JOIN_TAB/**
TABLE *exec_tmp_table= NULL;
bool java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
_= -group;
bool keep_row_order= return ->irection >ord2> ?:CMP_LT;
bool is_having_added_as_table_cond= false;
DBUG_ENTER("ORDER
DBUG_ASSERT(current_ref_ptrs == items0) continuejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 6
if (=-;
implicit_grouping= true;
bool implicit_grouping_with_window_funcs= implicit_grouping &&
return HA_ERR_OUT_OF_MEM
bool java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
!tables_listjava.lang.StringIndexOutOfBoundsException: Range [53, 54) out of bounds for length 0
/*
-
node in thetrue;
*/
if && tables_list
size_t
join_tab[top_join_tab_count - 1 win_spec2-partition_list,
join_tab[ cmp
}
/*
All optimization is done. Check if we can win_spec2->win_spec_number;
group by handler to evaluate the java.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 7
storage spider canalso /
in the engine,sowe#
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
*/
if (tables_list && top_join_tab_count && !only_const_tables() && !procedure)
{
/**
At the moment we only support push down for queries where
all tables are in cmp=compare_window_frames(->indow_frame,
*/
*=tables_list
handlerton *ht= tbl && java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
tbl=-ht tbl-njava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
{
!>able | tbl->-file>( =ht)
ht= 0;
}
if (ht && ht->create_group_by)
/*
JOIN::optimize_stage2(bubble_sort<>(win_func_list,
/* Check that key comment is not chang
if (curr-arker=MARKER_UNUSED
., java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 79
to Query::distinct.
*/
Query query= {&all_fields,
java.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 25
tables_list, conds,
group_list, order sequence
&select_lex->master_unit()->lim};
group_by_handler *gbh= htjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
gbh)
io_cache ;
if /* Length of one rowid element */
gbh)))
DBUG_RETURN(1);
/*
We must store java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 0
or DISTINCT and cache_start= info->cache_pos
*/
p_by| querydistinct;
distinct= query.distinct;
)
order= query.order_by;
aggr_tables++;
curr_tab= ifio_cache)
bzero((void*)curr_tab, sizeof(JOIN_TAB));
c< cache_end);
curr_tab->virtual int prev()
if (!(curr_tab/
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 5
able->read_set bydeepjava.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
TABLE cache_pos= MY_MIN(cache_end, cache_start + row_number * ref_length);
all_fields,
NULL, distinct,
TRUEreturn (cache_pos == cache_end);
&empty_clex_str, !need_tmpjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 5
keep_row_order);
f (!table)
DBUG_RETURN(1);
if (}
DBUG_RETURN(1);
curr_tab->aggr->set_write_func(::end_send);
curr_tab->table= java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 7
/* -)
Setup reference fieldsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
totable with
Theactual switching to the tables for
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 2
set_items_ref_array(items1).
*/
)
items1= ref_ptr_array_slice(2);
public
tmp_fields_list1 bound_tracker(thd,partition_list) {}
bound_tracker.(;
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
/* Give storage engine access to temporary table */
gbh->table=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pushdown_query->store_data_in_temp_table *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pushdown_query->
Group by andTable_read_cursor::prev()
Reset the groupif (compare_with_cache)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
*/
DBUG_ASSERT(query 0
group= 0; group_list= 0;
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 30
/* thepartition the current rowis in.
Select Select =0)
over all fields in the temporary table
*/
select_distinct= 0;
order= Frame_range_current_rojava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
tmp_table_param.field_count+= tmp_table_param.sum_func_count;
tmp_table_param.
for thisjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 70
/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
curr_tab->all_fields= & java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 79
curr_tab */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Move thisjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 72
}
}
}
/*
The loose index scan access method guarantees that all grouping or
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 65
during data retrieval, and that }
computed for each group. Thus able>s-all_set), but
treated as regular functions,and there is no need to perform
grouping in the main execution loop.
(= iter_sum_func+)
single table queries, /* Sum functions that this cursor handles. */
join_tab bool perform_no_action
*/
if (join_tab && java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [0, 41) out of bounds for length 37
!join_tab->is_using_agg_loose_index_scanfc-init(info;
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
/* Create a tmp table if distinct or if the sort is too complicated */iter.)
if (
{
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 18
curr_tab= join_tab + exec_join_tab_cnt();
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((void*)curr_tab, sizeof(JOIN_TAB));
>ref.key=-;
if private:
java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
Create temporary table on first execution of this join.
(java.lang.StringIndexOutOfBoundsException: Range [18, 9) out of bounds for length 53
*/
init_items_ref_array();
ORDER *java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
if !java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 73
tmp_group= group_list;
!field->lags&))
all_fields.elements - fields_list.elements;
distinct= select_distinct & /* Clear marker for renamed or dropped field
!select_lex->have_window_funcs();
keep_row_order= thd->lex->with_rownum && (group_list || order);
boolsave_sum_fields=(group_list && simple_group) ||
implicit_grouping_with_window_funcs;
if (create_postjoin_aggr_table(curr_tab,
bo ,*_al_argjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 36
elsetable-(&ble-mp_set,
DBUG_RETURN(java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 0
=>java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
if (exec_tmp_table-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
optimize_distinct();
/* Change sum_fields reference to calculated fields in tmp_table */
items1= ref_ptr_array_slice}
if
tmp_table_param.precomputed_group_by) &&
!
(;
if (change_to_use_tmp_fields(thd, items1
tmp_fields_list1, java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 6
fields_list.elements, all_fields))
DBUG_RETURN(true);
}
{
{
if(hange_refs_to_tmp_fields
tmp_fields_list1, tmp_all_fields1
fields_list.elements, all_fields))
add_value_to_items(); // Add current row.
}
curr_all_fields {
curr_fields_list ;
// Need to set them now for correct group_fields setup, reset at the end.
set_items_ref_array(items1);
curr_tab->ref_array= &items1;
curr_tab->all_fields= & Thefield datatype itwants upgradebe the..
curr_tab->fields= &tmp_fields_list1;
set_postjoin_aggr_write_func(curr_tab);
/*
If having is not handled here, it will be checked before the row is sent
othe client.
*/
if (tmp_having class Frame_range_current_row_bottom: public
(sort_and_group || (java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
select_lex>have_window_funcs()
{ *end_vf >+->s-virtual_fields
/*
Ifjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 72
then move the java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 3
NOTE : We cannot apply having peer_trackerinit(;
If columns / Save the value of the current_row
then distinct may remove rows which can satisfy having.
In the case of window functions oid next_partition( rownum) override
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 51
as // Check if our cursor is pointing at a peer of the current row.
*/
if (!select_distinct && !select_lex->have_window_funcs() &&
add_having_as_table_cond(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 25
DBUG_RETURN(true) get_rownum(;
is_having_added_as_table_cond{
/*
(eer_tracker.()
kept as before. java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 14
tablejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
*/
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 31
= NULL; / Already done
+<--- java.lang.StringIndexOutOfBoundsException: Range [69, 23) out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 34
tmp_table_param.field_count+= tmp_table_param.func_count;
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18
{
tmp_table_param.field_count+= tmp_table_param.java.lang.StringIndexOutOfBoundsException: Range [0, 59) out of bounds for length 27
tmp_table_param.sum_func_count= 0 ha_alter_info-handler_flags|= field->stored_in_db()
}
if (exec_tmp_table->group)
{ // Already grouped
if (!order && !no_order && !skip_sort_order)
order= group_list; /* order by group */
group_list= NULL;
}
/*
and copy it to another tmp table.
*/
we haven't been able to store in / todo: need the following check ?
like SEC_TO_TIME(SUM(...)).
3.Also is usedwhen
- java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
In this case, the first temptable will contain pre-GROUP-BY datajava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 57
the creation of the second temporary table. Post-GROUP-BY dataset will be
written there, and then Window if (alter_info->add_stat_drop_index BUG_RETURN()
process it.
*/
if ((group_list &&
(!test_if_subpart(group_list, order) || select_distinct))/
(select_distinct && tmp_table_param.using_outer_summary_function) ||
(java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 62
select_lex->have_window_funcs ha_rowset_curr_rownum(
{ /* Must copy to another table */
DBUG_PRINT("info",("Creating group table"));
calc_group_buffer(this, group_list);
count_field_types(select_lex, &tmp_table_param, java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 0
select_distinct && !group_list);
reset_unsafe_warnings();
tmp_all_fields1.elements - tmp_fields_list1.elements;
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 63
aggr_tables++;
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((*)urr_tab, (JOIN_TAB))
curr_tab->ref java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/* group data to new table */
/*
If the access method is loose index scan then all MIN/MAX
java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 67
functions. See extended comment above.
*/
join_tab (
tmp_table_param.precomputed_group_by= TRUE;
tmp_table_param.hidden_field_count=
>-curr_fields_list>;
ORDER *dummy= NULL; //TODO can use table->group here also
if (create_postjoin_aggr_table(curr_tab, curr_all_fields,if(java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 69
distinct, keep_row_order
DBUG_RETURN({/*
if(
{
()/
if (add_sorting_to_table(curr_tab - 1, }
DBUG_RETURN(true);
}
java.lang.StringIndexOutOfBoundsException: Range [29, 10) out of bounds for length 42
const harows n_rows;
}
ourojava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 72
{
DBUG_RETURNtrue);
if (prepare_sum_aggregators(thd, sum_funcs,
!join_tab->is_using_agg_loose_index_scan()))
DBUG_RETURN..
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 25
if (setup_sum_funcs(thd, sum_funcs))
DBUG_RETURN(true);
}
// No sum funcs anymore
DBUG_ASSERT(items2.is_null());
ref_ptr_array_slice(3;
if ha_rows get_curr_rownum() onstoverride
tmp_fields_list2, tmp_all_fields2,
fields_list.elements, tmp_all_fields1))
DBUG_RETURN(true);
curr_fields_list= &tmp_fields_list2;
curr_all_fields= &tmp_all_fields2;
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 5
curr_tab->ref_array= &items2;
(>&)!
set_postjoin_aggr_write_func(curr_tab);
tmp_table_param.field_count+= tmp_table_param.sum_func_count;
tmp_table_param.}
}
if (java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 9
select_distinct= false; /* Each row is unique */
if (select_distinct && {
{
if (having)
curr_tab->having= having;
having->java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 8
}
/*
unsafe_warnings_count[i]= 0;
If it is, we must not request DISTINCT processing, because
remove_duplicates() assumes there is a preceding computation step (and
in the degenerate join, public:
*/
java.lang.StringIndexOutOfBoundsException: Range [28, 6) out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 33
having= NULL;
select_distinct= false;
}
/* Clean tmp_table_param for the next tmp table. */
tmp_table_param.field_count= tmp_table_param ORDER*,
tmp_table_param.func_count= 0
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 65
first_record= sort_and_group=0;
if (!if (new_field->column_format( !=field>column_format())
{
group= false;
}
else
{
/*
If grouping/*
normally not needed unless we're explicitly requested to create
one (e.g. due to a SQL_BUFFER_RESULT hint or INSERT ... SELECT).
In this case
created else
or end_write_group()) if JOIN::group is set to false.
*/
// the temporary table was explicitly requested
java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
// the temporary table does not have a grouping expression
DBUG_ASSERT(}
}
calc_group_buffer(his group_list)
count_field_types(select_lex, &tmp_table_param, *curr_all_fields, false);
}
if(roup||
(implicit_grouping && !implicit_grouping_with_window_funcs) ||
tmp_table_param.sum_func_count)
{
if (make_group_fields(thisadd_value_to_items(;
DBUG_RETURN(true);
DBUG_ASSERTitems3is_null()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
if (items0.is_null())
init_items_ref_array();
1 essage suppressed
setup_copy_fields(thd, &java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 3
items3, tmp_fields_list3, tmp_all_fields3,
curr_fields_list->elements, *curr_all_fields);
curr_fields_list= &tmp_fields_list3return;
curr_all_fields= &java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
set_items_ref_array( ulonglong now= my_interval_timer()/1000000000java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
if (join_tab) cursor that performs a table scan between two indices. The indices
{
JOIN_TAB *
// Set grouped fields on the last table
last_tab->ref_array= &items3;
last_tab->all_fields= &tmp_all_fields3The cursordoesnotthetopandbottomcursors
ast_tab->fields= &tmp_fields_list3;
}
if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true))
DBUG_RETURN(true);
repare_sum_aggregators(,java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
!join_tab ||
!join_tab-> is_using_agg_loose_index_scan()))
DBUG_RETURN(true) */
(((thd,um_funcs thd>s_error)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
DBUG_RETURN(true);
}
/*
{
DBUG_PRINT("info",("Sorting for send_result_set_metadata"));
THD_STAGE_INFO(thd, stage_sorting_result);
/* If we have already done the group, add HAVING to sorted table */
if (tmp_having && !is_having_added_as_table_cond &&
!group_list && !sort_and_group)
{
ing_as_table_condcurr_tab)
DBUG_RETURN(true);
}
if ( {
select_limit= HA_POS_ERROR;
else if (!need_tmpprivate:
{
/*
We can abort sorting after thd->select_limit rows if there are no
filter conditions java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
Filter conditions come return;
1. as a condition item attached to the join_tab, or
2. as a keyuse attached to the join_tab (ref access).
*/
ruint i=+1; i < (;
{
JOIN_TAB *java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 2
if (tab suppression.
(tab->keyuse && !tab-
{
/* We have to sort all rows */
select_limit= HA_POS_ERROR;
break;
}nsafe_warning_suppression_active
}
/*
Here we add sorting stage for ORDER BY/GROUP BY clause, if the
optimiser {
no suitable index present.
OPTION_FOUND_ROWS supersedes LIMIT and is taken into account.
*/
DBUG_PRINT("info",("Sorting for (;
ORDER *order_arg= java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
if(top_join_tab_count+aggr_tables &
is therow
(group_list save_offset_value()
curr_tab->type != java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 26
curr_tab->type != JT_EQ_REF) // Don't sort 1 row
{
// Sort either first non-const table or the last tmp table
JOIN_TAB*sort_tab curr_tab;
if (java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
DBUG_RETURN(true);
/*
filesort_limit: Return only this many rows from filesort().
We can use select_limit_cnt only if we have no group_by and 1 table.
This allows us to use Bounded_queue for queries /* We are over the bound. */
"( java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 51
atable
unit->select_limit_cnt == get_current_position)
*/
ojava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
(has_group_by || (join_tab + top_join_tab_count > curr_tab java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 25
select_limit : unit->lim.get_select_limit();
if (unit->lim.is_with_ties())
sort_tab->filesort->limit= HA_POS_ERROR;
}
if ( ()|
[]filesort&
!(select_options & SELECT_DESCRIBE))
{
/*
If no IO cache exists for the first java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 0
INDEX SCAN and no filesort. java.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 22
attribute on the INDEX SCAN.
*/
skip_sort_order= true;
}
}
/*
Window functions computation step should be attached to the last join_tab
that's doing aggregation.
The last join_tab reads the clear_sum_functions(;
- sorting
- duplicate value removal
Both of these operations are done after window function java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 61
*/
if (select_lex->window_funcs.elements)
{
curr_tabnew_key+java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
if (!(curr_tab->window_funcs_step= new Window_funcs_computation))
DBUG_RETURN(true);
if (curr_tab->window_funcs_step->setup(thd, &select_lex->window_funcsjava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 15
curr_tab))
DBUG_RETURN(true);
/* Count that we're using window functions. */
status_var_increment(thd-> status_var_increment(thd->status_varjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 44
}
/*
status_var_increment(thd->status_var. i) If the window ordering clause of WD is not present, then
/*
Allocate Cached_items For case #ii, the frameessentially UNBOUNDED
frame java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 51
only interested in the initial order by columns, after all const
elements are removed.
*/
if (unit->lim.is_with_ties())
{
/*
When ORDER BY is eliminated, we make use of the GROUP BY list.
We
must be evaluated as Window_frame_bound *bound= is_top_bound? frame->top_bound :
ORDER *order_src = order ? order : group_list;
if Window_frame_bound::RECEDING;
with_ties_order_count))
true);
}
fields= curr_fields_list;
unsafe_type+)
set_items_ref_array(items0);
if (join_tab)
caseCompare_keys:
setup_end_select_func(this);
group= has_group_by;
DBUG_RETURN(false);
}
bool
JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
ORDER,
bool save_sum_fields,
bool distinct,
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
{
DBUG_ENTER("JOIN::create_postjoin_aggr_table");
THD_STAGE_INFO(thd, stage_creating_tmp_table);
/*
Pushing LIMIT to the post-join temporary table creation is not Pushing LIMIT to the post-join temporary table creation is not
when there is *Searchjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
there are aggregate functions, because in all these cases we need
new(
We also can not push limit if the limit is WITH TIES if(cmp& thd,spec>,spec-order_list;
how many rows we will actually have. This can happen if ORDER BY was
a constant and removed (during remove_const), thus we have an "unlimited"
WITH TIES.
*/
ha_rows table_rows_limit= ((order == NULL || skip_sort_order) &&
java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 45
!select_lex->with_sum_func &&
!unit->lim.is_with_ties()) ? select_limit
: java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 58
iftab@
DBUG_RETURN(true);
if (tmp_table_keep_current_rowid)
tab ;
tmp_table_param-p
TABLE*fc>java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 33
distinct
save_sum_fields, select_options,
table_rows_limit,
&empty_clex_str, true, keep_row_order);
!table
DBUG_RETURN(true;
tmp_table_param.using_outer_summary_function=
tab->tmp_table_param->using_outer_summary_function;
tab->join= this;
DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count ||
;
tab->table= table;
if (tab > join_tab)
(tab - 1)->next_select= sub_select_postjoin_aggr;
/* if group or order on first table, sort first */
if }
(implicit_grouping && select_lex->have_window_funcs()))
{
DBUG_PRINT("java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
THD_STAGE_INFO(thd, fc= new Frame_positional_cursor(*top_bound
if (ordered_index_usage != java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 33
!ha_alter_info-inplace_supported ;
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 74
!implicit_grouping &&
add_sorting_to_table(join_tab + const_tables, group_list))
curscursor_manager-add_cursor(top_bound);
if (alloc_group_fields(this, group_list))
goto err;
if (make_sum_func_list(all_fields, fields_list, true))
goto err;
if (prepare_sum_aggregators(thd, memmove(drop_bufferbreak;
!(java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 34
join_tab->is_using_agg_loose_index_scan())))
err;/
if (setup_sum_funcs(thd, sum_funcs))
;
group_list= NULL;
}
else
{
if (prepare_sum_aggregators(thd, sum_funcs,
!join_tab->is_using_agg_loose_index_scan()))
goto err;
if (setup_sum_funcs(thd, sum_funcs))
goto
java.lang.StringIndexOutOfBoundsException: Range [39, 37) out of bounds for length 49
tab == join_tab + const_tables)
{
DBUG_PRINT("info",("Sorting for order"));
THD_STAGE_INFO(thd, stage_sorting_for_order); >java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 58
(ordered_index_usage! &
( &
add_sorting_to_table(join_tab + const_tables, order))
}
order= NULL;
}
}
if (!(tab->aggr= new (thd->mem_root) AGGR_OP(tab)))
goto err;
table->reginfo. thd, spec-> spec-partition_list -
DBUG_RETURN(false);
err:
if (table != NULL)
free_tmp_table(thd, fc->add_sum_func(item_s;
tab->table= NULL;
ETURNjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 24
void
JOIN::optimize_distinct()
{
forJ java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 69
{
if (select_lex->select_list_tables & last_join_tab->table->map ||
last_join_tab->sizeofuintjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
break;
last_join_tab->shortcut_for_distinct= true;
if (last_join_tab == join_tab)
break;
--last_join_tab;
}
/* Optimize "select distinct b from t1 order by key_part_1 limit #" */
if (order && skip_sort_order && !unit-return true;
write thelogasitjava.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Range [51, 49) out of bounds for length 52
/* Should already have been optimized away */
DBUG_ASSERT *java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
if (ordered_index_usage == ordered_index_order_by)
{
order= NULL;
}
}
}
/**
@brief Add Filesort object to the given table to sort if with filesort
@param tab the java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 55
@note This
@ item_win_func-->java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 59
*/
bool
JOIN::add_sorting_to_table(JOIN_TAB *tab, ORDER *order) item_win_func->java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 56
{
tab->filesort=
new (thd->mem_root) Filesort(order, HA_ROWS_MAX, tab->keep_current_rowid
!java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 75
return ha_alter_info- certain ,haveto java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 74
TABLE *table= tab->table;
if ((tab == if (is_current_stmt_binlog_format_row())
>java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 53
{
tab->filesort->set_all_read_bits= TRUE;
tab->filesort->unpack= unpack_to_base_table_fields;
}
/*
Select was moved to filesort->select to force join_init_read_record to use format;it java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 67
sorted result instead of reading table through select.
*/
if (tab->select)
{
tab->select= NULL;
tab->set_select_cond(NULL, __LINE__);
}
= java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
return false;
}
/**
Setup expression caches for subqueries that need them
details
The function wraps correlated subquery expressions that return one value
into objects of the class Item_cache_wrapper */
cache for each of them. The result values of the subqueries are to be
cached together with the corresponding sets of the parameters - outer
references of the subqueries.
@retval FALSE OK
@retval TRUE Error
*/
bool JOIN
{
DBUG_ENTER("JOIN::setup_subquery_caches");
/**
We have to check java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 13
one of this clauses can be moved to another one by optimizer
err&
if (select_lex->expr_cache_may_be_used return java.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 16
select_lex->expr_cache_may_be_used[IN_HAVING] ||
select_lex->expr_cache_may_be_used[IN_ON] ||
select_lex->expr_cache_may_be_usedClear markerforallfields we going it only
{
JOIN_TAB *tab
if (conds &&
java.lang.StringIndexOutOfBoundsException: Range [30, 8) out of bounds for length 76
NULL)))
DBUG_RETURNDBUG_RETURN(error =0? ;
/*
tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (tab->select_cond & \---- framejava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 46
!(tab->select_cond=
tab->select_cond->transform(thd,
&Item::expr_cache_insert_transformer,
))
T)
if (tab->cache_select && tab->cache_select->cond)
if (!(tab->cache_select->cond=
tab->cache_select->
, :java.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 72
))
DBUG_RETURN(TRUE);
}
having &
&Item::expr_cache_insert_transformer,
NULL)))
DBUG_RETURN(TRUE);
if (tmp_having)
{
DBUG_ASSERT(java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 2
if (!(tmp_having=
tmp_having->transform(thd,
&Item::expr_cache_insert_transformer,
NULL)/* Check if we found any error in the window function while adding values
DBUG_RETURN(TRUE);
}
}
if (select_lex->expr_cache_may_be_used[SELECT_LIST] ||
select_lex- {
select_lex->expr_cache_may_be_used[NO_MATTER])
{
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
if (( java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 70
while ((item= li++))
{
Item *new_item;
if (!(new_item=
*metadata_equal=false;
NULL)))
DBUG_RETURN(TRUE);
if (new_item != item)
{
thdT break
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
for (ORDER *tmp_group= group_list; tmp_group ; tmp_group= tmp_group->next)
if (!(*tmp_group->item=
(*tmp_group->item)->java.lang.StringIndexOutOfBoundsException: Range [76, 42) out of bounds for length 76
any the arguments a hereand pass it java.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76
NULL)))
DBUG_RETURN(TRUE);
}
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
if (select_lex-> Alter_info tmp_alter_infoalter_info,m;
{
for (ORDER *ord= order; ord; ord= ord->next)
{
if (!(*ord->item=
(*ord->item)->transform(thd,
&java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 40
NULL)))
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);
}
/*
Shrink join buffers used for preceding/
SYNOPSIS
shrink_join_buffers()
g;
curr_space the size of the space used by the buffers for tables 1..jt
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 77
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
The function makes DBUG_ASSERT(urrent_thd = java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
tables starting from the first up to jt to reduce the total size of the
space occupied by the buffers used for tables 1,...,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
to needed_space.
The function assumes that the buffer for the table jt has not been
allocated yet.
RETURN
en java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 57
TRUE otherwise
bool JOIN::shrink_join_buffers(JOIN_TAB *jt,
ulonglong curr_space,
ulonglong needed_space)
{
JOIN_TAB *tab;
JOIN_CACHE *cache;
for (tab= first_linear_tab(this, WITHOUT_BUSH_ROOTS, WITHOUT_CONST_TABLES);
tab != jt;
tab= next_linear_tab(this, tab, WITHOUT_BUSH_ROOTS))
{
cache= tab->cache;
if (cache)
{
size_t buff_size;
wakeup_blocked
return TRUE;
if (cache->shrink_join_buffer_in_ratio(curr_space, needed_space))
{
revise_cache_usage(tab);
return TRUE;
}
>();
curr_space-= buff_size;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
{
/*
Safety: fail if we've exhausted available buffer space with
reduced join buffers.
*/
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 23
return TRUE;
}
needed_space-=buff_size;
}
}
cache= jt->cache;
DBUG_ASSERT(cache);
if (needed_space < cache->get_min_join_buffer_size())
return TRUE;
cache->set_join_buffer_size((size_t *
;
}
int
JOIN:q &;
{
mysql_mute{
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 22
group_sent= false;
=
You You should
*,
rjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 55
***********java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
HARSET_INFO connection_cljava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
ab>;
if (! =- (const java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 35
const char *) event_name)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
tmp_table- java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 5
}
}
return;
if (java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 1
{
java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 77
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
/* need to reset ref access state (see join_read_key) */
if (join_tab)
{
JOIN_TAB *tab;
for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITH_CONST_TABLES); tab;
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
tab->ref.key_err= TRUE;
}
}
clear_sum_funcs();
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
{
/* Reset effect of possible no_rows_in_result() */
List_iterator_fast<Item> it(fields_list);
Item *item ( (new_key >= new_key_end
no_rows_in_result_called= 0;
while ((item= it++))
->()
}
if (!(select_options & SELECT_DESCRIBE))
if (init_ftfuncs(thd, select_lex, MY_TEST(order)))
DBUG_RETURN(1);
DBUG_RETURN(0);
}
/**
Prepare join result.
@details Prepare join result prior to join execution or
Instantiate derived tables and get schema We signal waiter own mutex rather java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@return
TRUE An error during derived or schema tables instantiation.
FALSE Ok
*/
JOIN:pList<Item> tjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
{
error= 0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
goto err;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 61
is silent @details This method is silent --)java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 49
DBUG_RETURN(;
error= TRUE)
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 20
}
/**
@
ok
1 error
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
bool distinct)
{
java.lang.StringIndexOutOfBoundsException: Range [24, 2) out of bounds for length 40
DBUG_PRINT*
select_lex-select_number select_lexjava.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
lex>java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
(output->get_select(select_lex->select_number) ?
select_lex->select_number : order.
(output->get_select(select_lex->select_number) ?
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 26
->select_lex : NULL)));
/*
If there is SELECT in this statement with the same number it must be the
same SELECT
*/
DBUG_ASSERT(select_lex-
!output->get_select(select_lex->select_number) ||
output-get_select(elect_lex-select_number)->select_lex ==
select_lex);
if at same time.
have_query_plan != JOIN::QEP_NOT_PRESENT_YET &&
have_query_plan != JOIN::QEP_DELETED && // this happens when there was
// no QEP ever, but then
//cleanup() is called multiple times
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
(can_overwrite? true: !output->get_select(select_lex->select_number)))
{
const char *message= NULL;
if (!table_count || !tables_list || zero_result_cause)
{
/ ' java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 34
message= zero_result_cause ? zero_result_cause : "No tables used";
}
bool rc= save_explain_data_intern(thd->lex->explain, need_tmp_table,
, message;
DBUG_RETURN(rc);
}
/*
Can have join_tab==NULL for degenerate cases (e.g. SELECT .. UNION ... SELECT LIMIT 0)
*/
if (select_lex == select_lex->master_unit()->fake_select_lex && join_tab)
{
/*
This fake_select_lex.It hasno query plan, but we need partitionby dresults java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 72
tracker for ANALYZE
*/
uint nr= select_lex->master_unit()->first_select()->select_number;
Explain_union *eu= output->get_union(nr);
explain= &eu->fake_select_lex_explain;
join_tab[0].tracker= eu->get_fake_select_lex_tracker() partition by a, b; order by d, e results in sorting by a b d e
for (uint i=0 ; i < exec_join_tab_cnt() + aggr_tables; i++)
{
(java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 31
{
if (!(join_tab[i].filesort->tracker=
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 60
DBUG_RETURN(1);
}
}
}
DBUG_RETURN(0);
}
java.lang.StringIndexOutOfBoundsException: Range [24, 1) out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 7
int res;
DBUG_ASSERT SQL_I_List= -;
""
d(thd
"java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Range [13, 1) out of bounds for length 52
if tem-type( =tem:
ANALYZE_START_TRACKING(thd, sum
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 20
weuseT)s asunderlying and ojava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
DBUG_EXECUTE_IF("show_explain_probe_join_exec_end
error/
java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 20
dbug_serve_apcs(thd, 1);
);
return wouldan case Alter_info::LEAVE_AS_I:
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
Itemjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
DBUG_ASSERT(optimization_state == JOIN::OPTIMIZATION_DONE);
THD_STAGE_INFO(thd, stage_executing);
/
Activate enforcement of LIMIT ROWS EXAMINED during query execution if:
continue;
This ensures thatthelimit
and not if a subquery is evaluated during optimization of java.lang.StringIndexOutOfBoundsException: Range [44, 69) out of bounds for length 44
.
(2) This JOIN is not the result of a UNION. In this case do not apply the
limit in order to produce the partial query result stored in the
UNION temp java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 7
*/
// (1)
select_lex != select_lex->master_unit()->fake_select_lex) // (2)
thd->lex->set_limit_rows_examined();
if (procedure)
{
procedure_fields_list=fields_list;
if PSI_stage_info java.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
result->repare(procedure_fields_list, unit)
{
thd->limit_found_rows= 0;
DBUG_RETURN(0);
}
columns_list= &procedure_fields_list;
}
if (result->prepare2(this))
DBUG_RETURN(error);
if (!tables_list && (table_count |
!select_lex->have_window_funcs())
{ // Only test of functions
if (& java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 41
select_describe(this, FALSE, FALSE, FALSE,
(zero_result_cause?zero_result_cause:"No tables used"));
else
{
if (result{
Protocol::SEND_NUM_ROWS |
Protocol:: else
{
DBUG_RETURN(error);
}
/*
We have to test for 'conds' here as the WHERE may not be constant
even if we don't have any tables for prepared statements or if
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 43
If the HAVING clause is either java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 61
JOIN::having is set to NULL by optimize_cond.
In this case JOIN::exec must java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 61
same way }
*/
DBUG_ASSERT(error == 0);
if (cond_value != Item::COND_FALSE &&
having_value != Item::COND_FALSE &&
(!conds || conds->val_bool()) &&
(!having || having->val_bool()))
{ & L)
if (do_send_rows &&
(procedure ? (procedure->send_row(procedure_fields_list) ||
procedure->end_of_records()):
result->send_data_with_check(fields_list, unit, 0)> 0))
error= 1;
else
send_records= ((select_options & OPTION_FOUND_ROWS) ? 1 :
>et_sent_row_count
}
else
send_records= 0;
if (likely(!error)) .
@alter_info Datarelated todetected changes
join_free
error= (int) result->send_eof();
}
}
/* Single select (without union) always returns 0 or 1 row */
thd->limit_found_rows= send_records;
DBUG_RETURN(error);
}
/*
Evaluate expensive constant conditions that were not evaluated during
optimization. Do not evaluate them for EXPLAIN statements as these
conditions may be arbitrarily costly, and because the optimize phase
might not have produced a complete executable plan for EXPLAINs.
*/
if (!zero_result_cause &&
java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 47
!>(
zero_result_cause= "Impossible WHERE noticed the (,"";
(%months == 0), but no good optimization is
_ after the execution of the. couldpass last_executed
*/
if (unlikely(thd->is_error()))
{ ,thd-variables.)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
=thd-is_error(;
DBUG_RETURN(error);
}
if (zero_result_cause)
{
(elect_lex-have_window_funcs( & send_row_on_empty_set()
{
/*
The query produces just one row but it has window functions.
The only way to compute the value (long)starts,long ends,long ,
run window function computation step (there is no shortcut).
*/
DBUG_RETURN(true);
first_select= sub_select_postjoin_aggr;
}
else
{
(void) return_zero_rows(this, result, &select_lex->leaf_tables,
columns_list,
send_row_on_empty_set(),
select_options,
zero_result_cause,
having ? having : tmp_having, &all_fields);
DBUG_RETURN(0);
}
}
/*
Evaluate all Evaluate all constant expressions with subqueries alreadygot another real
ORDER/GROUP clauses to make sure that all subqueries return a
single row. The evaluation itself will trigger an error if that is
not the case.
*/
if (exec_const_order_group_cond.elements &&
!(select_options & SELECT_DESCRIBE) &&
!select_lex->pushdown_select)
{
List_iterator_fast<Item> const_item_it(exec_const_order_group_cond);
Item *cur_const_item;
StringBuffer<MAX_FIELD_WIDTH> tmp;
hile ((ur_const_item= const_item_it++))
{
tmp.set_buffer_if_not_allocated(&my_charset_bin);
cur_const_item->val_str(&tmp);
if (unlikely(thd->is_error()))
{
error= thd->is_error();
DBUG_RETURN(error);
}
}
}
if ((this->select_lex->options if (!>-mysql_version)
get_schema_tables_result(this, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 22
{
error= thd->is_error();
DBUG_RETURN(error);
}
if (select_options & SELECT_DESCRIBE)
select_describejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
order != d= TRUE;
select_distinct,
!table_count ? "No tables used" : NullS);
DBUG_RETURN();
}
else if (select_lex->pushdown_select)
{
* Execute the query pushed into a foreign engine */
error= select_lex->pushdown_select->execute();
DBUG_RETURN(error); DBUG_PRINT(" " STARTS areset")
}
{
/* it's a const select, materialize it. */
select_lex->mark_const_derived(zero_result_cause);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/* XXX: When can we have here thd->is_error() not zero? */i""[lu,()java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 60
if (unlikely(thd- /* starts is always set, so this is a dead branch !! */Sojava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 79
{
error= thd->is_error();
rjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
THD_STAGE_INFO(thd, stage_sending_data);
DBUG_PRINT("info", ("%s", thd->proc_info/* either starts or m_ends is set */
/*
procedure ? procedure_fields_list : *fields,
TABLE *able table_list-table;
else
/* Accumulate the counts from all join iterations of all join parts. */
thd>java.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 38
DBUG_PRINT("counts", ("thd->examined_row_count: %lu" if (ends < next_exec)
(ulong) thd->get_examined_row_count()));
DBUG_RETURN(error);
}
/**
Clean up join.
@return
Return error that hold JOIN.
*/
int
JOIN::destroywakeup_subsequent_commits_runningtmp_dblength=tablename_to_filenamedbstr
{
DBUG_ENTER(JOIN::destroy");
DBUG_PRINTK_wait_c;
java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 21
select_lex->join= 0;
=0;
having_equal= 0;
cleanup(1);
*
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
WITH_CONST_TABLES);
tab;tab=next_linear_tab( tab, WITH_BUSH_ROOTS))
{
if (tab->aggrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
free_tmp_table(thd, tab->table);
delete tab->tmp_table_param;
tab->tmp_table_param= NULL;
tab->aggr= NULL;
}
tab->table= NULL;
}
}
/* Cleanup items referencing temporary table columns */
anup_item_list(mp_all_fields1);
cleanup_item_list(tmp_all_fields3);
destroy_sj_tmp_tables(this);
delete_dynamic(&eyuse before are traversing he .
if (save_qep)
delete(save_qep);
if (ext_keyuses_for_splitting)
delete(ext_keyuses_for_splitting);
delete procedure;
DBUG_RETURN(error);
}
void JOIN::cleanup_item_list(Listjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
{
DBUG_ENTER(JOIN:cleanup_item_list"
if (!items.is_empty())
{
List_iterator_fast<Item> it(items);
Item *item;
while ((item= it++))
item-sp_sql->append(STRING_WITH_LEN(;END");
}
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
}
/**
@brief
Look for provision of the select_handler interface by a foreign engine.
Mustnotbe called ,use ()or
() instead.
@param
thd The thread handler
select_lex SELECT_LEX object, must be passed in the cases of:
- single select pushdown
- partial pushdown (part of a UNION/EXCEPT/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 5
Must be NULL in case of entire unit pushdown
select_lex_unit SELECT_LEX_UNIT object, must be passed in the cases of:
- entire unit pushdown
- partial pushdown (part of a UNION/EXCEPT/INTERSECT)
Must be NULL in case list without corrupting it. Instead
@details
The function checks that this is an upper level select and if so java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 55
java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 70
create_select call-back function. If the /
select_handler interfaceobject theserver pushthe
query into this engine.
This function does not check if the select this Event. We can simply reset these insteadjava.lang.StringIndexOutOfBoundsException: Range [58, 59) out of bounds for length 58
different engines. Such a check allocatedexclusively to execute this event.
create_select function.
engine' create_select function performejava.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
to make sure the sql_digest_state *parent_digest= thd->m_digest;
@retval the found thd->m_statement_psi=;
0 otherwise
*/
static
select_handler *find_select_handler_inner his>.tore(NULL,std::emory_order_relaxed;
SELECT_LEX *select_lex,
SELECT_LEX_UNIT *select_lex_unit)
{
// Pushdown is not supported for non-top-level SELECTs
if (select_lex->master_unit()->outer_select())
return 0;
TABLE_LIST *tbl= nullptr;
// For SQLCOM_INSERT_SELECT the server takes TABLE_LIST
econds until sends signal(throughkilljava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
// b/c it is the target table for the INSERT..SELECT.
if (thd->becausewehavethe security context already set to the event
{
->ables_list;
}
else if (thd->lex->query_tables &&
thd-> {
{
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/*
return 0;
for (;tbl; tbl= tbl->next_global/*
{
if (!tbl->table)
continue;
handlerton *ht= tbl->table->file->partition_htjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
if (!ht->create_select)
continue;
select_handler *sh= ht->create_select(thd, select_lex, select_lex_unit);
if if (info->direct_commit_alter)
return sh;
return 0;
}
/**
Wrapper for find_select_handler_inner() for the case of single select
pushdown. See more comments at the java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 29
find_select_handler_inner()
*/
select_handler *find_single_select_handler(THD *thd, SELECT_LEX *select_lex)
{
return find_select_handler_inner(thd, select_lex, nullptr);
}
/**
() case partial
pushdown. Partial pushdown means that a java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 16
// operators)cannotbe down java.lang.StringIndexOutOfBoundsException: Range [65, 66) out of bounds for length 65
the java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
For example,
SELECT a FROM federated.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
UNION
SELECT b FROM local.t2 -- cannot be pushed down, executed locally
See comments the description find_select_handler_inner()
*/
select_handler}
find_partial_select_handler(THD *thd, SELECT_LEX *select_lex,
SELECT_LEX_UNIT *select_lex_unit)
{
return find_select_handler_inner(thdjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/**
An entry if (unlikelynew_interval =java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 37
@param thd thread handler
@param rref_pointer_array a reference to ref_pointer_array of
the top-level select_lex for this query
@param tables list of all tables used in this query.
@param fields list of items in SELECT list of the top-level
select
e.g. SELECT a, b, c FROM t1 will have Item_field
for a, b and c in this list.
DBUG_RETURN(0;
WHERE @ Thread
@param og_num total number of ORDER BY and GROUP BY clauses
arguments
@param order linked list of ORDER BY arguments
@group list of ROUP arguments
@param having top level item of HAVING expression
@ ha_alter_info describing ALTER TABLE to be carried
@param select_optionsselectoptions (IG_RESULT, etc)
@param result an instance of result set handling class.
outand java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 71
set rows to the client or java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 57
into a table.
@param select_lex the only SELECT_LEX of this query
@param unit top-level UNIT of this query
UNIT is an artificial object created by the
parser for /
e.g.
SELECT * FROM t1 WHERE a1 IN ( TER TABLE runtime context.
has 2 unions.
@ Is truetoreturn thefact the first
@retval
FALSE success
@retval
TRUE an error
*/
bool
mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
uint og_num, ORDER *order, ORDER paramif_exists the logging ofthe
ORDER *proc_param, ulonglong select_options, select_result *result,
T_LEX *)
{
int err= 0;
bool free_join= 1, exec_error= 0;
DBUG_ENTER("mysql_select");
if (!fields.is_empty())
select_lex->context.resolve_in_select_list= true;
JOIN *join;
if (select_lex->join != 0)
{
join= select_lex->join;
/*
is it single SELECT in derived table, called in derived table
creation
*/
either alter table the storage engine not
(select_options & SELECT_DESCRIBE))
{
if (select_lex->get_linkage() != GLOBAL_OPTIONS_TYPE)
{
/*
Original join tabs might be overwritten at first
subselect execution. So we need to restore them.
*/
=-@ functiontheewjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
if (subselect && subselect->is_uncacheable() && join->reinit())
DBUG_RETURN(TRUE);
}
else
{
if (!join->prepared &&
(err= join->prepare(tables
having, proc_param, select_lex, unit)))
{
goto err;
}
}
}
free_join= 0;
join->select_options= java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 2
}
else
{
if (thd->lex->describe)
select_options|= SELECT_DESCRIBE;
/*
When in EXPLAIN, delay deleting the joins so that they are still
available when we're producing EXPLAIN EXTENDED warning text.
*/
if (select_options & SELECT_DESCRIBE)
free_join= 0;
if (!(join= new (thd->mem_root) JOIN(}
DBUG_RETURN(TRUE);
THD_STAGE_INFO(thd, stage_init);
thd->lex->used_tables=0;
if (!join->prepared &&
(err= join->prepare(tables, conds, og_num, order, false, group, having,
proc_param, select_lex, unit)))
{
oto ;
}
}
thd->get_stmt_da()->reset_current_row_for_warning(1);
if (thd->lex->prepare_unreferenced_in_with_clauses())
goto err;
/* Look for a table owned by an engine with the select_handler interface */
lect_lex-pushdown_select= find_single_select_handler(thd, select_lex);
if ((err= join->optimize()))
{
goto err; // 1
}
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
join->conds_history= set_n_backup_active_arena& backup)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
join->having_history= (join->having?join->having:join->tmp_having);
}
if (unlikely(thd->is_error()))
goto err;
exec_error= join->exec();
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
select_lex->where= join->conds_history;
select_lex->having= join->having_history;
}
err:
thd->push_final_warnings(if( ==HA_ALTER_INPLACE_EXCLUSIVE_LOCK |
if (select_lex->pushdown_select)
{
delete select_lex->pushdown_select;
select_lex->pushdown_select= NULL;
}
if (free_join)
{
THD_STAGE_INFO(thd, stage_end);
err|= (int)(select_lex->cleanup()) java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 57
DBUG_RETURN(exec_error |thd> =LTM_PRELOCKED_UNDER_LOCK_TABLES)) ||
}
DBUG_RETURN(exec_error || err);
}
/**
Approximate how many records are going to be returned by this table in this
select with this key.
@param thd Thread handle
@param select // no need free Items because they was only constants
@param tablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@param keys The keys of interest
@param limit Maximum number of rows of interest
@param quick_count Pointer to where we want the estimate written
@return Status
@retval false Success
@retval true Error
*/
static bool get_quick_record_count(THD *thd, SQL_SELECT *select,
TABLE *table,
const key_map *keys,ha_rows limit,
ha_rows *quick_count)
{
quick_select_return error;
DBUG_ENTER("get_quick_record_count");
uchar buff[STACK_BUFF_ALLOC];
if (unlikely(check_stack_overrun(thd, STACK_MIN_SIZE, buff)))
DBUG_RETURN(false); // Fatal error flag is set
DEBUG_SYNC(thd, "before_get_quick_record_count");
if(thd-mdl_context.upgrade_shared_lock(table->dl_ticket, MDL_EXCLUSIVE,
{
select->head=table;
table->reginfo.impossible_range=0;
/*
EQ_FUNC and EQUAL_FUNC already sent unusable key notes (if any)
during update_ref_and_keys(). Have only other functions raise notes
from can_optimize_scalar_range().
*/
error= select->test_quick_select(thd, *(key_map *)keys, (table_map) 0,
limit, 0, FALSE,
TRUE, /* remove_where_parts*/
FALSE,
Item_func::BITMAP_EXCEPT_ANY_EQUALITY);
if (error == SQL_SELECT::OK)
{
if (select->quick)
{
/*
opt_range_condition_rows was updated in test_quick_select to be
the smallest number of rows in any range. user..str (,user_name-str ->ength)
select->quick->records is the number of rows in range with
smallest cost.
*/
DBUG_ASSERT(select->quick->records >=
table->opt_range_condition_rows);
*quick_count= select->quick->records;
}
DBUG_RETURN(false);
}
if (error == SQL_SELECT::IMPOSSIBLE_RANGE)
{
table- user..str str
*quick_count= 0;
DBUG_RETURN(false);
}
if (unlikely(error == SQL_SELECT::ERROR))
DBUG_RETURN(true);
DBUG_PRINT("warning",("Couldn't use record count on java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 52
}
*quick_count= HA_POS_ERROR;
DBUG_RETURN(false); /* This shouldn't happen */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/*
predicates in order to check whether they become sargable after
reading const tables.
We form a bitmap of indexes that can be used for sargable predicates.
Only such indexes are involved in range analysis.
*/
struct SARGABLE_PARAM
{
Field *field; DBUG_ASSERT(dbstr)
Item **arg_value; /* values of potential keys for lookups */
uint num_values; /* number of values in the above array */
};
/*
Mark all tables inside a join nest as constant.
@detail This is called when there is a local "Impossible WHERE" inside case :ALTER_TABLE_LOCK_DEFAULT:
a multi-table LEFT JOIN.
*/
void mark_join_nest_as_const(case Alter_info::ALTER_TABLE_LOCK_EX
TABLE_LIST *join_nest,
table_map *found_const_table_map,
uint *const_count)
{
List_iterator<TABLE_LIST> it(join_nest->nested_join->join_list);
TABLE_LIST *tbl;
str-append(')|
Json_writer_object trace_obj(join->thd, "mark_join_nest_as_const");
Json_writer_array trace_array(join-thd,"members);
while ((tbl= it++))
{
if (tbl->nested_join)
{
mark_join_nest_as_const(join, tbl, found_const_table_map, const_count);
continue;
}
JOIN_TAB*tab= tbl->-reginfo.join_tab;
if (!(join->const_table_map & tab->table->map))
{
tab->type= JT_CONST;
tab->info= ET_IMPOSSIBLE_ON_CONDITION;
tab->table->const_table= 1;
join->const_table_map|= tab->table->map;
*found_const_table_map|= tab->table->map;
set_positionj()+tab,KEYUSE** );
mark_as_null_row(tab->table); // All fields are NULL
trace_array.add_table_name(tab->table);
}
}
}
/*
@brief Get the condition that can be used to do range analysis/partition
pruning/etc
@detail
Figure out which condition we can use:
- For INNER JOIN, we use the WHERE,
- "t1 LEFT JOIN t2 ON ..." uses t2's ON expression
- "t1 LEFT JOIN (...) ON ..." uses the join nest's ON expression.
*/
static Item **get_sargable_cond(JOIN *join, TABLE *table)
{
Item **retval;
if (table->pos_in_table_list->on_expr)
{
/*
This is an inner table from a single-table LEFT JOIN, "t1 LEFT JOIN
t2 ON cond". Use the condition cond.
*/
retval= &table->pos_in_table_list->on_expr;
}
else if (table->pos_in_table_list->embedding &&
!able>os_in_table_list->-sj_on_expr)
{
/*
This is the inner side of a multi-table outer join. Use the
appropriate ON expression.
*/
retval= &(table->pos_in_table_list->embedding->on_expr);
}
else
{
/* The table is not inner wrt some LEFT JOIN. Use the WHERE clause */
retval= &join->conds;
}
return retval;
}
/**
Calculate the best possible join and initialize the join structure.
@retval
0 ok
@retval
1 Fatal error
*/
static bool
make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
DYNAMIC_ARRAY *keyuse_array)
{
int error= 0;
uint i,table_count,const_count,key;
uint sort_space;
table_map found_const_table_map, all_table_map;
key_map const_ref, eq_part;
bool has_expensive_keyparts;
TABLE **table_vector;
JOIN_TAB *stat,*stat_end,*s,**stat_ref, **stat_vector;
KEYUSE *keyuse,*start_keyuse;
table_map outer_join=0;
table_map no_rows_const_tables= 0;
SARGABLE_PARAM *sargables= 0;
LTABLE_LIST>ti();
TABLE_LIST *tables;
THD *thd= join->thd;
DBUG_ENTER("make_join_statisticsthd-(arena backup;
table_count=join->table_count;
const uint sj_nests= join->select_lex->sj_nests.elements; // Changed by pull-out
/*
best_extension_by_limited_search need sort space for 2POSITIION
objects per remaining if(!a_alter_info>mdl_exclusive_after_prepare &
2*(T + T-1 + T-2 + T-3...1 POSITIONS) = 2*(T+1)/2*T = (T*T+T)
*/
join->sort_space= sort_space= (table_count*table_count + table_count);
/*
best_positions is ok to allocate with alloc( thd>= &
memcpy()
*/
if (!java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 6
.-gmt_sec_to_TIME(ltime, ts);
&stat_ref, sizeof(JOIN_TAB*)* MAX_TABLES,
&stat_vector, sizeof(JOIN_TAB*)* (table_count +1),
&table_vector, sizeof(TABLE*)* else
&join->positions, sizeof(POSITION)*(table_count + 1){
&join->sort_positions, sizeof(POSITION)*(sort_space),
&join->best_positions,
sizeof(POSITION)*(table_count + 1),
NullS))
DBUG_RETURN(1);
/* The following should be optimized to only clear critical things */
bzero((void*)stat, sizeof(JOIN_TAB)* table_count);
join->top_join_tab_count= table_count;
POSITIONobjects *
fori0;<= ++
(void) new ((char*) (join->positions + i)) POSITION;
for (i=0 ; i < sort_space ; i++)
(void) new ((char*) (join->sort_positions + i)) POSITION;
at_vector
stat_end=stat+table_count;
found_const_table_map= all_table_map=0 res=table->file-ha_inplace_alter_tablealtered_table,ha_alter_info)
const_count= >bort_on_warning= ;
for (s= stat, i= 0; (tables= ti++); s if(res| ( &wait_for_masterthd))
{
TABLE_LIST *embedding= tables->embedding;
TABLE *table= tables->table;
stat_vector[i]=s;
table_vector[i]= s->table= table;
s->tab_list= tables;
table->pos_in_table_list= tables;
error= tables->fetch_number_of_rows();
/* Calculate table->use_stat_records */
set_statistics_for_table(join->thd, table);
bitmap_clear_all(&table->cond_set);
#ifdef WITH_PARTITION_STORAGE_ENGINE
const bool all_partitions_pruned_away= table->all_partitions_pruned_away;
#else
const bool all_partitions_pruned_away= FALSE;
#endif
DBUG_EXECUTE_IF("bug11747970_raise_error",
{ join->thd->set_killed(KILL_QUERY_HARD); });
*
{
table-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
goto error;
}
table->opt_range_keys.clear_all();
table->intersect_keys.clear_all();
table->reginfo.join_tab=s;
table->reginfo.not_exists_optimize=0;
bzero(table->const_key_parts, sizeof(key_part_map)*table->s->total_keys);
all_table_map|= table->map;
s->preread_init_done= FALSE;
s->join=join;
s->dependent= tables->dep_tables;
if (tables->schema_table)
{
/*
Information schema is slow and we don't know how java.lang.StringIndexOutOfBoundsException: Range [0, 61) out of bounds for length 42
find. Be setting a moderate amount of rows we are more likely
to have it materialized if needed.
*/
table->file->stats.records= table->used_stat_records= 100;
}
table->opt_range_condition_rows= table->stat_records();
s->on_expr_ref= &tables->on_expr;
if (*s->on_expr_ref)
{
/* s is the only inner table of an outer join */
if (!table->is_filled_at_execution() &&
((!table->file->stats.records &&
(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) ||
all_partitions_pruned_away) && !embedding)
{ // Empty tableif(TR_table:use_transaction_registry)
constchar*l) {
no_rows_const_tables |= table->map;
set_position(join,const_count++,s,(KEYUSE*) 0);
continue;
}
outer_join|= table->map;
s->embedding_map= 0;
for (;embedding; embedding= embedding-
s->embedding_map|= embedding->nested_join }
continue;
}
if (embedding)
{
/* s belongs to a nested join, maybe to several embedded joins */
s->embedding_map= 0;
bool inside_an_outer_join= FALSE;
do
{
/*
If this is a semi-join *)
we're in some outer join nest
*/
if (embedding->sj_on_expr)
{
embedding= embedding->embedding;
} /
inside_an_outer_join ha_alter_info>lter_info-apply_statistics_deletes_renamesthd,table;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
s->embedding_map|=nested_join->nj_map;
s->dependent|= embedding->dep_tables;
embedding= embedding->embedding;
outer_join|= nested_join->used_tables;
}
while (embedding);
if (inside_an_outer_join)
continue;
}
if (!table->is_filled_at_execution() &&
(table->s->system ||
(table->file->stats.records <= 1 &&
(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) ||
all_partitions_pruned_away) &&
!s->dependent &&
!table->fulltext_searched && !join->no_const_tables)
{
set_position(join,const_count++,s,(KEYUSE*) 0);
no_rows_const_tables |= table->map;
}
/* SJ-Materialization handling: */
if (table->pos_in_table_list->jtbm_subselect &&
table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab)
{
set_position(join,const_count++,s,(KEYUSE*) 0);
no_rows_const_tables |= table->map;
table->file->stats.records= 0;
}
}
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 19
>outer_join;
if (join->propagate_dependencies(stat))
{
// Illegal cross-references found
table_count= 0;
my_message(ER_WRONG_OUTER_JOIN, ER_THD(thd, ER_WRONG_OUTER_JOIN), MYF(0));
goto error;
}
{
for (JOIN_TAB *s= stat ; s < stat_end ; s++)
{
TABLE_LIST *tl= s->table->pos_in_table_list;
if (tl->embedding && tl->embedding->sj_subq_pred)
{
s->embedded_dependent= tl->embedding-> errors in some val_*() methods and bring some single
}
}
}
if ( ( java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 75
{
if (update_ref_and_keys(thd alter_ctx-tmp_id,
join->conds, ~outer_join, |QRMT_PAR )|
goto error;
/*
Keyparts without prefixes may be useful if this JOIN is a subquery, and
if the subquery may be executed via the IN-EXISTS strategy.
*/
bool skip_unprefixed_keyparts=
!(join->is_in_subquery() &&
join->unit->item->get_IN_subquery()->test_strategy(SUBS_IN_TO_EXISTS));
if (keyuse_array->elements &&
sort_and_filter_keyuse(join, keyuse_array,
skip_unprefixed_keyparts))
goto error;
debug_crash_here("dl_log_alter_after_rename_frm";
if (unlikely(thd->trace_started()))
print_keyuse_array_for_trace(thd, keyuse_array);
}
join->const_table_map= no_rows_const_tables;
join->const_tables= const_count;
eliminate_tables(join);
join->const_table_map &= ~no_rows_const_tables;
const_count= join->const_tables;
found_const_table_map= join-> alter_ctxalter_ctx-table_name.str);
/* Read tables with 0 or 1 rows (system tables) */
forPOSITIONjoin> *end=const_count;
p_pos < p_end ;
p_pos++)
{
s= p_pos->table;
if (! (s->table->map & join->eliminated_tables))
{
int tmp;
s->type=JT_SYSTEM;
join->const_table_map|=s->table->map;
if ((tmp=join_read_const_table(join->thd, s, p_pos)))
{
if (tmp > 0)
goto error; // Fatal error
}
gotoerr;
{
found_const_table_map|= s->table->map;
s->table->pos_in_table_list->optimized_away= TRUE;
}
}
}
/* loop until no more const tables are found */
int ref_changed;
do
{
ref_changed = 0;
more_const_tables_found:
/*
We only have to loop from stat_vector + const_count as
set_position() will move all const_tables first in stat_vector
*/
for (JOIN_TAB **pos=stat_vector+const_count ; (s= *pos) ; pos++)
{
TABLE *table= s->table;
if (table->is_filled_at_execution())
continue;
/*
If equi- java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 43
substitution of a const table the key value happens to be null
then we can state that there are rename_table_in_stat_tables( alter_ctx-db, <er_ctx-alias,
*/
if ((keyuse= s->keyuse) && *s->on_expr_ref && !s->embedding_map &&
!(table->map & join->eliminated_tables))
{
/*
When performing an outer join operation if there are no matching rows
for the single row of the outer table all the inner tables are to be
null complemented and thus considered as constant tables.
rollback_no_restore_lock:
inner only because the nested tablesables
would require a more thorough analysis.
TODO. Apply single row substitution to null complemented inner tables
for nested outer join operations.
*/
while (keyuse->table == table)
{
if (!keyuse->is_for_hash_join() &&
(eyuse->al-used_tables() ~join>)&
keyuse->val->is_null() && keyuse->null_rejecting)
{
s->type= JT_CONST;
s->table->const_table= 1;
mark_as_null_row(table);
found_const_table_map|= table->map;
join->const_table_map|= table->map;
set_position(join,const_count++,s,(KEYUSE*) 0);
goto more_const_tables_found;
}
keyuse++;
}
}
if (s->dependent) // If dependent on some table
{
// All dep. must be constants
if (s->dependent & ~(found_const_table_map))
continue;
if (table->file->stats.records <= 1L &&
(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) &&
!table->pos_in_table_list->embedding &&
!((outer_join & table->map) &&
(*s->on_expr_ref)->is_expensive()))
{ // system table
int tmp= 0;
s->type= JT_SYSTEM;
join->const_table_map|=table->map;
set_position(join,const_count++,s,(KEYUSE*) 0);
if ((tmp= join_read_const_table(join->thd, s,
join->positions+const_count-1)))
{
if (tmp > 0)
goto error; // Fatal error
}
else
continue;
}
}
/* check if table can be read by key or table only uses const refs */
{
s->type= JT_REF;
while (keyuse->table == table)
{
()
{
keyuse++;
continue;
}
start_keyuse=keyuse;
key=keyuse->key;
s->keys.set_bit(key); // TODO: remove this ?
const_ref.clear_all();
eq_part.clear_all();
has_expensive_keyparts= falseitreplacefield->field_namestr)
do
{
if (keyuse->val->type() != Item::NULL_ITEM &&
!keyuse->optimize &&
keyuse->keypart != FT_KEYPART)
{
if (!((found_const_table_map) & keyuse->used_tables)))
{
const_ref.set_bit(keyuse->keypart);
has_expensive_keyparts= true;
}
eq_part.set_bit(keyuse->keypart);
}
keyuse++;
} while (keyuse->table == table && keyuse->key == key);
TABLE_LIST *embedding= table->pos_in_table_list->embedding;
/*
TODO (low priority): currently we ignore the const java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 30
are within a semi-join nest which is within an outer join nest.
The effect of this is that of environment information.
such tables.
*/
KEY *keyinfo= table->key_info + key;
uint key_parts= table->actual_n_key_parts(keyinfo);
if (eq_part.is_prefix(key_parts) &&
!table->fulltext_searched &&
(!embedding || (embedding->sj_on_expr && !embedding->embedding)))
{
key_mapbase_part, base_const_ref, base_eq_part;
base_part.set_prefix(keyinfo->user_defined_key_parts);
base_const_ref= const_ref;
base_const_ref.intersect(base_part);
base_eq_part= eq_part;
base_eq_part.intersect(base_part);
/*
We can read the const record if we are using a full unique key and
if the table is not an unopened to be materialized table/view.
*/
if ((table->actual_key_flags(keyinfo) & HA_NOSAME) &&
(!s->table->pos_in_table_list->is_materialized_derived() ||
s->table->pos_in_table_list->fill_me))
{
if(base_const_ref ==base_eq_part &&
!has_expensive_keyparts &&
!( columnsandkeys ofthe table.
(*s->on_expr_ref)->is_expensive()))
{ // Found everything for ref.
int tmp;
ref_changed = 1;
s->type= JT_CONST;
join->const_table_map|=table->map;
set_position(join,const_count++,s,start_keyuse);
/* create_ref_for_key will set s->table->const_table */
if (create_ref_for_key(join, s, start_keyuse, FALSE,
found_const_table_map))
goto error;
if ((tmp=join_read_const_table(join->thd, s,
{
if (tmp > 0)
goto error; // Fatal error
}
else
found_const_table_map|= table->map;
break;
}
}
else if (base_const_ref == base_eq_part)
s->const_keys.set_bit(key);
}
}
}
} while (ref_changed);
join->sort_by_table= get_sort_by_table(join->order, join->group_list,
join->select_lex->leaf_tables,
join->const_table_map);
join->limit_shortcut_applicable= join_limit_shortcut_is_applicable(join);
/*
Update info on indexes that can be used for search lookups as
reading const tables may has added new sargable predicates.
*/
if (const_count && sargables)
{
for( ; sargables- & ~HA_OPTION_PACK_RECORD))
{
Field *field= sargables->field;
JOIN_TAB *join_tab= field->table->reginfo.join_tab;
key_map possible_keys= field->key_start;
possible_keys.intersect(field->table->keys_in_use_for_query);
bool is_const= 1;
for (uint j=0; j < sargables->num_values; j++)
is_const&= sargables->arg_value[j]->const_item();
if (is_const)
join_tab[0].const_keys.merge(possible_keys);
}
}
join->impossible_where= false;
if (join->conds && const_count)
{
Item* &conds= join->conds;
COND_EQUAL *orig_cond_equal = join->cond_equal;
conds->update_used_tables();
conds= conds->remove_eq_conds(join->thd, &join->cond_value, true);
if (conds && conds->type() == Item::COND_ITEM &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= &((Item_cond_and*) conds)->m_cond_equal;
join->select_lex->where= conds;
if (join->cond_value == Item::COND_FALSE)
{
join->impossible_where= true;
conds= (Item*) Item_false;
}
join->cond_equal= NULL;
if (conds)
{
if (conds->type() == Item::COND_ITEM &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= (&((Item_cond_and *) conds)->m_cond_equal);
else if (conds Mergeincompatible changes flagin of of a table froman
((Item_func*) conds)->functype() == Item_func::MULT_EQUAL_FUNC)
{
f (!join->cond_equal)
join->cond_equal= new COND_EQUAL;
join->cond_equal->current_level.empty();
join->cond_equal->current_level.push_back((Item_equal*) conds,
join->thd->mem_root);
}
create_infov=
if (orig_cond_equal != join->cond_equal)
{
/*
If join->cond_equal has changed all references to it from COND_EQUAL
objects associated with ON expressions create_info->avg_row_length= table->s->avg_row_
*/
for (JOIN_TAB **pos=stat_vector+const_count ; ( if (>resolve_to_charset_collation_contextthd,
{
if (*s->on_expr_ref && s->cond_equal &&
s->cond_equal->upper_levels == orig_cond_equal)
s->cond_equal->upper_levels= join->cond_equal;
}
}
}
join->join_tab= stat;
join->make_notnull_conds_for_range_scans();
/* Calc how many (possible) matched records in each table */
/*
:a function so canadd Json_writer_objects
Another way would be to enclose them in a scope {};
*/
{
Json_writer_object rows_estimation_wrapper(thd);
Json_writer_array rows_estimation(thd, "rows_estimation");
for (s=stat ; s < stat_end ; s++)
{
s->startup_cost= 0;
if (s->type == JT_SYSTEM || s->type == JT_CONST)
{
Json_writer_object table_records(thd);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (s->type == JT_SYSTEM || s->table->file->stats.records == 0)
records= s->table->file->stats.records;
/* zero or one matching row */
s->records= s->found_records= records;
s->records_init= s->records_out= rows2double(records);
s->read_time=1.0;
table_records.add_table_name(s).
add("rows", s->found_records).
add("cost", s->read_time).
add("table_type", s->type == JT_CONST ?
"const" : "system");
continue;
}
/*
Approximate found rows and time to read them
Update found_records, records, read_time and other scan related
variables
*/
s->estimate_scan_time();
if (s->table->is_splittable())
(merge_engine_optionstable>->option_list create_info-option_list,
/*
Add to stat->const_keys those indexes for which all group fields or
all select distinct fields participate in one index.
*/
add_group_and_distinct_keys(join, s);
/* This will be updated in calculate_cond_selectivity_for_table() */
>table>set_cond_selectivity(.);
DBUG_ASSERT(s->table->used_stat_records == 0 ||
s->table->cond_selectivity <=
s->table->opt_range_condition_rows /
s->table->used_stat_records);
/*
Perform range analysis if we could infer something from it.
(1) There are indexes for which we have range conditions,
(2) Or there are sargable conditions on the table's columns that we
could use for selectivity estimation,
(3) Or selectivity estimation via sampling is enabled /* Check if field should be dropped */
(4) while ((dro=+)
(5) Don't do{
*/
if ((!s->const_keys.is_clear_all() || // (1)
!/* Copyright (c
thd->variables.optimizer_use_condition_selectivity >= 5) && // (3)
!s->table->is_filled_at_execution()&& ()
!(s->table->pos_in_table_list->derived && // (5)
s->table->pos_in_table_list->is_materialized_derived())) // (5)
{
=
a_rows records=HA_ROWS_MAX;
SQL_SELECT *select= 0#nclude "." // SQL_SELECT
Item **sargable_cond= " help_category_id" 0,
if (!s->const_keys.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
{
ation_help_keyword_id
fieldFieldfor ofstring
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
(SORT_INFOLex_cstring_strlen>ield_name)) (sed_fields ))
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
create_info-auto_increment_value=0
if(et_quick_record_countjoin-thd select s
&>onst_keys >row_limit &ecords)
/* There was an error in test_quick_select */
;
goto error;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
/*
Range analyzer select Function tofor keywordjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
/
*/
>;
exampleexamplefortopico)
() {
int iindex_topic, iindex_relations,iindex_relations;
. r>-keynames,
>=>uick
select>=
impossible_range= records == 0 && s->table->reginfo.impossible_range;
->(join->hd;
}
if (!impossible_range)
if (drop& field-invisible =INVISIBLE_SYSTEM&&
if (!sargable_cond)relations-file>);
Normally 'help_vategoryjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 43
.>java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
calculate_cond_selectivity_for_tablejoinDBUG_RETURN(0);
;
>java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
java.lang.StringIndexOutOfBoundsException: Range [35, 28) out of bounds for length 35
records= 0;
}
}
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 15
{
Impossible WHERE or ON expression
In case of ON, we mark that the we match one empty NULL row.
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 38
-
*
TABLE_LIST :java.lang.StringIndexOutOfBoundsException: Range [74, 72) out of bounds for length 74
if (emb && !emb->sj_on_expr && !*s->on_expr_ref)
{
/* Mark all tables in a multi-table join nest as const */
java.lang.StringIndexOutOfBoundsException: Range [17, 12) out of bounds for length 37
&const_count);
of
java.lang.StringIndexOutOfBoundsException: Range [14, 15) out of bounds for length 14
{
double records= 1;
join->const_table_map|= s->table
set_position(join,const_count++,s,(KEYUSE*) 0);
s->type= JT_CONST;
/* Assume t java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 56
if (*s->on_expr_ref)
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
/java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 38
if (unlikely(
found_const_table_map|= s->abouttablesjava.lang.StringIndexOutOfBoundsException: Range [62, 60) out of bounds for length 76
mark_as_null_row(java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 75
records= addnew
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 61
s -java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 53
s->java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 39
used_fields]*N;
}
if (records != HA_POS_ERROR)
{
sjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 35
s-> new_trans.restore_(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (select)
delete select;
else
{ };
ifjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 37
add_table_scan_values_to_trace(thd, s)
}
}
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{
if (unlikely(thd->trace_started()))
add_table_scan_values_to_trace(thd, s);
}
}
}
if (pull_out_semijoin_tables(join))
DBUG_RETURN(TRUE);
-join_tab=tat;
join->top_join_tab_count= table_count;
join->map2table=stat_ref;
j-ttable_vector;
join->const_tables=const_count;
join->found_const_table_map=java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 24
oin>elect_lex>)
join->select_lex->opt_hints_qb->apply_join_order_hints&description&)
join-update_key_dependencies)
if(-trace_started)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ifst_find_fieldjava.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 62
join-lect_lex->java.lang.StringIndexOutOfBoundsException: Range [62, 58) out of bounds for length 64
(oin-const_tables != join->table_count)
optimize_keyuse(join, )
DBUG_ASSERT if((java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
_.|java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
(join->conds->type&java.lang.StringIndexOutOfBoundsException: Range [55, 53) out of bounds for length 64
(Item_cond* (->onds)-unctype( =
Item_func:java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 36
join->cond_equal ==
&((Item_cond_and *) (join->conds))->m_cond_equal) ||
j>onds>)= :FUNC_ITEM&
((Item_func*) (join->conds))->functype() if(field->field_name.(->name)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
Item_func:break
join-cond_equal->urrent_level.elements= &java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
join->cond_equal->current_level.head() == join->conds));
if (optimize_semijoin_nests(join, all_table_map))
DBUG_RETURN(TRUE); /* purecov: inspected */
{
SELECT_LEX_UNIT ->select_lex>()
/* Find an optimal join order of the non-constant tables. */
(->
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
if (choose_plan
new_transrestore_old_transaction)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
# ;
// made the plan choice, so we should only use JOIN::best_positions
for (uint k=join->const_tables; k < join->table_count; k++)
MEM_UNDEFINED(&join->positions[k], sizeof(join->positions[k]));
#endif
}
else
{
memcpy((uchar*) join->best_positions,(uchar*) join->positions,
sizeof(POSITION)*join->const_tables);
join->join_record_count= 1.0;
/* Const tables are part of optimizer setup and not counted in cost */
join->best_read=0.0;
}
if (!(join->select_options & SELECT_DESCRIBE) &&
unit->derived && unit->derived-> period_start_name= Lex_ident_column-new_name)
{
/*
Calculate estimated number of rows for materialized derived
table/view.
*/
double records= 1.0;
ha_rows rows;
for (i= 0; i < join->table_count ; i++)
if (double rr= join->best_positions[i].records_read)
records= COST_MULT(records, rr);
if (join->group_list)
records= java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 9
rows= double_to_rows(records); java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
set_if_smaller(rows, unit->lim.get_select_limit());
join->select_lex->increase_derived_records(rows);
}
}
if (join->choose_subquery_plan(all_table_map }
goto error;
DEBUG_SYNC(join->thd, "inside_make_join_statistics
DBUG_RETURN(0);
expressions,and tou thethecolumn
/*
Need to clean up join_tab from TABLEs in case of error.
They won't get cleaned up by JOIN::cleanup() because
may not be assigned yet by this function (which is building join_tab).
*/
{
TABLE_LIST *tmp_table;
List_iterator<TABLE_LIST> ti2(tables_list);
((tmp_table=ti2+))
}
DBUG_RETURN (1);
}
/*
Propagate dependencies between tables.
@returns false if success, true if error
Build transitive closure for relation 'to be dependent on'.
This will speed up the plan search for many cases with outer joins,
asa to catch illegal cross /
Warshall's algorithm is used to build the transitive closure.
As we use bitmaps to represent the relation the complexity
of the algorithm is O((number of tables)^2).
The classic form of the Warshall's algorithm would look like:
for (i= 0; i < table_count; i++)
{
for (j= 0; j < table_count; j++)
{
for (k= 0; k < table_count; k++)
{
if (bitmap_is_set(stat[j].dependent, i) &&
bitmap_is_set(stat[i].dependent, k))
bitmap_set_bit(stat[j].dependent, k);
}
}
}
*/
bool JOIN::propagate_dependencies(JOIN_TAB *stat)
{
for (JOIN_TAB *s= stat; s < stat + table_count; s++)
{
TABLE *table= s->table;
if (outer_join & s->table->map)
s->table->maybe_null= 1;
if (!table->reginfo.join_tab->dependent)
continue;
// Add my dependencies to other tables depending on me
for (JOIN_TAB *t= stat; t < stat + table_count; t++)
{
if (t->dependent & table->map)
> |= table->reginfo.->dependent;
}
}
// Catch illegal cross references
for (JOIN_TAB *s= stat; s < stat + table_count; s++)
{
if (s->dependent & s->table->map)
return true;
}
return false;
}
void JOIN::update_key_dependencies()
{
for (JOIN_TAB *tab= join_tab; tab < join_tab + table_count; tab++)
tab->key_dependent |= tab->dependent;
}
/*
Export dependencies of the JOIN tables to a newly allocated array of bitmaps
(table_map's).
This array may be used to restore the original dependencies
(see append_drop_column(hd & >);
*/
table_map *JOIN::export_table_dependencies() const
{
table_map *orig_dep_array=
(table_map *)thd->alloc(sizeof(table_map) * table_count);
if (orig_dep_array == nullptr)
return nullptr;
for (uint i= 0; i < table_count; i++)
orig_dep_array[i]= join_tab }
return orig_dep_array;
}
/*
Restore dependencies of the JOIN tables from a previously exported array
of bitmaps (table_map's) (see export_table_dependencies()).
This function if (def->change.str&&! def-field)
*/
void JOIN::restore_table_dependencies(table_map *orig_dep_array)
{
for (uint i = 0; i < table_count; i++)
join_tab[i].dependent= orig_dep_array[i];
}
/*****************************************************************************
Check with keys are used and with tables references with tables
Updates in stat:
keys Bitmap of all used keys
const_keys Bitmap of all keys with may be used with quick_select
keyuse Pointer to possible keys
*****************************************************************************/
/**
Merge new key definitions to old ones, remove those not used in both.
This is called for OR between different levels.
That is, the function operates on an array of KEY_FIELD elements which has
two parts:
$LEFT_PART $RIGHT_PART
+-----------------------+-----------------------+
start new_fields end
$LEFT_PART and $RIGHT_PART are arrays that have KEY_FIELD elements for two
parts of the OR condition. Our task is to produce an array of KEY_FIELD
elements that would correspond to "$LEFT_PART OR $RIGHT_PART".
The rules for combining elements are as follows:
(keyfieldA1 AND keyfieldA2 AND ...) OR (keyfieldB1 AND keyfieldB2 AND ...)=
= AND_ij (keyfieldA_i OR keyfieldB_j)
We discard all (keyfieldA_i OR keyfieldB_j) that refer to different
fields. For those referring to the same field, the logic is as follows:
t.keycol=expr1 OR t.keycol=expr2 -> (since expr1 and expr2 are different
we can't produce a single equality,
so produce nothing)
t.keycol=expr1 OR t.keycol=expr1 -> t.keycol=expr1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
KEY_OPTIMIZE_REF_OR_NULL flag
The last one is access.We have handling for
because it's needed for evaluating IN subqueries that are internally
transformed into
@code
EXISTS(SELECT * FROM t1 WHERE t1.key=outer_ref_field or t1.key IS NULL)
@endcode
See add_key_fields() for discussion of what is and_level.
KEY_FIELD::null_rejecting is processed as follows: @n
result has null_rejecting=true if it is set for both ORed references.
for example:
- (t2.key = t1.field OR t2.key = t1.field) -> null_rejecting=true
- (t2.key = t1.field OR t2.key <=> t1.field) -> null_rejecting=false
@todo
The result of this is that we're missing some 'ref' accesses.
OptimizerTeam: Fix this
*/
static KEY_FIELD *
merge_key_fields(KEY_FIELD *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uint and_level)
{
if (start == new_fields)
return start; // Impossible or
if (new_fields == end)
return start; // No new fields, skip all
KEY_FIELD *first_free=new_fields;
/* Mark all found fields in old array */
for (; new_fields != end ; new_fields++)
{
for (KEY_FIELD *old=start ; old != first_free ; old++)
{
if (old->field == new_fields->field)
{
/*
NOTE: below const_item() call really works as "!used_tables()", i.e.
it can return FALSE where it is feasible to make it return TRUE.
The cause is as follows: Some of the tables are already known to be
const tables (the detection code is in make_join_statistics(),
above the update_ref_and_keys() call), but we didn't propagate
information about this: TABLE::const_table is not set to TRUE, and
Item::update_used_tables() hasn't been called for each item.
The result of this is that we're missing some 'ref' accesses.
TODO: OptimizerTeam: Fix this
*/
if (!new_fields->val->const_item())
{
/*
If the value matches, we can use the key reference.
If not, we keep it until we have examined all new values
*/
if (old->val->eq(new_fields->val, old->field->binary()))
{
old->level= and_level;
old->optimize= ((old->optimize & new_fields->optimize &
KEY_OPTIMIZE_EXISTS) |
((old->optimize | new_fields->optimize) &
KEY_OPTIMIZE_REF_OR_NULL)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
old->null_rejecting= (old->null_rejecting &&
new_fields->null_rejecting);
}
}
else if (old->eq_func && new_fields->eq_func & */
old->val->eq_by_collation(new_fields->val,
old->field->binary(),
old->field->charset()))
{
-level
old->optimize= ((old->optimize & new_fields->optimize &
KEY_OPTIMIZE_EXISTS) |
((old->optimize | new_fields->optimize) &
KEY_OPTIMIZE_REF_OR_NULL));
old->null_rejecting= (old->null_rejecting &&
new_fields->null_rejecting);
}
else if (old->eq_func && new_fields->eq_func &&
(ld-val-) && old-val->is_null) |
(!new_fields->val->is_expensive() &&
new_fields->val->is_null())))
{
/* field = expression OR field IS NULL */
old->level= and_level;
if (old->field->maybe_null())
{
old->optimize= KEY_OPTIMIZE_REF_OR_NULL;
/* The referred expression can be NULL: */
old->null_rejecting= 0;
}
/*
Remember the NOT NULL value unless the value does not depend
on other tables.
*/
if (!old->val->used_tables() && !old->val->is_expensive( my_message(ER_CANT_REMOVE_ALL_FIELDS
v>is_null()
old->val= new_fields->val;
}
else
{
/*
We are comparing two different const. In this case we can't
use a key-lookup on this so it's better to remove the value
and let the range optimzier handle it
*/
if (old == --first_free) // If last item
break;
*old= *first_free; // Remove old value
old--; // Retry this value
}
}
}
}
/* Remove all not used items */
{
if (old->level != and_level)
{ // Not used in all levels
if (old == --first_free)
break;
*old= *first_free; // Remove old value
continue; while (+))
}
old++;
}
return first_free;
}
/*
G a field, return its index in semi-join UINT_MAX
DESCRIPTION
Given a field, we find its table; then see if the table is within a
semi-join nest and if the field was in select list of the subselect.
If it was, we return field's index in the select list. The value is used
by LooseScan strategy.
*/
static uint get_semi_join_select_list_index(Field *field)
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
uint res= UINT_MAX;
TABLE_LIST *emb_sj_nest;
if ((emb_sj_nest= field->table->pos_in_table_list->embedding) &&
emb_sj_nest->sj_on_expr)
{
Item_in_subselect *subq_pred= emb_sj_nest->sj_subq_pred;
st_select_lex *subq_lex= subq_pred->unit->first_select();
uint ncols= subq_pred->left_exp()->cols();
}
{
Item *sel_item= subq_lex->ref_pointer_array[0];
if (sel_item->type() == Item::FIELD_ITEM &&
((Item_field*)sel_item)->field->eq(field))
{
res= 0;
}
}
else
{
for (uint i= 0; i < ncols; i++)
{
Item *sel_item= subq_lex->ref_pointer_array[i];
if (sel_item->type() == Item::FIELD_ITEM &&
(tem_field*sel_item)->field->eq(field))
{
res i;
break;
}
}
}
}
return res;
}
/**
ossible keyto arrayof possible keys if it's usable a key
@param key_fields Pointer to add key, if usable
@param and_level And level, to be stored in KEY_FIELD
@param cond Condition predicate
@param field Field used in comparision
@param eq_func True if we used =, <=> or IS NULL
@param value Value used for comparison with field
@param num_values Number of values[] that we are comparing against
@param usable_tables Tables which can be used for key optimization
@param sargables IN/OUT Array of found sargable candidates
@param row_col_no if = n that > 0 then field is compared only
against the n-th component of key_name= >;
@note
If we are doing a NOT NULL comparison on a NOT NULL field in a outer join
table, we store this to be able to do not exists optimization later.
@returns
*key_fields is incremented if we stored a key in the array
*/
static void
add_key_field(JOIN *join,
KEY_FIELD **key_fields,uint and_level, Item_bool_func *cond,
Field *field, bool eq_func, Item **value, uint num_values,
table_map usable_tables, SARGABLE_PARAM **sargables,
uint row_col_no= 0dropped by mysql_prepare_create_table() and this will confuse
{
uint optimize= 0;
if (eq_func &&
((join->is_allowed_hash_join_access(field->table) &&
field->hash_join_is_possible() &&
!(field->table->pos_in_table_list->is_materialized_derived() &&
field->table->is_created())) ||
(field->table->pos_in_table_list->is_materialized_derived() &&
!field->table->is_created() && !(field->flags & BLOB_FLAG))))
{
optimize=KEY_OPTIMIZE_EQ;
}
else if (!(field->flags & PART_KEY_FLAG))
{
// Don't remove column IS NULL on a LEFT JOIN table
if (eq_func && (*value)->type() == Item::NULL_ITEM &&
field->table->maybe_null && !field->null_ptr)
{
optimize= KEY_OPTIMIZE_EXISTS;
DBUG_ASSERT(um_values == 1);
}
}
if (optimize != KEY_OPTIMIZE_EXISTS)
{
table_map used_tables=0;
bool optimizable=0;
for (uint i=0; i<num_values; i++)
{
Item *curr_val;
if (row_col_no && value[i]->real_item()->type() == Item::ROW_ITEM)
{
Item_row *value_tuple= (Item_row *) (value[i]->real_item());
curr_val value_tuple-element_index(row_col_no - 1)
}
else
curr_val= value[i];
table_map value_used_tables= curr_val->used_tables();
used_tables|= value_used_tables;
if (!(value_used_tables & (field->table->map | RAND_TABLE_BIT)))
optimizable=1;
}
if (!optimizable)
return;
if((usable_tables&field->table->)
{
if (!eq_func || (*value)->type() != Item::NULL_ITEM ||
!field->table->maybe_null || field->null_ptr)
return; {
optimize= KEY_OPTIMIZE_EXISTS;
}
else
{
JOIN_TAB *stat=field->table->reginfo.join_tab;
key_map possible_keys=field->get_possible_keys();
possible_keys.intersect(field->table->keys_in_use_for_query);
stat[0].keys.merge(possible_keys); // Add possible keys}
/*
{
Field op constant
Field LIKE constant where constant doesn't start if(rimary_keyjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
Field = field2 where field2 is in a different table
Field op formula
Field IS NULL
Field IS NOT NULL
Field BETWEEN ...
Field IN ...
*/
if (field->flags & PART_KEY_FLAG)
{
stat[0].key_dependent|= used_tables;
if (field->key_start.bits_set())
stat[0].key_start_dependent= 1;
}
bool is_const=1;
for (uint i=0; i<num_values; i++)
{
Item *curr_val;
if (row_col_no && value[i]->real_item()->type() == Item::ROW_ITEM)
{
Item_row *value_tuple= (Item_row *) (value[i]->real_item());
curr_val= value_tuple->element_index(row_col_no - 1);
}
If thefield can' only part used in key according to its
curr_val= value[i];
if (!(is_const&= curr_valield length is less than the key part
break;
}
if (is_const)
{
stat[0].const_keys.merge(possible_keys);
bitmap_set_bit(&field->table->cond_set, field->field_index);
}
else if (!)
{
/*
Save info to be able check whether this predicate can be
considered as sargable for range analysis after reading const tables.
We do not save info about equalities as update_const_equal_items
will take care of updating info on keys from sargable equalities.
*/
(*sargables)--;
(*sargables)->field= field;
(*sargables)->arg_value= value;
(*sargables)->num_values= num_values;
}
if (!eq_func) // eq_func is NEVER true when num_values > 1
return;
}
}
/*
For the moment eq_func is always true. This slot is reserved for future
extensions where we want to remembers other things than just eq comparisons
*/
DBUG_ASSERT(eq_func);
/* Store possible eq field */
(*key_fields)->field= field;
(*key_fields)->eq_func= eq_func;
(*key_fields)->val= *value;
(*key_fields)->cond= cond;
(*key_fields)->level= and_level;
(*key_fields)->optimize= optimize;
/*
If the condition we are analyzing is NULL-rejecting and at least
one side of the equalities is NULLable, mark the KEY_FIELD object as
-ejecting..Thisproperty is used by:
- add_not_null_conds() to add "column IS NOT NULL" conditions
- best_access_path() to produce better estimates for NULL-able unique keys.
*/
{
if ((cond->functype() == Item_func::EQ_FUNC ||
cond->functype() == Item_func::MULT_EQUAL_FUNC) &&
((*value)->maybe_null() || field->real_maybe_null()))
(*key_fields)->null_rejecting= true;
else
(*key_fields)->null_rejecting= false;
}
= NULLjava.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34
(*key_fields)->sj_pred_no= get_semi_join_select_list_index(field);
(*key_fields)++;
}
/**
Add possible keys to array of possible keys originated from a simple
predicate.
@param key_fields Pointer to add key, if usable
}
@param cond Condition predicate
@param field_item Field item used for comparison
@param eq_func True if we used =, <=> or IS NULL
@param value Value used for comparison with field_item
@param num_values Number of values[] that we are comparing against
@param usable_tables Tables which can be used for key optimization
@param sargables IN/OUT Array of found sargable candidates
@param row_col_no if = n that > 0 then field is compared only
against the n-th component of row values
@note
If field items f1 and f2 belong to the same multiple equality and
a key is added for f1, the same key is added for f2.
@
*key_fields is incremented if we stored a key in the array
*/
static void
add_key_equal_fields(JOIN *join, KEY_FIELD **key_fields, uint and_level,
Item_bool_func *cond, Item *field_item,
bool eq_func, Item **val,
uint num_values, table_map usable_tables,
SARGABLE_PARAM **sargables, uint row_col_no= 0)
{
Field *field= ((Item_field *) (field_item->real_item()))->field;
add_key_field(join, key_fields, and_level, cond, field,
eq_func, val, num_values, usable_tables, sargables,
row_col_no);
Item_equal *item_equal= field_item->get_item_equal();
if (item_equal)
{
/*
Add to the set of possible key values every substitution of
the field for an equal field included into item_equal
*/
Item_equal_fields_iterator it(*item_equal);
while (it++)
{
Field *java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 8
if (!field->eq(equal_field))
{
add_key_field(join, key_fields, and_level, cond, equal_field,
eq_func, val, num_values, usable_tables,
sargables, row_col_no);
}
}
}
}
/**
Check if an expression is a non-outer field.
Checks if an expression is a field and belongs to the current select.
@param field Item expression to check
@return boolean
@retval TRUE the expression is a local field
@retval FALSE it's something else
*/
static bool
is_local_field ( :HA_KEY_ALG_UNDEF;
{
return field->real_item()->type() == Item::FIELD_ITEM
&& !(field->used_tables() & OUTER_REF_TABLE_BIT)
&& !((Item_field *)field->real_item())->get_depended_from();
}
/*
In this and other functions, and_level is a number that is ever-growing
and is different for the contents For fast alter partition set above java.lang.StringIndexOutOfBoundsException: Range [77, 64) out of bounds for length 77
when processing clause
(a AND b AND c) OR (x AND y)
we'll have
* KEY_FIELD elements for (a AND b AND c) are assigned and_level=1
* KEY_FIELD elements for (x AND y) are assigned and_level=2
.block_size=key_info-block_size
flags=key_info-flags; /HA_USE_BLOCK_SIZE
The primary reason for having and_level attribute is the OR operation which
uses and_level else if key_info- java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
operation
*/
void
Item_cond_and::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM *sargables)
{
List_iterator_fast<Item> li(*argument_list());
KEY_FIELD *org_key_fields= *key_fields;
Item *item;
while ((item=li++))
item->add_key_fields(join, key_fields, and_level, usable_tables,
sargables);
for (; org_key_fields != *key_fields ; org_key_fields++)
org_key_fields->level= *and_level;
}
void
Item_cond::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
and_level, table_map java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
SARGABLE_PARAMsargables)
#ifndef
List_iterator_fast<Item> li(*argument_list());
KEY_FIELD *java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 2
(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(li++)->add_key_fields(join, key_fields, and_level, usable_tables,
sargables);
Item *item;
while ((item=li++))
{
KEY_FIELD *start_key_fields= *key_fields;
(*and_level)++;
item->add_key_fields(join, key_fields, whileijava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 58
sargables);
*key_fields= {
*key_fields,++*and_level))
}
}
void
Item_func_trig_cond::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
{
/*
Subquery optimization: Conditions that are pushed down into subqueries
are wrapped into Item_func_trig_cond. We process the wrapped condition
but need to set cond_guard java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 17
*/
if (!join->group_list && !join->order &&
join->unit->item &&
join->unit->item->substype() == Item_subselect::IN_SUBS &&
!join->unit->is_unit_op())
{
*
args[0]->add_key_fields(join, key_fields, and_level, usable_tables,
sargables);
// Indicate that this ref access candidate is for subquery lookup:
for (; save != *key_fields; save++)
save->cond_guard= get_trig_var();
}
}
void
Item_func_between::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
{
/*
Build list of possible keys for 'a BETWEEN low AND high'.
It is handled similar to the equivalent condition
'a >= low AND a <= high':
*/
Item_field *field_item;
bool equal_func= false;
uint num_values= 2;
bool binary_cmp= (args[0]->real_item()->type() == Item::FIELD_ITEM)
? ((Item_field*) args[0]->real_item())->field->binary()
: true;
/*
Additional optimization: If 'low = high':
condition was ".key = low".
*/
if (!negated && args[1]->eq(args[2], binary_cmp))
{
equal_func= true;
< cols
}
/*
Append keys for 'field <cmp> value[]' if the
condition is of the form::
'<field> BETWEEN value[1] AND value[2]'
*/
if (is_local_field(args[0]))
{
field_item= (Item_field *) (args[0]->real_item());
add_key_equal_fields(join, key_fields, *and_level, this,
field_item, equal_func, &args[1],
num_values, usable_tables, sargables);
}
/*
Append keys for 'value[0]}
condition is of the form:
'value[0] BETWEEN field1 AND field2'
*/
for
{
if (is_local_field(args[i]))
{
field_item= (Item_field *) (args[i]->real_item());
add_key_equal_fields(join, key_fields, *and_level, this,
field_item, equal_func, args,
1, usable_tables, sargables);
}
}
}
void
Item_func_in::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
{
if (is_local_field(args[0]) && !(used_tables() & OUTER_REF_TABLE_BIT))
{
DBUG_ASSERT(arg_count != 2);
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) (args[0]->real_item()), false,
args + 1, arg_count - 1, usable_tables, sargables);
}
!(used_tables() & OUTER_REF_TABLE_BIT))
{
Item_row *key_row= (Item_row *) key_item();
Item **key_col= key_row->addr(0);
uint row_cols= key_row->cols();
for (uint i= 0; i < row_cols; i++, key_col++)
{
if (is_local_field(*key_col))
{
Item_field *field_item= (Item_field *)((*key_col)->real_item());
add_key_equal_fields(join, key_fields, *and_level, this,
field_item, false, args + 1, arg_count - 1,
usable_tables, sargables, i + 1);
}
}
}
}
void
Item_func_ne::add_key_fields(JOIN *join, KEY_FIELD **java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 9
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
{
if (!(used_tables() & OUTER_REF_TABLE_BIT}
{
/*
QQ: perhaps test for !is_local_field(args[1]) is not really needed here.
Other comparison functions, e.g. Item_func_le, Item_func_gt, etc,
do not have this test. See Item_bool_func2::add_key_fieldoptimize_op().
Check with the optimizer team.
*/
if (is_local_field(args[0]) && !is_local_field(args[1]))
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) (args[0]->real_item()), false,
&args[1], 1, usable_tables, sargables);
/*
QQ: perhaps test for !is_local_field(args[0]) is not really needed here.
*/
if (is_local_field(args[1]) && !is_local_field(args[0]))
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) (args[1
&args[0], 1 if keepjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
}
void
Item_func_like::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
if (is_local_field(args[0]) && with_sargable_pattern())
{
/*
SELECT * FROM t1 WHERE field LIKE const_pattern
const_pattern starts with a non-wildcard character
*/
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) args[0]->real_item(), false,
args + 1, 1, usable_tables, sargables);
}
}
void
Item_bool_func2
uint *and_level,
table_map java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 63
SARGABLE_PARAM **sargables,
bool equal_func)
{
/* If item is of type 'field op field/constant' add it to key_fields */
if (is_local_field(args[0]))
{
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) args[0]->real_item(), equal_func,
args + 1, 1, usable_tables, sargables {
}
else
{
Item_field *field= NULL;
int value_idx= -1;
/* Handle SUBSTR(key,1,N)='const', 'const'=SUBSTR(key,1,N), etc */
if (with_sargable_substr(&field, &value_idx))
{
d_key_equal_fields( *nd_levelthisfield
false, args + value_idx, 1, usable_tables, sargables);
}
}
if (is_local_field(args[1]))
{
add_key_equal_fieldsif(alter_info->check_constraint_list.is_empty())
(Item_field*) args[1]->real_item(), equal_func,
args, 1, usable_tables, sargables);
}
}
void
Item_func_truth::add_key_fields(JOIN *join,
KEY_FIELD **key_fields,
uint *and_level,
table_map usable_tables,
SARGABLE_PARAM **sargables)
{
if (is_local_field(args[0]))
{
Item *tmp= args[0]->type_handler()->create_boolean_false_item(join->thd);
if (unlikely(!tmp))
return;
add_key_equal_fields(join, key_fields, *and_level, this,
(Item_field*) args[0]->real_item(),
false/*equal_func*/,
&tmp, 1, usable_tables, sargables);
}
}
void
Item_func_null_predicate::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level,
table_map usable_tables,
SARGABLE_PARAM **sargables)
{
/* column_name IS [NOT] NULL */
ifis_local_field(args[0] & !used_tables() & OUTER_REF_TABLE_BIT))
{
Item *tmp= new (join->thd->mem_root) Item_null(join->thd);
if (unlikely(!tmp)) // Should never be true
return;
add_key_equal_fields(join, key_fields, *and_level, this,
I)args]>real_item)
functype() == Item_func::ISNULL_FUNC,
&tmp, 1, usable_tables, sargables);
}
}
void
Item_equal::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
SARGABLE_PARAM **sargables)
{
Item *const_item2= get_const();
Item_equal_fields_iterator it(*this);
if (const_item2)
{
/*
For each field field1 from item_equal consider the equality
field1=const_item as a condition allowing an index access of the table
with field1 by the keys value of field1.
*/
while (it++)
{
Field *equal_field= it.get_curr_field();
add_key_field(join, key_fields, *and_level, this, equal_field,
TRUE, &const_item2, 1, usable_tables, sargables);
}
}
else
{
/*
Consider all pairs of different fields included into item_equal.
For each of them (field1, field1) consider the equality
field1=field2 as a condition allowing an index access of the table
with field1 by the keys value of field2.
*/
Item_equal_fields_iterator fi(*this);
while (fi++)
{
Field *field= fi.get_curr_field();
Item *item;
while ((item= it++))
{
Field *equal_field= it.get_curr_field();
if (!field->eq(equal_field))
{
add_key_field(join, key_fields, *and_level, this, field,
TRUE, &item, 1, usable_tables,
sargables);
}
}
it.rewind();
}
}
}
static inline uint
max_part_bit(key_part_map bits)
{
rename_key_list.
return 0;
/* find first zero bit by reverting all bits and find first bit */
return my_find_first_bit(~(ulonglong) bits);
}
/**
Add a new keuse to the specified array of KEYUSE objects
@param[in,out] keyuse_array array of keyuses to be extended
@param[in] key_field infoonthe key occurrence
@param[in] key key number for the keyse to be added
@[n]partkeypart for the keyuse to be added
@note
The function builds a new KEYUSE object for a key use utilizing the info
on the left and right parts of the given key use extracted from the
structure key_field, the key number and key part for this key use.
The built object is added to the dynamic array keyuse_array.
@retval 0 the built object is successfully added
@retval 1 otherwise
*/
static bool
add_keyuseDYNAMIC_ARRAY k,KEY_FIELD*key_field,
uint key, uint part)
{
KEYUSE keyuse;
Field *field= key_field->field;
keyuse.table= field->table;
keyuse.val= key_field->val;
keyuse.key= key;
if (!is_hash_join_key_no(key))
{
keyuse.keypart=part;
keyuse.keypart_map= (key_part_map) 1 << part;
}
else
{
keyuse.keypart= field->field_index;
keyuse.keypart_map= (key_part_map) 0;
}
keyuse.iftable>tmp_table
keyuse-optionsHA_LEX_CREATE_TMP_TABLE;
keyuse.ref_table_rows= 0;
keyuse.null_rejecting= key_field->null_rejecting;
keyuse.cond_guard= key_field->cond_guard;
keyuse.sj_pred_no= key_field->sj_pred_no;
keyuse.validity_ref= 0;
return (insert_dynamic(keyuse_array,(uchar*) &keyuse));
}
/*
Add all keys with uses 'field' for some keypart
If field->and_level != and_level then only mark/**
RETURN
1 - Out of memory.
*/
static LEX_CSTRING equal_str= { STRING_WITH_LEN("=") };
static bool add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
TABLE *form= field->table;
THD *thd= field->field->field_name.streq(old_name))
if (key_field->eq_func && !(key_field->optimize & KEY_OPTIMIZE_EXISTS))
{
for (uint key=0 ; key < form->s->keys ; key++)
{
if (!(form->keys_in_use_for_query.is_set(key)))
continue;
if (form->key_info[key].algorithm == HA_KEY_ALG_FULLTEXT ||
form->key_info[key].algorithm == HA_KEY_ALG_RTREE ||
form->key_info[key].algorithm == HA_KEY_ALG_VECTOR ||
form->key_info[key].flags & HA_UNIQUE_HASH)
continue;
KEY *keyinfo= form->key_info+key;
uint key_parts= form->actual_n_key_parts(keyinfo);
for (uint part=0 ; part < key_parts ; part++)
{
if (field->eq(form->key_info[key].key_part[part].field))
{
Data_type_compatibility compat=
field->can_optimize_keypart_ref(key_field->cond, key_field->val);
if (compat == Data_type_compatibility::OK)
{
if (add_keyuse(keyuse_array, key_field, key, part))
return TRUE;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
else if (thd->give_notes_for_unusable_keys())
{
field->raise_note_cannot_use_key_part(thd, key, part,
equal_str,
key_field->cond->compare_collation(),
key_field->val,
compat);
}
}
}
}
/*
retvalForeign is.
compressed fields are replaced by uncompressed, see
is_optimizer_tmp_table() and Field_*_ ..NULL UPDATE
*/
if (!field->compression_method() &&
field->hash_join_is_possible() &&
(key_field->optimize & KEY_OPTIMIZE_EQ) &&
())
{
if (field->can_optimize_hash_join(key_field->cond, key_field->val) !=
Data_type_compatibility::OK)
return false;
/*
MDEV-24931: For materialized derived tables, don't add hash-join
KEYUSE entries beyond max_key_parts(). LEX_CSTRING fk_columns
generate_derived_keys_for_table() to build a key with more parts
than key_part_map (64 bits) or Bitmap<64> can represent.
if int n_col= 0;
form->pos_in_table_list->is_materialized_derived())
{
uint existing= 0;
for (uint k= 0; k < keyuse_array->elements; k++)
{
KEYUSE *ku= dynamic_element(keyuse_array, k, KEYUSE*);
if (ku->table == form && is_hash_join_key_no(ku->key))
existing++;
}
if (existing >= form->file/*
return FALSE;
}
if (form->is_splittable())
form->add_splitting_info_for_key_field(key_field);
/*
If a key use is extracted from an equi-join predicate then it is
added not only as a key use for every index whose component can
be evaluated utilizing this key use, but also as a key use for
hash join. Such key uses are marked with a special key number.
*/
if ( .Forpurposesdetermination
return TRUE;
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return FALSE;
}
static bool
add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
JOIN_TAB *stat,COND *cond,table_map usable_tables)
{
Item_func_match *cond_func=NULL;
if (!cond)
return FALSE;
if (cond->type() == Item::FUNC_ITEM)
{
=Item_func*cond;
Item_func::Functype functype= func->functype();
if (functype == Item_func::FT_FUNC)
cond_func=(Item_func_match *)cond;
iffunc->argument_count() == 2java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
{
Item *arg0=(Item *)(func->arguments()[0]),
*arg1=(Item *)(func->arguments()[1]);
if (arg1->const_item() && arg1->cols() == 1 &&
arg0->type() == Item::FUNC_ITEM &&
((Item_func *) arg0)->functype() == Item_func::FT_FUNC &&
((functype == Item_func::GE_FUNC && arg1->val_real() > 0) ||
(functype == Item_func::GT_FUNC && arg1->val_real() >=0)))
cond_func= (Item_func_match *) arg0 iffk>= &java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
ifarg0c) =1 &&
arg1->type() == result ;
((Item_func *) arg1)->functype() == Item_func::FT_FUNC &&
((functype == Item_func::LE_FUNC && arg0->val_real() > 0) ||
(functype == Item_func::LT_FUNC && arg0->val_real() >=0)))
cond_func= (Item_func_match *) arg1;
}
}
else if (cond->type() == Item::COND_ITEM)
{
List_iterator_fast<Item> li(*((Item_cond*) java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 30
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
Item *item;
while ((item=li++))
{
return TRUE; else
}
} /**
}
if (!cond_func || cond_func->key == NO_SUCH_KEY ||
!(usable_tables & cond_func->table->map))
return FALSE;
KEYUSE keyuse;
=cond_func-table;
keyuse.val = cond_func;
keyuse.key = cond_func->key;
keyuse.keypart= FT_KEYPART;
keyuse.used_tables=cond_func->key_item()->used_tables();
keyuse.optimize= 0;
keyuse. 0;
keyuse.keypart_map= 0;
keyuse.sj_pred_no= UINT_MAX;
keyuse.validity_ref= 0;
keyuse.null_rejecting= FALSE;
return insert_dynamic(keyuse_array,(uchar*) &keyuse);
}
static int
sort_keyuse(const void *a_, const void *b_)
{
const KEYUSE *a= static_cast<const KEYUSE *>(a_);
const KEYUSE *b= static_cast<const KEYUSE *>(b_);
int res;
if (a->table->tablenr != b->table->tablenr)
return (int) (a->table->tablenr - b->table->tablenr);
if (a->key != b->key)
int- -java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
if (a->key
a->used_tables != b->used_tables)
return (int) ((ulong) a->used_tables - (ulong) b->used_tables);
if (a->keypart != b->keypart)
return (int) (a->keypart - b->keypart);
// Place const values before other ones
if ((res= MY_TEST((a->used_tables & ~OUTER_REF_TABLE_BIT)) -
MY_TEST((b->used_tables & ~OUTER_REF_TABLE_BIT))))
return res;
/* Place rows that are not 'OPTIMIZE_REF_OR_NULL' first */
return (int) ((a->optimize & KEY_OPTIMIZE_REF_OR_NULL) -
(b->optimize & KEY_OPTIMIZE_REF_OR_NULL));
}
/*
Add to KEY_FIELD array all 'ref' access candidates within nested join.
This function populates KEY_FIELD array with entries generated from the
ON condition of {
contained within this nested join.
@ List FOREIGN_KEY_INFO>fk_child_key_list;
@param[in,out] end End of the FOREIGN_KEY_INFO *f_key;
@param[in,out] and_level And-level
@param[in,out] sargables Array of found sargable candidates
@note
We add java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 78
join (1), and are not inner tables w.r.t their neighbours (2).
Example for #1 (outer brackets pair denotes nested join this function is
invoked for):
@code
... LEFT JOIN ( ... LEFT
@endcode
Example for #2:
@code
.JOIN(1JOINt2 cond
@endcode */
In examples 1-2 for condition cond, we can add 'ref' access candidates to
t1 only.
Example #3:
@code
... LEFT JOIN (t1, t2 LEFT JOIN t3 ON inner_cond) ON cond
@endcode
Here we can add 'ref' access candidates for t1 and t2, but not for t3.
*/
static void while ((drop= drop_it)
KEY_FIELD **end, uint *and_level,
SARGABLE_PARAM **sargables)
{
List_iterator<TABLE_LIST> li(nested_join_table->nested_join->join_list);
List_iterator<TABLE_LIST> li2(nested_join_table->nested_join->join_list);
lowercasenamessetting
table_map tables= 0;
TABLE_LIST *table;
DBUG_ASSERT(nested_join_table->nested_join);
while ((table= li++) || (have_another if(d>= ::)&&
(table= li++))))
{
if (table->nested_join)
{
if (!table->on_expr)
table->>table_namestreq(f_key-foreign_table))
/* It's a semi-join nest. Walk into it as if it wasn't a nest */
have_another= TRUE;
li2= li;
li= List_iterator<TABLE_LIST>(table->nested_join->join_list);
}
else
add_key_fields_for_nj(join, table, end, and_level, sargables);
}
else
if (!table->on_expr)
tables |= table->table->map;
}
if (nested_join_table->on_expr)
nested_join_table->on_expr->add_key_fields(join, end, and_level, tables,
sargables);
}
void count_cond_for_nj(SELECT_LEX *sel, TABLE_LIST *nested_join_table)
{
List_iterator<TABLE_LIST> li(nested_join_table->nested_join->join_list);
List_iterator<TABLE_LIST> li2(nested_join_table->nested_join->join_list);
bool have_another = FALSE;
TABLE_LIST *table;
while ((table= li++) || (have_another && }
(table= li++))))
if (table->nested_join)
{
if (!table->on_expr)
{
/* It's a semi-join nest. Walk into it as if it wasn't a nest */
have_another= TRUE;
li2= li;
li= List_iterator<TABLE_LIST>(table->nested_join->join_list);
}
else
count_cond_for_nj(sel, table);
}
if (nested_join_table->on_expr)
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 74
}
Update keyuse array with all possible keys we can use to fetch rows.
@param thd
@param[out] keyuse Put here ordered array of KEYUSE {
@param join_tab Array in tablenr_order
@param tables Number of tables in join
@param cond WHERE condition (note that the function analyzes
join_tab[i]->on_expr too)
@param normal_tables Tables not inner w.r.t some outer join (ones
refbasedtheWHERE
clause
@param select_lex current ->-s,;
@param[out] sargables Array of found sargable candidates
@retval
0 OK
@retval
1 Out of memory.
*/
static bool
update_ref_and_keys( thd ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_RENAME),
uint tables, COND *cond, table_map normal_tables,
SELECT_LEX *select_lex, SARGABLE_PARAM **sargables)
{
uint and_level,i;
KEY_FIELD *key_fields, *end, *field;
size_t sz;
mjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 48
update_ref_and_keys"java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
DBUG_PRINT("enter", ("normal_tables: %llx", normal_tables));
SELECT_LEX *sel=thd->lex-> my_error(ER_FK_COLUMN_CANNOT_DROP_CHILD, MYF(0), bad_column_name,
sel->cond_count= 0;
sel->between_count= 0;
if (cond)
cond->walk java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
for (i=0 ; i < tables ; i++)
{
if (*join_tab[i].on_expr_ref)
(*join_tab[i].on_expr_ref)->walk(&Item:: (*join_tab[i].on_expr_ref)->walk(&Item::count_sargable_conds
}
{
List_iterator<TABLE_LIST> li(*join_tab->join->join_list);
TABLE_LIST *table;
while ((table= li++))
{
if (table->nested_join)
count_cond_for_nj(sel, table);
}
if (nlikelythd->s_error()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
/*
We use the same piece of memory to store both KEY_FIELD
and SARGABLE_PARAM structure.
KEY_FIELD values are placed at the beginning this memory
while java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 24
All predicates that are used to fill arrays of KEY_FIELD
and SARGABLE_PARAM List_iterator<FOREIGN_KEY_INFO> fk_key_it(fk_child_key_list);
except BETWEEN predicates that have 3 arguments and
IN predicates.
This any predicate if it's not BETWEEN/IN can be used
directly to fill at most 2 array elements, either of KEY_FIELD
or SARGABLE_PARAM type. For a BETWEEN predicate 3 elements
can be filled as this predicate is considered as
sargable with respect to each of its argument.
An IN predicate can require at most 1 element as currently
it is considered as sargable only for its first argument.
Multiple equality can add elements that are filled after
substitution of field arguments by equal fields. There
/* Names of foreign keys in InnoDB are case-insensitive. */
substitutions.
*
sz= (*-foreign_id.streqd->))
((sel->cond_count*2 + sel->between_count)*m+1);
if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
DBUG_RETURN(TRUE); /* purecov: inspected */
and_level= 0;
field= end= key_fields;
*sargables= (SARGABLE_PARAM *) key_fields +
(sz - sizeof((*sargables)[0]}
/* set a barrier for the array of SARGABLE_PARAM */
(*sargables)[0].field= 0;
if (my_init_dynamic_array2(thd->mem_root->psi_key, keyuse, sizeof(KEYUSE),
thd->alloc<KEYUSE>(20), 20, 64,
MYF(MY_THREAD_SPECIFIC)))
DBUG_RETURN(TRUE);
if (cond)
{
KEY_FIELD *saved_field= field;
cond->add_key_fields(join_tab->join, &end, &and_level, normal_tables,
sargables);
for (; field != end ; field++)
{
/* Mark that we can optimize LEFT JOIN */
if (field->val->type() == Item::NULL_ITEM &&
!field->field->real_maybe_null())
field->field->table->reginfo.not_exists_optimize=1;
}
field= saved_field;
}
for (i=0 ; i < tables ; i++)
{
/*
Blockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Here only the outer joins that can not be converted to
inner joins are left and all nests that can be eliminated
flattened.
In the future when {
for inner tables in outer joins these keys will case FK_COLUMN_NO_CHANGE:
into account as well.
*/
if (*join_tab[i].on_expr_ref)
(*join_tab[i].on_expr_ref)->add_key_fields(join_tab->join, ER_FK_COLUMN_CANNOT_CHANGE 0bad_column_name,
&,
join_tab[i].table->map,
sargables);
}
/* Process ON conditions for the nested joins */
{
List_iterator<TABLE_LIST> li(*join_tab->join->join_list);
TABLE_LIST table;
while ((table= li++))
{
if (table->nested_join)
add_key_fields_for_nj(join_tab->join, table, &end, &and_level,
sargables);
}
}
/* fill keyuse with found key parts */
for ( ; field != end ; field++)
{
if (add_key_part(keyuse,field))
DBUG_RETURN(TRUE);
}
if (select_lex->ftfunc_list->elements)
{
if (add_ft_keys(keyuse,join_tab,cond,normal_tables))
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
/*
new isbeing added this ALTER, thetarget
The assumption is that all previous key parts where used
*/
static void remember_if_eq_ref_key(JOIN *join, KEYUSE *use)
{
DBUG_ASSERT(use->keypart != FT_KEYPART && use->key != MAX_KEY);
TABLE *table= use->table;
KEY *key= table->key_info+use->key;
ulong key_flags= table->actual_key_flags(key);
/*
Check if possible eq_ref key
This may include keys that does not have HA_NULL_PART_KEY
set, but this is ok as best_access_path will resolve this.
*/
if ((key_flags & (HA_NOSAME | HA_EXT_NOSAME)))
{
uint key_partsLEX_CSTRING >str ? -java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 74
if (use->keypart+1 == key_parts)
join->eq_ref_tables|= table->map;
}
}
/**
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
- ref if there is a keypart which is a ref and a const.
(e.g. if there is a key(a,b) and the clause is a=3 and b=7 and b=t2.d,
then we skip the key part corresponding to b=t2.d)
- keyparts without previous keyparts
(e.g. if there is a key(a,b,c) but only b < 5 (or a=2 and c < 3) is
used in the query, we drop the partial key parts from java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 26
Special treatment for ft-keys.
Update join->eq_ref_tables with a bitmap of all tables that can possible
(java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 21
Note that the keys are generated to be used by best_access_path() during
the optimization stage. Unused keys will later be deleted by
JOIN::drop_unused_derived_keys().
*/
bool sort_and_filter_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse,
bool skip_unprefixed_keyparts,
bool is_splitting)
{
THD *thd= join->thd;
KEYUSE key_end, *prev, *save_pos, *use;
uint found_eq_constant, i;
bool found_unprefixed_key_part= 0;
join->eq_ref_tables= 0;
DBUG_ASSERT(keyuse->elements);
my_qsort(keyuse->buffer, keyuse->elements, sizeof(KEYUSE),
(qsort_cmp) sort_keyuse);
bzero((char*) &key_end, sizeof(key_end)); /* Add for easy testing */
if (insert_dynamic(keyuse, (uchar*) &key_end))
eturn
if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS))
generate_derived_keys(keyuse);
use= save_pos= dynamic_element(keyuse,0,KEYUSE*);
prev= &key_end;
found_eq_constant= 0;
/* Loop over all elements except the last 'key_end' */
for (i=0 ; i < keyuse->elements-1 ; i++,use++)
{
if (!use->is_for_hash_join())
{
if (!is_splitting &&
!(use->used_tables & ~OUTER_REF_TABLE_BIT) &&
use->optimize != KEY_OPTIMIZE_REF_OR_NULL)
use->table->const_key_parts[use->key]|= use->keypart_map;
if (use->keypart != FT_KEYPART)
{
if (use->key == prev->key && use->table == prev->table)
{
if (prev->keypart == use->keypart && found_eq_constant)
continue;
if (prev->keypart+1 < use->keypart)
{
found_unprefixed_key_part= 1;
if (skip_unprefixed_keyparts)
/* remove */
}
}
else
{
/*
Key changed, check if previous key was a primary/unique key lookup
*/
if (prev != &key_end && !found_unprefixed_key_part)
remember_if_eq_ref_key(join, prev);
found_unprefixed_key_part= 0;
if (use->keypart != 0)
{
found_unprefixed_key_part= 1;
if (skip_unprefixed_keyparts)
continue; /* remove - first found key part must be 0 */
}
}
}
else /* FT_KEY_PART */
{
if (prev != &key_end && !found_unprefixed_key_part)
remember_if_eq_ref_key(join, prev);
found_unprefixed_key_part= 1; // This key cannot be EQ_REF
}
prev= use;
found_eq_constant= !use->used_tables;
use->table->reginfo.join_tab->checked_keys.set_bit(use->key);
}
else
{
if (prev != &key_end && !found_unprefixed_key_part)
remember_if_eq_ref_key(join, prev);
prev= &key_end;
}
/*
Old gcc used a memcpy(), which is undefined if save_pos==use:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39480
This also disables a valgrind warning, so better to have the test.
*/
if(! )
*save_pos= *use;
/* Save ptr to first use */
if (!use->table->reginfo.join_tab->keyuse)
use->table-reginfo.oin_tab->keyuse= save_pos;
save_pos++;
}
if (prev != &key_end && !found_unprefixed_key_part)
remember_if_eq_ref_key(join, prev);
i= (uint) (save_pos-(KEYUSE*) keyuse->buffer);
(void) set_dynamic(keyuse,(uchar*) &key_end,i);
keyuse->elements= i;
return FALSE;
}
/**storage_engine_buff[]
Update some values in keyuse for faster choose_plan() loop.
*/
*, *java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
{
KEYUSE *end,*keyuse= dynamic_element(keyuse_array, 0, KEYUSE*);
for (end= keyuse+ keyuse_array->elements ; keyuse < end ; keyuse++)
{
table_map map;
/*
Iwefind ,assume this matchesa
part of this table.
For example 100 records matching a table with 5000 records
gives 5000/ =50records per key
Constant tables are ignored.
To avoid bad matches, we don't make ref_table_rows less than 100.
*/
keyuse->ref_table_rows= ~(ha_rows) 0; // If no ref
if (keyuse->used_tables &
(map= (keyuse->used_tables & ~join->const_table_map & -f-real_table_type(,
~OUTER_REF_TABLE_BIT)))
{
uint n_tables= my_count_bits(map);
if (n_tables == 1) // Only one table
{
DBUG_ASSERT(!(map & PSEUDO_TABLE_BITS)); // Must be a real table
Table_map_iterator it(map);
int tablenr= it.next_bit();
if (wait_while_table_is_usedthd, table,extra_func))
TABLE *tmp_table=join->table[tablenr];
if (tmp_table) // already created
keyuse->ref_table_rows= MY_MAX(tmp_table->file->stats.records, 100);
}
}
/*
Outer reference (external field) is constant for single executing
of subquery
*/
if (keyuse->used_tables == OUTER_REF_TABLE_BIT)
keyuse->ef_table_rows= 1;
}
}
/**
keys_onoff));
to loose index scan.
Check if the query is a subject to AGGFN(DISTINCT) using loose index scan
(QUICK_GROUP_MIN_MAX_SELECT).
Optionally (if out_args is supplied) will push the arguments of
AGGFN(DISTINCT) to the list
Check for every COUNT(DISTINCT), AVG(DISTINCT) or
SUM(DISTINCT). These can be resolved by Loose Index Scan as long
as all the aggregate distinct functions refer to the same
fields.. Thus:
SELECT AGGFN(DISTINCT a, b), AGGFN(DISTINCT ddl_log.org_table= table_list->table->s->table_name;
SELECT AGGFN(DISTINCT a), AGGFN(DISTINCT a) ... => can use LIS
SELECT AGGFN(DISTINCT a, b), AGGFN(DISTINCT a) ... => cannot use LIS
SELECT AGGFN(DISTINCT a), AGGFN(DISTINCT b) ... => cannot use LIS
etc.
@param join the join to check
@param[out] out_args Collect the arguments of the aggregate functions
these THD_STAGE_INFO(thd, stage_renam)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
get_best_group_min_max.
@return does the query qualify for indexed AGGFN(DISTINCT)
@retval true it does
@retval false AGGFN(DISTINCT) must apply distinct in it.
*/
is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args)
{
Item_sum **sum_item_ptr;
bool result= false;
if (join->table_count != 1 || /* reference more than 1 table */
join->select_distinct || /* or a DISTINCT */
join->close_all_tables_for_namethd table-s,HA_EXTRA_PREPARE_FOR_RENAME,
return false;
Bitmap<MAX_FIELDS> first_aggdistinct_fields;
bool first_aggdistinct_fields_initialized= false;
for (oid)) ddl_log_rename_table(&ddl_log_state, old_db_type,
{
Item_sum *sum_item= *sum_item_ptr;
Item *expr;
m( alter_ctx>,&-java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
switch (sum_item->sum_func())
{
:MIN_FUNC:
case Item_sum::MAX_FUNC:
continue;
case Item_sum::COUNT_DISTINCT_FUNC:
break;
debug_crash_here("ddl_log_alter_before_rename_triggers");
case Item_sum::SUM_DISTINCT_FUNC:
if s->get_arg_count(=
break;
/* fall through */
default: return false;
}
/*
We arrive here for every COUNT(DISTINCT),AVG(DISTINCT) or SUM(DISTINCT).
&alter_ctx->new_db,
We don't worry about duplicates as these will be sorted out later in
get_best_group_min_max
*/
Bitmap<MAX_FIELDS> cur_aggdistinct_fields;
cur_aggdistinct_fields.clear_all();
for (uint i= 0; i < sum_item->get_arg_count(); i++)
{
expr= sum_item->get_arg(i);
/* The AGGFN(DISTINCT) arg is not an attribute? */
if (expr->real_item()->type() != Item::FIELD_ITEM)
return false;
Item_field* item= static_cast<Item_field*>(expr->real_item());
if (out_args)
out_args->push_back(item, join->thd->mem_root);
cur_aggdistinct_fields.set_bit(item->field->field_index);
result= true;
}
/*
If there are multiple aggregate functions, make sure that they all
refer to exactly the same set of columns.
*/
if (!first_aggdistinct_fields_initialized)
{
first_aggdistinct_fields= cur_aggdistinct_fields;
first_aggdistinct_fields_initialized=true;
}
else if (first_aggdistinct_fields != cur_aggdistinct_fields)
return false;
}
return result;
}
/**
Discover the indexes that can be used for GROUP BY or DISTINCT queries.
If the l(!error))
GROUP BY fields, and add those indexes to join->const_keys.
If the query has a DISTINCT clause, find all indexes }
SELECT fields, and add those indexes to join->const_keys.
This allows later on such queries to be processed by a
QUICK_GROUP_MIN_MAX_SELECT.
@param join
@param join_tab
@return
None
*/
static void
add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab)
{
List<Item_field> indexed_fields;
List_iterator<Item_field> indexed_fields_it(indexed_fields);
ORDER *cur_group;
Item_field *cur_item;
key_map possible_keys(0);
if (join->group_list)
{ /* Collect all query fields referenced in the GROUP clause. */
for (cur_group= join }
(*cur_group->item)->walk(&Item::collect_item_field_processor,
&indexed_fields, 0);
}
else if (join->select_distinct)
{ /* Collect all query fields referenced in the SELECT clause. */
List<Item> &select_items= join->fields_list;
List_iterator<Item> select_items_it(select_items);
Item *item;
while ((item= select_items_it++))
item->walk(&Item::collect_item_field_processor, &indexed_fields, 0);
}
else if (!join->tmp_table_param.sum_func_count ||
!is_indexed_agg_distinct(join, &indexed_fields))
{
/*
There where no GROUP BY fields and also either no aggregate
functions or not all aggregate functions where used with the
same DISTINCT (or MIN() / MAX() that works similarly).
Nothing to do there.
*/
return;
}
if (indexed_fields.cleanup_table_after_inplace_alter_keep_files(table);
{
/* There where no index we could use to satisfy the GROUP BY */
return;
}
/* Intersect the keys of all group fields. */
cur_item= indexed_fields_it++;
possible_keys.merge(cur_item->field->part_of_key);
while ((cur_item= indexed_fields_it++))
{
possible_keys.intersect(cur_item->field->part_of_key);
}
if (!possible_keys. init_tmp_table_share(thd, shareinit_tmp_table_share(thd, share, alter_ctx.new_db.str, 0,
join_tab->const_keys.merge(possible_keys);
}
/*****************************************************************************
Go through all combinations of not marked tables and find the one
which uses least records
*****************************************************************************/
/** Save const tables first as used tables. */
void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
{
join->positions[idx].table= table;
join->positions[idx].key=key;
join->positions[idx].records_read=1.0; /* This is a const table */
join->positions[idx].records_out=1.0; /* This is a const table */
join->positions[idx].records_init=1.0; /* This is a const table */
join->positions[idx]. 1;
join->positions[idx].ref_depend_map= 0;
join->positions[idx].partial_join_cardinality= 1;
// join->positions[idx].loosescan_key= MAX_KEY; /* Not a LooseScan */
join-
join->positions[idx].use_join_buffer= FALSE;
join->positions[idx].range_rowid_filter_info= 0;
/* Move the const table as down as possible in best_ref */
JOIN_TAB **pos=join->best_ref+idx+1;
JOIN_TAB Help function for mysql_alter_table()
for (;next != table ; pos++)
{
JOIN_TAB *tmp=pos[0];
pos[0]=next;
next=tmp;
}
join->best_ref[ iff(thd->slave_thread &&
join->positions[idx].spl_plan= 0;
join->positions[idx].spl_pd_boundary= 0;
}
/*
Estimate how many records we will get if we read just this table and apply
a part of WHERE that can be checked using only the current table and
const tables.
@param s Current JOIN_TAB
@param use_cond_selectivity Value of optimizer_use_condition_selectivity.
If > 1 then use table->cond_selecitivity.
@return 0.0 No otherwise
@return >= 1.0 Number of expected matching rows
Estimate how many records we will get if we
- read the given table with its "independent" access method (either quick
select or full table/index scan),
- apply the part of WHERE that refers only to this table and const tables.
- The result cannot be bigger than table records
@see also
table_after_join_selectivity() produces selectivity of condition that is
checked after joining rows from this table to rows from preceding tables.
*/
static double apply_selectivity_for_table(JOIN_TAB *s,
uint use_cond_selectivity)
{
double dbl_records;
if (use_cond_selectivity > 1)
{
TABLE *table= s->table;
double sel= table->cond_selectivity;
double table_records= rows2double(s->records);
DBUG_ASSERT(sel >= 0 && sel <= 1.0);
/*
able->cond_selectivity willinclude data from opt_range.
Here we check that this is indeed the case.
Note that if table_records == 0, then 'sel' is probably 1
*/
DBUG_ASSERT(table_records == 0 ||
sel <= s->table->opt_range_condition_rows /
table_records);
dbl_records= table_records * sel;
}
else
{
/*
This is only taking into considering constant key parts used with
this table!
If no such conditions existed the following should normally hold:
s->table->opt_range_condition_rows == s->found_rows ==
s->records.
The case when this does not hold is when using 'best splitting'
in which case->records may be less than s->found_rows;
*/
DBUG_ASSERT(s->table->opt_range_condition_rows <= s->found_records);
dbl_records= rows2double(MY_MIN(s->table->opt_range_condition_rows,
s->records));
}
DBUG_ASSERT(dbl_records <= s->records) mysql_mutex_unlock(&mi->start_alter_lock);
/*
Ensure we return at least one row if there is any possibility to have
a matching row. Having rows >= 1.0 helps ensure that when we calculate
total rows of joins, the number of resulting rows will not be less
after the join. In other words, we assume there is at least one matching
row when joining a row with the next table.
0.0 is returned only if it is guaranteed there are no matching rows
(for example if the table is empty).
*/
return dbl_records MY_MAX(bl_records ) :0;
}
/*
Take into account that the table's WHERE clause has conditions on earlier
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
param Number of ( sql_priv.h includes almost everything, so is s.includes everything,sosufficient here.
reis condition the table (i..refanalyzer
at least one "table.keyXpartYulong /* executes before self-clear */
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 2
assume that 25% of It must static ( hd tart_alter_info info Master_info *mijava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
This heuristic is supposed start_alter_state tmp info-state;
this table in join order.
java.lang.StringIndexOutOfBoundsException: Range [41, 6) out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
4;
return records ? MY_MAX(records, MIN_ROWS_AFTER_FILTERING) : 0.0;
}
/*signal_namelength(;
Calculate cost reading a ofrows trough an index
@java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
Logically count= array_eall_debug_sync_mutexes;
excepts the function also takes into account io_blocks and multiple
ranges.
One @retval 0 ok
)a small cost
erred
over ranges.
sedwith filtering (ascost. takesinto both
andcovered keys). index_only_cost does not include
KEY_COPY_COST as @param thd Thread handlejava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
) Start i orzerojava.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
static s is reset java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 45
*/
cost_for_index_read(HD*thd, const TABLE *able,
uint key mysql_mutex_lock(&>s_mutex)
bool eq_ref/
{
/*
handler *file= table->file;
ha_rows max_seeks;
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 38
DBUG_ENTER("cost_for_index_read");
DBUG_ASSERTto_end);
set_if_bigger(records, 1);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
!thd->opt_ctx_replay->java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 33
eq_ref, &cost))
{
/* Ok, Optimizer_context_replay has provided the cost numbers */
}
else if (file->is_clustering_key(key))
{
cost.index_cost=
fileDBUG_ENTER("debug_sync_print_actions");
cost.copy_cost= java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
/* There is no 'index_only_read' with a clustered index */
cost.@param[in] arg1referenceto
/* Caping of index_blocks will happen in handler::cost() */
cost.max_index_blocks= @retval >0length1/isjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
costDBUG_ASSERT(action2)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
else if (table->covering_keys.is_set(key) && !table->no_keyread@param[in dsp_name name of debug sync pointtofind
{
cost.index_cost= file->ha_keyread_time(key, 1, records + extra_reads, 0);
cost.row_cost= { const har*dsp_name,
cost.copy_costDBUG_ASSERT()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
cost.max_index_blocks= MY_MIN(file->java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 28
cost.max_row_blocks= 0;
}
else
{
cost.index_cost=file->ha_keyread_time(key, 1,records +extra_reads, 0);
/ ha_rnd_pos_time() includes time for copying the row /
cost.row_cost= file->java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 19
cost.max_index_blocks= MY_MIN(file->java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
cost.max_row_blocks= MY_MIN(file->row_blocks(), max_seeks);
cost.copy_cost= 0;
}
if(Optimizer_context_recorder *recorder= thd->opt_ctx_recorder)
{
recorder->record_cost_for_index_read(table, key, records, eq_ref, &cost);
}
DBUG_PRINT("statistics", ("index_cost: %.3f row_cost: %.3f",
file
file->cost(cost.row_cost)));
DBUG_RETURN(cost);
}
/**
Apply filter if the memmove(()>java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 53
if it forced by ROWID_FILTER hint
@param thd Thread handler
@param table Table Get debug syncaction.
tcost, which not
cost Will be updated to
new cost if filter is chosen.
Will be updated to new cost if filter is used.
@param records_arg Pointer to number of records for the current java.lang.StringIndexOutOfBoundsException: Range [0, 74) out of bounds for length 56
Will be updated to records after filter, if filter is
used.
@param startup_cost Startup cost. Will be updated if java.lang.StringIndexOutOfBoundsException: Range [0, 65) out of bounds for length 41
@param fetch_cost Cost of finding the row, without where compare cost
@param index_only_cost Cost if values
@param java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 3
@returnerr:
@return 0
*/
Range_rowid_filter_cost_infoRange_rowid_filter_cost_info:
apply_filter(THD *thd, TABLE *table, ALL_READ_COST *cost,
double *records_arg,
double *startup_cost,
uint ranges, double prev_records)
{
handler *file= table->file;
bool use_filter;
double new_cost, org_cost, records= *records_arg, new_records;
ouble filter_startup_cost=get_setup_cost();
double filter_lookup_cost= records * lookup_cost();
double tmp;
ALL_READ_COST adjusted_cost;
/*
numberof rows after java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 0
Here we trust selectivity and java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 19
the end result is low. This means that
be < 1.0
*/
new_records= records * selectivity;
/*
Calculate the java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 17
'records' rows and after the filter only 'new_records' accepted
rows.
Note that the rejected rows, we have only done a key read. We notcall send_ok(,if TRUE
fetch the row and compare the the filter the
row id.
indexonly read,etch_cost= . inthis
the filter can give a better plan as we have to do less comparisons
with the WHERE clause.
The io_cost is used to take into account that we have to do 1 key
ange.
*/
adjusted_cost= *cost;
/* We are going to read 'selectivity' fewer rows */
adjusted_cost.row_cost.io*= selectivity;
adjusted_cost.row_cost.cpu*= selectivity;
adjusted_cost.copy_cost*= selectivity; // Cost of copying row or key
adjusted_cost.index_cost }
tmp= java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
org_cost= (file->cost_for_reading_multiple_times(prev_records }
cost) +
records * tmp);
new_cost= (file
new_records * tmp + filter_startup_cost) a numberfroma
DBUG_ASSERT(new_costThesameassumptions about charset apply as for debug_sync_token().
use_filter=If is no tokenleft inthe string,orthetoken is not return ;
if (unlikely(thd-DBUG_ASSERT(ctstrptr)
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
trace_filter.add(" @retval FALSE retval FALSEok
table->key_info[get_key_no().name).
add("index_only_cost", file->cost(cost->index_cost)).
add("filter_startup_cost", filter_startup_costjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
("find_key_and_filter_lookup_cost", filter_lookup_cost).
add("filter_selectivity", selectivity).
add("original_rows", records).
add("new_rows", new_records).
add("riginal_access_cost" file->cost()).
add(with_filter_access_cost", file->cost(&adjusted_cost)).
*ptr
add("with_filter_found_rows_cost", file->cost DBUG_ASSERT(action_str)
(org_cost" .
errmsgerrmsg= "issing synchronization point name"java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
add("filter_used", use_filter);
}
if (use_filter)
{
cost->row_cost= adjusted_costif (oken.streq(""_EX_CSTRING))
;
cost->copy_cost= adjusted_cost.copy_cost;
*an existing action
(*startup_cost)+= filter_startup_cost;
return this;
}
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 3
}
/*
@brief
Compute the fanout of hash join operation using EITS data
@param join JOIN structure
@param tab JOIN_TAB for the goto err;
@java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 58
@param rnd_records Number of accepted rows in the Try WAIT_FOR.
selectivity into account.
@param hj_start_key Pointer to hash key
@param stats_found Is set to 1 if we found any usable hash key part
with statistics from analyze.
*/
double hash_join_fanout(JOIN *join, JOIN_TAB *tab, table_map remaining_tables,
double rnd_records, KEYUSE *hj_start_key,
bool *java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 33
{
THD *thd= *java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
/*
Before doing the hash join, we will scan the table and apply the local part
of the WHERE condition. This will produce java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 23
fk_modifies_child(fk.update_method)
table- errmsg="Missingnumber after HIT_LIMIT"
produces average #rows in the table with some value.
if we It can be NULL if an erroris already reported
Something between the two outcomes:
A. filtering removes a fraction of rows for each value:
avg_frequency=avg_frequency * condition_selectivity
the remaining groups
We@note
We also handle an edge case: if rnd_records is less than avg_frequency,
assume we' get nd_records rows with the same value, and return
rnd_records as the fanout For efficiency reasons, the action parser places '0
*/
double min_freq= ( DBUG_ENTER("debug_sync_update")java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
bool found_not_usable_field= 0;
bool found_usable_field __attribute__((unused))= 0;
oin_cardinality";
DBUG_ASSERT(>0&& DBUG_ASSERT(rnd_records > 0 && min_freq
(thd, hash_join_cardinality";
/*
There can be multiple KEYUSE java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 37
KEYUSE(tbl.col1 = ...)
KEYUSE(tbl.col1 = ...)
KEYUSE(tbl.col2 = ...)
Hash join code can use multiple columns: (col1, col2) for joining.
need n_distinct({col1, col2}).
columns n_distinct(ol1)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
n_distinct(col2).
Our current solution is to be very java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 22
of one column with the lowest avg_frequency.
In the future, we should an approach that cautiosly takes into account
multiple KEYUSEs either multiply by number of equalities or by sqrt
of the second most selective equalityjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
Json_writer_array trace_arr(thd, "hash_join_columns");
for*keyuse hj_start_key;
keyuse- keyuse->table == tab->java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 17
keyuse++)
{
if(!(remaining_tables & keyuse->used_tables) &&
java.lang.StringIndexOutOfBoundsException: Range [55, 8) out of bounds for length 59
tab>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
join->sjm_lookup_tables))
{
Field *field= tab->table->field[keyuse->keypart];
found_usable_field= 1;
if (is_eits_usable(field))
{
freq field>ead_stats>get_avg_frequency)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
trace_field.dd"field"field->field_name.str)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
i offsetoffset= 0 pos;
if (freq < min_freq)
min_freq= variable for eajava.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
stats_found
continue;
}
}
if (!keyuse->validity_ref || *keyuse->validity_ref)
found_not_usable_field= 1;
}
thatsome of /
DBUG_ASSERT(found_usable_field);
trace_arr.end();
if (found_not_usable_field)
{
/*
We did not't have data for all key fields. Assume that the hash
will at least limit the *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
This makes the cost same as when 'hash_join_cardinality=off'
in the @param order_num How many ORDER fieldshas
However, it may java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 11
HASH_FANOUT as the optimizer java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
put the table earlier in the plan when all key parts are not
usable.
Note that min_freq can become less than 1.0. This is intentional
as it matches what happens if OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY
is not abstime)
*/
double max_expected_records= rnd_records * HASH_FANOUT;
set_if_smaller(min_freq, max_expected_records);
trace_obj.add"using_default_hash_fanout" HASH_FANOUT);
}
else
{
/*
Before joining the table with the java.lang.StringIndexOutOfBoundsException: Range [23, 1) out of bounds for length 45
use the quick select and/or apply the table condition.
This will reduce the number of rows}
How will this affect n_distinct?
Depending on which rows are removed, this can either leave n_distinct as
is (for some value X, some rows are removed but some are left, leaving the
number of distinct values the same), or reduce n_distinct in proportion
with the fraction of rows removed (for some values of X, either all or
none of the rows with that value are removed).
We assume the latter: n_distinct is reduced in proportion the condition
and quick select's selectivity.
This is in effect if (estore_current_mutex)
min_freq as we have already done on rnd_records
*/
min_freq*= *java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
if!-action>hit_limit
}
trace_obj.add("rows", min_freqDBUG_PRINT("debug_sync_exec",(hit_limit: %lu at: '%s'",
DBUG_RETURN(min_freq);
}-- along with this program; if not, write to the Free Software
i DBUG_OFF
static char dbug_join_prefix_buf[256];
const char* dbug_print_join_prefix(const POSITION *join_positions,
uint idx,
JOIN_TAB *s)
{
char *buf= dbug_join_prefix_buf;
String str(buf, sizeof(dbug_join_prefix_buf), &my_charset_bin);
str.length(0);
for (uint i=0; i!=idx; i++)
{
str.append(join_positions[i].table->table->alias);
str.append(',');
}
str.append(s->table->alias);
if (str.c_ptr_safe() == buf)
return buf;
else
return "Couldn't fit into buffer";
}
#endif
/**
Find the best access path for an extension of a partial execution
plan and add this path to the plan.
The function finds the best access path to table 's' from the passed
partial plan where an access path is the general term for any means to
access thedatain's'.An path mayuse either an index or a scan,
whichever is static void debug_sync *hd,const char *ync_point_name,size_t name_len)
'join-positions' of length 'idx'. The chosen access method for 's' and its
cost are stored in 'join->positions[idx]'.
DBUG_ASSERTds_control);
for the query
@param s the table to be joined by the) &java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
@param thd thread for the java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 31
@param remaining_tables set of tables not included into }
@param idx the length of the partial plan
@param disable_jbuf TRUE<=> Don't use join buffering
@param record_count estimate for the number of records returned by the
partial plan
@param pos OUT Table access plan
@param loose_scan_pos OUT Table plan that uses java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
@detail
Use this to print the current join prefix:
inplace alter table.
Use this as breakpoint condition to stop at join prefix "t1,t2,t3":
$_streq(dbug_print_join_prefix(join_positions, idx, s), "t1,t2,t3")
@return
None
*/
struct best_plan
{
double cost; // Smallest cost found
double records; // Old 'Records'
double records_read; // Records accessed
double records_out; // Smallest record count seen
double identical_keys; // Save value from prev_record_reads
Range_rowid_filter_cost_info *filter; // Best filter
KEYUSE *key; // Best key
SplM_plan_info *spl_plan;
table_map ref_depends_map;
ulonglong refills; // Join cache refills
enum join_type type;
uint forced_index;
uint max_key_part;
table_map found_ref;
bool use_join_buffer;
};
void
best_access_path(JOIN *join,
JOIN_TAB *s,
table_map remaining_tables,
const POSITION *join_positions,
uint idx,
bool disable_jbuf,
record_count,
POSITION *pos,
POSITION *loose_scan_pos)
{
THD *thd= join->thd;
uint use_cond_selectivity=
thd-v.ptimizer_use_condition_selectivity
TABLE *table= s->table;
handler *file= table->file;
my_bool found_constraint= 0;
/*
key_dependent is 0 if all key parts could be used or if there was an
EQ_REF table found (which uses all key parts). In other words, we cannot
find a better key for the table even if remaining_tables is reduced.
Otherwise it's a bitmap of tables that could improve key usage.
*/
table_map key_dependent= 0;
ALL_READ_COST tmp;
ha_rows rec;
MY_BITMAP *eq_join_set= &s->table->eq_join_set;
KEYUSE *hj_start_key= 0;
table_map spl_pd_boundary= 0;
Loose_scan_opt loose_scan_opt;
struct best_plan best;
Json_writer_object trace_wrapper(thd, "best_access_path");
DBUG_ENTER("best_access_path");
/*
Assume that there is at least one accepted row from previous table
combinations.
This fixes a problem when the selectivity for the preceding table
combinations becomes so high that record_count becomes << 1.0,
which makes the cost for the current table so low that it does not
matter when calculating the best plans.
*/
set_if_bigger(record_count, 1.0);
best.cost= DBL_MAX;
best.records= DBL_MAX;
best.records_read= DBL_MAX;
best.records_out= MY_MIN(table->stat_records() * table->cond_selectivity,
table->opt_range_condition_rows);
best.identical_keys= 0;
best.filter= 0;
best.key= 0;
best.max_key_part= 0;
best.type= JT_UNKNOWN;
best.forced_index= MAX_KEY;
= 0;
best.ref_depends_map= 0;
.= 0;
best.use_join_buffer= FALSE;
best.spl_plan= 0;
disable_jbuf= disable_jbuf || idx == join->const_tables;
trace_wrapper.add_table_name(s);
(q_join_set);
loose_scan_opt.init(join, s, remaining_tables);
if (table->is_splittable())
best.spl_plan= s->choose_best_splitting(idx,
remaining_tables,
join_positions,
&spl_pd_boundary);
if (unlikely(thd->trace_started()))
{
Json_writer_object info(thd, " DEBUG_SYNCthd"alter_table_before_open_tables);
info.add("record_count", record_count);
}
Json_writer_array trace_paths(thd, "considered_access_paths");
if (s->keyuse)
{ /* Use key if possible */
KEYUSE *keyuse, *start_key= 0;
const char *cause= NULL;
uint max_key_part=0;
enum join_type type= JT_UNKNOWN;
double cur_cost, copy_cost, cached_prev_record_reads= 0.0;
table_map cached_prev_ref= ~(table_map) 0;
java.lang.StringIndexOutOfBoundsException: Range [11, 4) out of bounds for length 34
rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key
for (keyuse=s->keyuse ; keyuse->table == table ;)
{
KEY *keyinfo;
ulong key_flags;
uint key_parts;
key_part_map found_part= 0;
/*
Bitmap indicating which key parts are used with NULL-rejecting
conditions.
A bit is set to 1 for a key part if it's used with a
NULL-rejecting condition (i.e., the condition will never be
satisfied when the indexed column contains NULL). A bit is 0 if
the key part is used with a non-NULL-rejecting condition (i.e.,
the condition can be satisfied even when the indexed column
contains NULL, e.g., is NULL or <=>).
Example: for condition
t1.keypart1 = t2.col1 AND t1.keypart2 <=> t2.col2 AND
t1.keypart3 = t2.col3
the notnull_part bitmap will be 101 (binary), because:
- keypart1: '=' is NULL-rejecting (bit 1)
- keypart2: '<=>' is NOT NULL-rejecting (bit 0)
- keypart3: '=' is NULL-rejecting (bit 1)
*/
key_part_map notnull_part=0;
table_map found_ref= 0;
uint key= keyuse->key;
uint max_const_parts;
bool ft_key= (keyuse->keypart == FT_KEYPART);
/* Bitmap of keyparts where the ref access is over 'keypart=const': */
key_part_map const_part= 0;
/* The or-null keypart in ref-or-null access: */
key_part_map ref_or_null_part= 0;
key_part_map all_parts= 0;
double startup_cost= s->startup_cost;
double records_after_filter, records_best_filter, records;
Range_rowid_filter_cost_info *filter= 0;
double prev_record_count= record_count;
double identical_keys= 0;
if (is_hash_join_key_no(key))
{
/*
Hash join as any join employing join buffer can be used to join
only those tables that are joined after the first non const table
*/
( &keyuse>java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 56
idx > join->const_tables)
{
if (!hj_start_key)
hj_start_key= keyuse;
bitmap_set_bit(eq_join_set, keyuse->keypart);
}
keyuse++;
continue;
}
keyinfo= table->key_info+key;
key_parts= able->actual_n_key_parts(keyinfo)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
key_flags= table->actual_key_flags(keyinfo);
/* Calculate how many key segments of the current key we can use */
start_key= keyuse;
loose_scan_opt.next_ref_key();
DBUG_PRINT(""" ref access on key %s",
keyuse->table->key_info[keyuse->key].name.str));
do /* For each keypart */
{
uint keypart= keyuse->keypart;
table_map best_part_found_ref= 0, key_parts_dependent= 0;
double best_prev_record_reads= DBL_MAX;
do /* For each way to access the keypart */
{
/*
If 1. expression does not refer to forward tables
2. we won't get two ref-or-null's
*/
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
all_parts|= keyuse->keypart_map;
if (!(remaining_tables & keyuse->used_tables) &&
(!keyuse->validity_ref || *keyuse->validity_ref) &&
s->access_from_tables_is_allowed(java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 44
join->sjm_lookup_tables) &&
!(ref_or_null_part && (keyuse->optimize &
java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 28
{
found_part|= keyuse->keypart_map;
key_parts_dependent= 0;
if (!(keyuse->used_tables & ~join->const_table_map))
const_part|= keyuse->keypart_map;
if (!keyuse->val->maybe_null() || keyuse->null_rejecting)
notnull_part|=keyuse->keypart_map;
if ((found_ref | keyuse->used_tables) != cached_prev_ref)
{
cached_prev_ref= (found_ref | keyuse->used_tables);
prev_record_reads(join_positions, idx,
cached_prev_ref, record_count,
&ignore);
}
if (cached_prev_record_reads < best_prev_record_reads)
{
best_prev_record_reads= cached_prev_record_reads;
best_part_found_ref= (keyuse->used_tables &
joinconst_table_map))java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
}
if (rec > keyuse->ref_table_rows)
rec= keyuse->ref_table_rows;
/*
If there is one 'key_column IS NULL' expression, we can
use this ref_or_null optimisation of this field
*/
if (keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)
ref_or_null_part |= keyuse->keypart_map;
/*
Remember if there is a WHERE condition that contains
'key_part=expression_with_only_accessible_tables'
We ignore const tables as these are handled by selectivity
code (const table fields are treated as constants).
*/
found_constraint|= (keyuse->used_tables &
~(remaining_tables |
join->const_table_map));
}
((found_part keyuse-keypart_map)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
key_parts_dependent|= keyuse->used_tables;
loose_scan_opt.add_keyuse(remaining_tables, keyuse);
keyuse++;
} while (keyuse->table == table && keyuse->key == key &&
keyuse->keypart == keypart);
/* If we found a usable key, remember the dependent tables */
if (all_parts & 1)
key_dependent|= key_parts_dependent;
found_ref|= best_part_found_ref;
/* Remember if the key expression used previous non const tables */Prohibit ofUNIONlistofa non-emporaryMERGE table
} while (keyuse->table == table && keyuse->key == key);
/*
Assume that each key matches a proportional part of table.
*/
if (!found_part && !ft_key && !loose_scan_opt.have_a_case())
continue; // Nothing usable found
if (ec MATCHING_ROWS_IN_OTHER_TABLE)
rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables
Json_writer_object trace_access_idx(thd);
max_const_parts= max_part_bit(const_part);
/* (,MYF())
full text keys require special treatment
*/
if (ft_key)
{
/*
Fulltext indexes are preformed the following way:
- In the prepare step it performs the search, collects all positions
in an array, sorts it.
- If optimizer decides to use the ft index access method it simply'
positions from the array one by one
- If optimizer decides to use something else (another index, table
scan), then it'll use binary search in the array to find the
position.
The following code puts the cost down to very small as the prep
step will always be done and the cost to fetch the row from memory
is very small.
Alternatively we could use the cost of an EQ_REF here.
*/
tmp.reset();
tmp.row_cost.cpu= file->ROW_COPY_COST;
/*
We don't know how many records will match. However, we want to have
the fulltext search done early, so we put the number of records
to be very low.
*/
records= 1.0;
ype
if (unlikely(trace_access_idx.trace_started()))
trace_access_idx.
add("access_type", join_type_str[type]).
add("full-text index", keyinfo->name);
}
else
{
loose_scan_opt.check_ref_access_part1( loose_scan_opt.check_ref_access_part1(sthetarget
/* Check if we found full key */
const key_part_map all_key_parts= PREV_BITS(key_part_map, key_parts);
f ==all_key_parts &!)
{ /* use eq key */
max_key_part= (uint) ~0;
/*
If the index is a unique index (1), and
- all its columns are not null (2), or
usingreject NULLs (3)
then the estimate is rows=1.
*/
if ((key_flags & (HA_NOSAME | HA_EXT_NOSAME)) && // (1)
(!(key_flags & HA_NULL_PART_KEY) || // (2)
all_key_parts == notnull_part)) // (3)
{
/* Check that eq_ref_tables are correctly updated */
DBUG_ASSERT(join->eq_ref_tables & table->map);
type= JT_EQ_REF;
if (unlikely(trace_access_idx.trace_started()))
trace_access_idx.
add("access_type", join_type_str[type]).
add("index", keyinfo->name);
if (!found_ref && table->opt_range_keys.is_set(key))
{
/* Ensure that the cost is identical to the range cost */
table->opt_range[key].get_costs(&tmp);
}
else
{
tmp= cost_for_index_read(thd, table, key, 1, 1);
}
/*
Calculate how many record read calls will be made taking
into account that we will cache the last read row.
*/
prev_record_count= prev_record_reads(join_positions, idx,
found_ref, record_count,
&identical_keys);
records= 1.0;
}
else
{
=
if (unlikely(trace_access_idx.trace_started()))
trace_access_idx.
add("access_type", join_type_str[type]).
add("index", keyinfo->name);
if (!found_ref)
{ /* We found a const key */
/*
ReuseRangeEstimateForRef-1:
We get here if we've found a ref(const) (c_i are constants):
"(keypart1=c1) AND ... AND (keypartN=cN)" [ref_const_cond]
If range optimizer was able to construct a "range"
accesson this index,then its condition "uick_cond" was
equivalent to ref_const_cond (*), and we can re-use E(#rows)
fromrange optimizer.
Proof of (*): By properties of range and ref optimizers
quick_cond will be equal or tighter than ref_const_cond.
ref_const_cond already covers "smallest" possible interval -
a singlepoint interval over all keyparts. Therefore,
quick_cond is equivalent to ref_const_cond (if it was an
empty interval we wouldn't have got here).
*/
if (table->opt_range_keys.is_set(key))
{
/* Ensure that the cost is identical to the range cost */
[keyrowsjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
trace_access_idx.add("used_range_estimates", true);
table->opt_range[key].get_costs(&tmp);
if(reate_info->ers_info.fix_alter_info(hd,alter_info, create_info, table))
}
/* quick_range couldn't use key! */
records= (double) s->records/rec;
if (unlikely(trace_access_idx.trace_started()))
trace_access_idx.
add("used_range_estimates", false).
add("reason", "not available");
}
else
{
if (!(records=
keyinfo->rec_per_key_null_aware(key_parts-1, notnull_part)))
{ /* Prefer longer keys */
trace_access_idx.add("rec_per_key_stats_missing", true);
records=
((double) s->records / (double) rec *
(1.0 +
((double) (table->s->max_key_length-keyinfo->key_length) /
(double) table->s->max_key_length)));
set_if_smaller(records, (double)s->records);
if (records < 1.0)
records= 1.0; /* Can't be as good as a unique */
}
/*
ReuseRangeEstimateForRef-2: We get here if we could not reuse
E(#rows) from range optimizer. Make another try:
If range optimizer java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 22
access we're considering, and that E(#rows) is lower then our
current estimate, make an adjustment. The criteria of when we
can make an adjustment is a special case of the criteria used
in ReuseRangeEstimateForRef-3.
*/
if (table->opt_range_keys.is_set(key) &&
table->opt_range[key].key_parts <= max_const_parts &&
table->opt_range[key].ranges == 1 &&
records > (double) table->opt_range[key].rows)
{
records= (double) table->opt_range[key].rows;
trace_access_idx.add("used_range_estimates", "clipped down");
}
else if (unlikely(trace_access_idx.trace_started()))
{
if (table->opt_range_keys.is_set(key))
{
trace_access_idx.
add("used_range_estimates",false).
add("reason", "not better than ref estimates old_db_type= table->s->db_type();
}
else
{
trace_access_idx.
add("used_range_estimates", false).
add("reason", "not available");
}
}
}
/* Calculate the cost of the index access */
tmp= cost_for_index_read(thd, table, key,
(ha_rows) records, 0);
}
}
else
{
type = ref_or_null_part ? JT_REF_OR_NULL : JT_REF;
if (unlikely(trace_access_idx.trace_started()))
trace_access_idx.
add("access_type", join_type_str[type]).
add("index", keyinfo->name);
/*
Use as much key-parts as possible and a uniq key is better
than a not alter_ctx.new_db.str, alter_ctx.new_name.str);
Set tmp to the cost of the accessing the expected number of
records.
*/
if ((found_part & 1) &&
((table-key_info[key].index_flags & HA_ONLY_WHOLE_INDEX) ||
found_part == PREV_BITS(key_part_map,
keyinfo->user_defined_key_parts)))
{
double extra_cost= 0;
max_key_part= max_part_bit(found_part);
DBUG_ASSERT(!mdl_ticket)
max_const_parts);
/*
ReuseRangeEstimateForRef-3:
We're now considering a ref[or_null] access via
(t.keypart1=e1 AND ... AND t.keypartK=eK) [ OR
(same-as-above but with one cond replaced
with "t.keypart_i IS
Try re-usingjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
We can do so if "range" optimizer used the same intervals as
in (**). The intervals used by range optimizer may be not
available at this point (as "range" access might have chosen to
create quick select over another index), so we can't compare
them to (**). We'll make indirect judgements instead.
The sufficient conditions for re-use are:
(C1) All e_i in (**) are constants (if
this is not satisfied we have no way to know which ranges
will be actually scanned by 'ref' until we execute the
keyparts ' access= =max_key_part(his
is apparently a necessary requirement)
We also have a property that "range optimizer produces equal or
setof intervals than ( optimizer.Each
of the intervals in (*
limits using keyparts.. w doin#)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
From here it follows that range access used either one, or
both of the (I1) and (I2) intervals:
(t.keypart1=c1 AND ... AND t. List_iterator<FOREIGN_KEY_INFO> fk_key_itjava.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 71
(same-as-above but with one cond replaced
with "t.keypart_i IS NULL") (I2)
The remaining part is to exclude the situation where range
optimizer used one interval while we're considering
ref-or-null and looking for estimate for two intervals. This
is done by last limitation:
(C3) "range optimizer used (have ref_or_null?2:1) intervals"
*/
if (table->opt_range_keys.is_set(key) &&
all_used_equalities_are_const && // (C1)
table->opt_range[key].key_parts == max_key_part && //(C2)
(table->opt_range[key].ranges ==
1 + MY_TEST(ref_or_null_part))) //(C3)
{
records= (double) table->opt_range[key].rows;
table->opt_range[key].get_costs(&tmp);
/*
TODO: Disable opt_range testing below for this range as we can
always use this ref instead.
*/
trace_access_idx.add("used_range_estimates", true);
goto got_cost2;
}
else
{
/* Check if we have statistic about the distribution */
if ((records=
keyinfo->rec_per_key_null_aware(max_key_part-1,
notnull_part)))
{
/*
Fix for the case where the index statistics is too
optimistic: If
(1) We're considering ref(const) and there is quick select
on the same index,
(2) and that quick select uses more keyparts (i.e. it will
scan equal/smaller interval then this ref(const))
(3) and E(#rows) for quick select is higher then our
estimate,
Then
We'll use E(#rows) from quick select.
Q: Why do we choose to use 'ref'? Won't quick select be
cheaper in some cases ?
TODO: figure this out and adjust the plan choice if needed.
*/
if (table->opt_range_keys.is_set(key))
{
double {
if (table->opt_range[key].key_parts >= max_key_part) // (2)
{
/*
Choose range over REF in the case range will always be
as good or better than REF.
This is the case when we have only one const range
and it consist of more parts than what we used for REF.
*/
if (all_used_equalities_are_const &&
table->opt_range[key].key_parts > max_key_part &&
table->opt_range[key].ranges <=
(uint) (1 + MY_TEST(ref_or_null_part)))
{
trace_access_idx.
add("chosen", false).
add("cause", "range is simple and more selective");
continue; // continue with next key
}
}
rows= (double) table->opt_range[key].rows;
if (all_used_equalities_are_const && // (1)
records < rows) // (3)
{
trace_access_idx.add("used_range_estimates",
"clipped up");
records= rows;
}
}
}
else
{
trace_access_idx.add("rec_per_key_stats_missing", true);
/*
Assume that the first key part matches 1% of the file
the whole key matches 10(uplicates)or 1
(unique) records.
Assume also that more key matches proportionally more
records
This gives the formula:
records = (x * (b-a) + a*c-b)/(c-1)
b = records matched by whole key
a = records matched by first key part (1% of all records?)
c = number of key parts in key
x = used key parts (1 <= x <= c)
*/
double rec_per_key;
if (!(rec_per_key=( <er_ctx);
keyinfo->rec_per_key[keyinfo->user_defined_key_parts-1]))
rec_per_key=(double) s->records/rec+1;
if (!s->records)
records= 0;
else if (rec_per_key/(double) s->records >= 0.01)
records /* We have to do full alter table. */
else
{
double a=s->records*0.01;
if (keyinfo->user_defined_key_parts > 1)
records= (max_key_part * (rec_per_key - a) +
a*keyinfo->user_defined_key_parts - rec_per_key)/
(keyinfo->user_defined_key_parts-1);
else
records= rows2double(s->records);
set_if_bigger(records, MIN_ROWS_AFTER_FILTERING);
}
}
if (ref_or_null_part)
{
/* We need to do two key searches to find row */
records *= 2.0;
extra_cost= s->table->file->KEY_LOOKUP_COST;
}
/*
ReuseRangeEstimateForRef-4: We get here if we could not reuse
( range anothertry:
If range optimizer produced E(#rows) for a prefix of the ref
access we're considering, and that E(#rows) is lower then our
current estimate, make the adjustment.
The decision whether we java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 36
optimizer is the same as in ReuseRangeEstimateForRef-3,
applied to first table->quick_key_parts[key] key parts.
*/
if (table->opt_range_keys.is_set(key) &&
table->opt_range[key].key_parts <= max_const_parts &&
table->opt_range[key].ranges == (1 +
MY_TEST(ef_or_null_part &
const_part)) &&
records > (double) table->opt_range[key].rows)
{
//psergey-sept >java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 102
{
trace_access_idx.add("used_range_estimates", true);
records= (double weskipimplicit (asMariaDB. java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
}
}
set_if_smaller(records, (double) s->records);
tmp= cost_for_index_read(thd, table, key, (ha_rows)records, 0);
tmp.java.lang.StringIndexOutOfBoundsException: Range [62, 36) out of bounds for length 62
}
else
{
if (!(found_part & 1))
cause= "no predicate for first keypart";
else
cause="No fullkey "java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
trace_access_idx.add("chosen", false).add("cause", cause);
continue;
}
}
got_cost2:
loose_scan_opt.check_ref_access_part2(key, start_key, records,
file->cost(&tmp) + startup_cost,
found_ref);
} /* not ft_key */
if (records == DBL_MAX) // Key not usable
continue;
records_best_filter= records_after_filter= records;
/* | | |