Skip to content

Commit

Permalink
Fix for Bug#17154722 REMOVE COMPILER WARNINGS PRODUCED BY SUN STUDIO …
Browse files Browse the repository at this point in the history
…COMPILER

                  
Fixes the following compiler warning caused by a local variable having the
same name as a class variable:
      
   Warning: keyuse hides JOIN::keyuse
      
The solution for this is to rename the JOIN::keyuse variable to keyuse_array.
The patch also changes make_join_statistics() and optimize_keyuse() to use 
JOIN::keyuse_array directly instead of getting it as an argument.
  • Loading branch information
Olav Sandstaa committed Oct 30, 2013
1 parent 082ee66 commit 6958f5f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions sql/sql_optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ using std::max;
using std::min;

static bool make_join_statistics(JOIN *join, TABLE_LIST *leaves, Item *conds,
Key_use_array *keyuse,
bool first_optimization);
static bool optimize_semijoin_nests_for_materialization(JOIN *join);
static void calculate_materialization_costs(JOIN *join, TABLE_LIST *sj_nest,
Expand Down Expand Up @@ -90,7 +89,7 @@ static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
TABLE *table,
const key_map *keys,ha_rows limit);
static void optimize_keyuse(JOIN *join, Key_use_array *keyuse_array);
static void optimize_keyuse(JOIN *join);
static Item *
make_cond_for_table_from_pred(Item *root_cond, Item *cond,
table_map tables, table_map used_table,
Expand Down Expand Up @@ -384,7 +383,7 @@ JOIN::optimize()

/* Calculate how to do the join */
THD_STAGE_INFO(thd, stage_statistics);
if (make_join_statistics(this, select_lex->leaf_tables, conds, &keyuse,
if (make_join_statistics(this, select_lex->leaf_tables, conds,
first_optimization))
{
DBUG_PRINT("error",("Error: make_join_statistics() failed"));
Expand Down Expand Up @@ -3166,7 +3165,6 @@ void JOIN::set_prefix_tables()
@param tables_arg List of tables referenced by this query block.
@param conds Query search condition (derived version of the
WHERE clause.)
@param keyuse_array[out] Populated with key_use information.
@param first_optimization True if this is the first optimization of this
query.
Expand Down Expand Up @@ -3203,7 +3201,7 @@ void JOIN::set_prefix_tables()

static bool
make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, Item *conds,
Key_use_array *keyuse_array, bool first_optimization)
bool first_optimization)
{
int error;
THD *const thd= join->thd;
Expand Down Expand Up @@ -3383,7 +3381,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, Item *conds,
trace_table_dependencies(trace, stat, table_count);

if (conds || outer_join)
if (update_ref_and_keys(thd, keyuse_array, stat, join->tables,
if (update_ref_and_keys(thd, &join->keyuse_array, stat, join->tables,
conds, join->cond_equal,
~outer_join, join->select_lex, &sargables))
goto error;
Expand Down Expand Up @@ -3815,7 +3813,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, Item *conds,
join->set_semijoin_embedding();

if (!join->plan_is_const())
optimize_keyuse(join, keyuse_array);
optimize_keyuse(join);

join->allow_outer_refs= true;

Expand Down Expand Up @@ -9518,8 +9516,10 @@ static void save_index_subquery_explain_info(JOIN_TAB *join_tab, Item* where)
*/

static void optimize_keyuse(JOIN *join, Key_use_array *keyuse_array)
static void optimize_keyuse(JOIN *join)
{
Key_use_array *keyuse_array= &join->keyuse_array;

for (size_t ix= 0; ix < keyuse_array->size(); ++ix)
{
Key_use *keyuse= &keyuse_array->at(ix);
Expand Down
7 changes: 4 additions & 3 deletions sql/sql_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ class JOIN :public Sql_alloc
bool need_tmp;
int hidden_group_field_count;

Key_use_array keyuse;
// Used and updated by make_join_statistics and optimize_keyuse
Key_use_array keyuse_array;

List<Item> all_fields; ///< to store all expressions used in query
///Above list changed to use temporary table
Expand Down Expand Up @@ -419,7 +420,7 @@ class JOIN :public Sql_alloc

JOIN(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg,
select_result *result_arg)
: keyuse(thd_arg->mem_root),
: keyuse_array(thd_arg->mem_root),
fields_list(fields_arg),
sj_subselects(thd_arg->mem_root)
{
Expand Down Expand Up @@ -476,7 +477,7 @@ class JOIN :public Sql_alloc
all_fields= fields_arg;
if (&fields_list != &fields_arg) /* Avoid valgrind-warning */
fields_list= fields_arg;
keyuse.clear();
keyuse_array.clear();
tmp_table_param.init();
tmp_table_param.end_write_records= HA_POS_ERROR;
rollup.state= ROLLUP::STATE_NONE;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ bool JOIN::destroy()
delete sjm;
sjm_exec_list.empty();

keyuse.clear();
keyuse_array.clear();
DBUG_RETURN(test(error));
}

Expand Down

0 comments on commit 6958f5f

Please sign in to comment.