diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 5 | ||||
-rw-r--r-- | sql/log.cc | 8 | ||||
-rw-r--r-- | sql/multi_range_read.cc | 4 | ||||
-rw-r--r-- | sql/opt_range.cc | 38 | ||||
-rw-r--r-- | sql/rpl_gtid.cc | 16 | ||||
-rw-r--r-- | sql/rpl_gtid.h | 2 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_join_cache.cc | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 | ||||
-rw-r--r-- | sql/sql_statistics.cc | 2 |
10 files changed, 53 insertions, 32 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 1ee4a4436fe..15b1cedf346 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3866,7 +3866,10 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref) vals= (DYNAMIC_COLUMN_VALUE *) alloc_root(thd->mem_root, sizeof(DYNAMIC_COLUMN_VALUE) * (arg_count / 2)); - for (i= 0; i + 1 < arg_count && args[i]->result_type() == INT_RESULT; i+= 2); + for (i= 0; + i + 1 < arg_count && args[i]->result_type() == INT_RESULT; + i+= 2) + ; if (i + 1 < arg_count) { names= TRUE; diff --git a/sql/log.cc b/sql/log.cc index a4ec5583dc9..a96ec830b01 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -119,7 +119,6 @@ static MYSQL_BIN_LOG::xid_count_per_binlog * static bool start_binlog_background_thread(); - static rpl_binlog_state rpl_global_gtid_binlog_state; /** @@ -2994,6 +2993,13 @@ void MYSQL_BIN_LOG::cleanup() mysql_cond_destroy(&COND_binlog_background_thread); mysql_cond_destroy(&COND_binlog_background_thread_end); } + + /* + Free data for global binlog state. + We can't do that automaticly as we need to do this before + safemalloc is shut down + */ + rpl_global_gtid_binlog_state.free(); DBUG_VOID_RETURN; } diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index e3719600dff..ceb6b16ec7a 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -1199,9 +1199,9 @@ bool DsMrr_impl::setup_buffer_sharing(uint key_size_in_keybuf, statistics? */ uint parts= my_count_bits(key_tuple_map); - ulong rpc; + ha_rows rpc; ulonglong rowids_size= rowid_buf_elem_size; - if ((rpc= key_info->actual_rec_per_key(parts - 1))) + if ((rpc= (ha_rows) key_info->actual_rec_per_key(parts - 1))) rowids_size= rowid_buf_elem_size * rpc; double fraction_for_rowids= diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b736f898768..85c9c9fd394 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5919,8 +5919,8 @@ ha_rows records_in_index_intersect_extension(PARTIAL_INDEX_INTERSECT_INFO *curr, ha_rows ext_records= ext_index_scan->records; if (i < used_key_parts) { - ulong f1= key_info->actual_rec_per_key(i-1); - ulong f2= key_info->actual_rec_per_key(i); + double f1= key_info->actual_rec_per_key(i-1); + double f2= key_info->actual_rec_per_key(i); ext_records= (ha_rows) ((double) ext_records / f2 * f1); } if (ext_records < table_cardinality) @@ -13157,11 +13157,11 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, double *read_cost, ha_rows *records) { ha_rows table_records; - uint num_groups; - uint num_blocks; - uint keys_per_block; - uint keys_per_group; - uint keys_per_subgroup; /* Average number of keys in sub-groups */ + ha_rows num_groups; + ha_rows num_blocks; + uint keys_per_block; + ha_rows keys_per_group; + ha_rows keys_per_subgroup; /* Average number of keys in sub-groups */ /* formed by a key infix. */ double p_overlap; /* Probability that a sub-group overlaps two blocks. */ double quick_prefix_selectivity; @@ -13170,24 +13170,24 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, DBUG_ENTER("cost_group_min_max"); table_records= table->stat_records(); - keys_per_block= (table->file->stats.block_size / 2 / - (index_info->key_length + table->file->ref_length) - + 1); - num_blocks= (uint)(table_records / keys_per_block) + 1; + keys_per_block= (uint) (table->file->stats.block_size / 2 / + (index_info->key_length + table->file->ref_length) + + 1); + num_blocks= (ha_rows)(table_records / keys_per_block) + 1; /* Compute the number of keys in a group. */ - keys_per_group= index_info->actual_rec_per_key(group_key_parts - 1); + keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1); if (keys_per_group == 0) /* If there is no statistics try to guess */ /* each group contains 10% of all records */ - keys_per_group= (uint)(table_records / 10) + 1; - num_groups= (uint)(table_records / keys_per_group) + 1; + keys_per_group= (table_records / 10) + 1; + num_groups= (table_records / keys_per_group) + 1; /* Apply the selectivity of the quick select for group prefixes. */ if (range_tree && (quick_prefix_records != HA_POS_ERROR)) { quick_prefix_selectivity= (double) quick_prefix_records / (double) table_records; - num_groups= (uint) rint(num_groups * quick_prefix_selectivity); + num_groups= (ha_rows) rint(num_groups * quick_prefix_selectivity); set_if_bigger(num_groups, 1); } @@ -13196,7 +13196,7 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, Compute the probability that two ends of a subgroup are inside different blocks. */ - keys_per_subgroup= index_info->actual_rec_per_key(used_key_parts - 1); + keys_per_subgroup= (ha_rows) index_info->actual_rec_per_key(used_key_parts - 1); if (keys_per_subgroup >= keys_per_block) /* If a subgroup is bigger than */ p_overlap= 1.0; /* a block, it will overlap at least two blocks. */ else @@ -13224,9 +13224,9 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, *records= num_groups; DBUG_PRINT("info", - ("table rows: %lu keys/block: %u keys/group: %u result rows: %lu blocks: %u", - (ulong)table_records, keys_per_block, keys_per_group, - (ulong) *records, num_blocks)); + ("table rows: %lu keys/block: %u keys/group: %lu result rows: %lu blocks: %lu", + (ulong)table_records, keys_per_block, (ulong) keys_per_group, + (ulong) *records, (ulong) num_blocks)); DBUG_VOID_RETURN; } diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index d6a6ed90bd3..bda060115ed 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -686,6 +686,7 @@ rpl_binlog_state::rpl_binlog_state() sizeof(uint32), NULL, my_free, HASH_UNIQUE); mysql_mutex_init(key_LOCK_binlog_state, &LOCK_binlog_state, MY_MUTEX_INIT_SLOW); + initialized= 1; } @@ -699,11 +700,20 @@ rpl_binlog_state::reset() my_hash_reset(&hash); } +void rpl_binlog_state::free() +{ + if (initialized) + { + initialized= 0; + reset(); + my_hash_free(&hash); + mysql_mutex_destroy(&LOCK_binlog_state); + } +} + rpl_binlog_state::~rpl_binlog_state() { - reset(); - my_hash_free(&hash); - mysql_mutex_destroy(&LOCK_binlog_state); + free(); } diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index e63d8439803..046533fd760 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -135,11 +135,13 @@ struct rpl_binlog_state HASH hash; /* Mutex protecting access to the state. */ mysql_mutex_t LOCK_binlog_state; + my_bool initialized; rpl_binlog_state(); ~rpl_binlog_state(); void reset(); + void free(); int update(const struct rpl_gtid *gtid); uint64 seq_no_from_state(); int write_to_iocache(IO_CACHE *dest); diff --git a/sql/set_var.cc b/sql/set_var.cc index 48f7cc7a054..97545778f18 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -315,7 +315,7 @@ longlong sys_var::val_int(bool *is_null, { case_get_string_as_lex_string; case_for_integers(return val); - case_for_double(return val); + case_for_double(return (longlong) val); default: my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str); return 0; diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 6b0882bda80..9fca8730cb5 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -3812,8 +3812,8 @@ uint JOIN_TAB_SCAN_MRR::aux_buffer_incr(ulong recno) uint incr= 0; TABLE_REF *ref= &join_tab->ref; TABLE *tab= join_tab->table; - uint rec_per_key= - tab->key_info[ref->key].actual_rec_per_key(ref->key_parts-1); + ha_rows rec_per_key= + (ha_rows) tab->key_info[ref->key].actual_rec_per_key(ref->key_parts-1); set_if_bigger(rec_per_key, 1); if (recno == 1) incr= ref->key_length + tab->file->ref_length; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 46cc157061d..b448e5a64b9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5977,8 +5977,8 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, KEY *key=show_table->key_info+i; if (key->rec_per_key[j]) { - ha_rows records=((double) show_table->stat_records() / - key->actual_rec_per_key(j)); + ha_rows records= (ha_rows) ((double) show_table->stat_records() / + key->actual_rec_per_key(j)); table->field[9]->store((longlong) records, TRUE); table->field[9]->set_notnull(); } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index f355f2c7760..2e2886a1d3f 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -337,7 +337,7 @@ protected: void store_record_for_lookup() { - store_record(stat_table, record[0]); + DBUG_ASSERT(record[0] == stat_table->record[0]); } bool update_record() |