summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2010-06-10 17:45:22 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2010-06-10 17:45:22 -0300
commit53b8829682307224a8b5a9de814019926eea9bd7 (patch)
tree676cbb2ee0c8122ad5c35cc014e428700958b280 /sql/item_subselect.cc
parentbb036c93b44b8342c3bea1b07e5b7644189d36c0 (diff)
downloadmariadb-git-53b8829682307224a8b5a9de814019926eea9bd7.tar.gz
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f3fcbc4db68..b93ea6f241b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -244,12 +244,12 @@ bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
if (item->walk(processor, walk_subquery, argument))
return 1;
}
- for (order= (ORDER*) lex->order_list.first ; order; order= order->next)
+ for (order= lex->order_list.first ; order; order= order->next)
{
if ((*order->item)->walk(processor, walk_subquery, argument))
return 1;
}
- for (order= (ORDER*) lex->group_list.first ; order; order= order->next)
+ for (order= lex->group_list.first ; order; order= order->next)
{
if ((*order->item)->walk(processor, walk_subquery, argument))
return 1;
@@ -1781,15 +1781,15 @@ int subselect_single_select_engine::prepare()
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
if (join->prepare(&select_lex->ref_pointer_array,
- (TABLE_LIST*) select_lex->table_list.first,
+ select_lex->table_list.first,
select_lex->with_wild,
select_lex->where,
select_lex->order_list.elements +
select_lex->group_list.elements,
- (ORDER*) select_lex->order_list.first,
- (ORDER*) select_lex->group_list.first,
+ select_lex->order_list.first,
+ select_lex->group_list.first,
select_lex->having,
- (ORDER*) 0, select_lex,
+ NULL, select_lex,
select_lex->master_unit()))
return 1;
thd->lex->current_select= save_select;
@@ -2450,14 +2450,13 @@ table_map subselect_engine::calc_const_tables(TABLE_LIST *table)
table_map subselect_single_select_engine::upper_select_const_tables()
{
- return calc_const_tables((TABLE_LIST *) select_lex->outer_select()->
- leaf_tables);
+ return calc_const_tables(select_lex->outer_select()->leaf_tables);
}
table_map subselect_union_engine::upper_select_const_tables()
{
- return calc_const_tables((TABLE_LIST *) unit->outer_select()->leaf_tables);
+ return calc_const_tables(unit->outer_select()->leaf_tables);
}