mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ...
- Call tmp_having->update_used_tables() *before* we have call JOIN::cleanup(). Making the call after join::cleanup() is not allowed, because subquery predicate items walk parent join's JOIN_TAB structures. Which can be invalidated by JOIN::cleanup().
This commit is contained in:
@@ -2367,7 +2367,12 @@ JOIN::exec()
|
||||
List<Item> *curr_all_fields= &all_fields;
|
||||
List<Item> *curr_fields_list= &fields_list;
|
||||
TABLE *curr_tmp_table= 0;
|
||||
bool tmp_having_used_tables_updated= FALSE;
|
||||
/*
|
||||
curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not
|
||||
be safe to call update_used_tables() after that.
|
||||
*/
|
||||
if (curr_join->tmp_having)
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
|
||||
/*
|
||||
Initialize examined rows here because the values from all join parts
|
||||
@@ -2618,16 +2623,6 @@ JOIN::exec()
|
||||
curr_join->select_distinct=0; /* Each row is unique */
|
||||
|
||||
|
||||
/*
|
||||
curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not
|
||||
be safe to call update_used_tables() after that.
|
||||
*/
|
||||
if (curr_join->tmp_having)
|
||||
{
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
tmp_having_used_tables_updated= TRUE;
|
||||
}
|
||||
|
||||
curr_join->join_free(); /* Free quick selects */
|
||||
|
||||
if (curr_join->select_distinct && ! curr_join->group_list)
|
||||
@@ -2708,9 +2703,6 @@ JOIN::exec()
|
||||
if (curr_join->tmp_having && ! curr_join->group_list &&
|
||||
! curr_join->sort_and_group)
|
||||
{
|
||||
// Some tables may have been const
|
||||
if (!tmp_having_used_tables_updated)
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables];
|
||||
table_map used_tables= (curr_join->const_table_map |
|
||||
curr_table->table->map);
|
||||
|
||||
Reference in New Issue
Block a user