#At file:///home/mysql_src/bzrrepos/mysql-next-mr-opt-backporting2/ based on revid:guilhem@stripped
3163 Guilhem Bichot 2010-05-10
Some debugging aids which helped debugging BUG 46743 "Azalea processing correlated, aggregate
SELECT subqueries incorrectly". Backporting of guilhem@stripped .
modified:
sql/sql_select.cc
sql/sql_select.h
storage/myisam/mi_scan.c
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-05-10 19:31:43 +0000
+++ b/sql/sql_select.cc 2010-05-10 19:58:01 +0000
@@ -2848,7 +2848,7 @@ JOIN::exec()
DBUG_VOID_RETURN;
curr_table->select->cond->fix_fields(thd, 0);
}
- curr_table->select_cond= curr_table->select->cond;
+ curr_table->set_select_cond(curr_table->select->cond, __LINE__);
curr_table->select_cond->top_level_item();
DBUG_EXECUTE("where",print_where(curr_table->select->cond,
"select and having",
@@ -4556,7 +4556,8 @@ make_join_statistics(JOIN *join, TABLE_L
join->best_read=1.0;
}
/* Generate an execution plan from the found optimal join order. */
- DBUG_RETURN(join->thd->killed || get_best_combination(join));
+ error= join->thd->killed || get_best_combination(join);
+ DBUG_RETURN(error);
error:
/*
@@ -8668,7 +8669,9 @@ static void add_not_null_conds(JOIN *joi
DBUG_EXECUTE("where",print_where(notnull,
referred_tab->table->alias,
QT_ORDINARY););
- add_cond_and_fix(&referred_tab->select_cond, notnull);
+ COND *new_cond= referred_tab->select_cond;
+ add_cond_and_fix(&new_cond, notnull);
+ referred_tab->set_select_cond(new_cond, __LINE__);
}
}
}
@@ -8855,9 +8858,9 @@ static bool make_join_select(JOIN *join,
if (!tmp)
DBUG_RETURN(1);
tmp->quick_fix_field();
- cond_tab->select_cond= !cond_tab->select_cond ? tmp :
- new Item_cond_and(cond_tab->select_cond,
- tmp);
+ COND *new_cond= !cond_tab->select_cond ? tmp :
+ new Item_cond_and(cond_tab->select_cond, tmp);
+ cond_tab->set_select_cond(new_cond, __LINE__);
if (!cond_tab->select_cond)
DBUG_RETURN(1);
cond_tab->select_cond->quick_fix_field();
@@ -8981,7 +8984,8 @@ static bool make_join_select(JOIN *join,
*/
if (!(tmp= add_found_match_trig_cond(first_inner_tab, tmp, 0)))
DBUG_RETURN(1);
- tab->select_cond=sel->cond=tmp;
+ sel->cond= tmp;
+ tab->set_select_cond(tmp, __LINE__);
/* Push condition to storage engine if this is enabled
and the condition is not guarded */
tab->table->file->pushed_cond= NULL;
@@ -8999,7 +9003,10 @@ static bool make_join_select(JOIN *join,
}
}
else
- tab->select_cond= sel->cond= NULL;
+ {
+ sel->cond= NULL;
+ tab->set_select_cond(NULL, __LINE__);
+ }
sel->head=tab->table;
DBUG_EXECUTE("where",print_where(tmp,tab->table->alias, QT_ORDINARY););
@@ -9153,8 +9160,9 @@ static bool make_join_select(JOIN *join,
if (!tmp)
DBUG_RETURN(1);
tmp->quick_fix_field();
- cond_tab->select_cond= !cond_tab->select_cond ? tmp :
- new Item_cond_and(cond_tab->select_cond,tmp);
+ COND *new_cond= !cond_tab->select_cond ? tmp :
+ new Item_cond_and(cond_tab->select_cond, tmp);
+ cond_tab->set_select_cond(new_cond, __LINE__);
if (!cond_tab->select_cond)
DBUG_RETURN(1);
cond_tab->select_cond->update_used_tables();
@@ -9207,11 +9215,9 @@ static bool make_join_select(JOIN *join,
tmp_cond->quick_fix_field();
/* Add the predicate to other pushed down predicates */
DBUG_PRINT("info", ("Item_cond_and"));
- cond_tab->select_cond= !cond_tab->select_cond ? tmp_cond :
- new Item_cond_and(cond_tab->select_cond,
- tmp_cond);
- DBUG_PRINT("info", ("Item_cond_and 0x%lx",
- (ulong)cond_tab->select_cond));
+ COND *new_cond= !cond_tab->select_cond ? tmp_cond :
+ new Item_cond_and(cond_tab->select_cond, tmp_cond);
+ cond_tab->set_select_cond(new_cond, __LINE__);
if (!cond_tab->select_cond)
DBUG_RETURN(1);
cond_tab->select_cond->update_used_tables();
@@ -9590,17 +9596,18 @@ static void push_index_cond(JOIN_TAB *ta
if (row_cond)
{
if (!idx_remainder_cond)
- tab->select_cond= row_cond;
+ tab->set_select_cond(row_cond, __LINE__);
else
{
- tab->select_cond= new Item_cond_and(row_cond, idx_remainder_cond);
+ COND *new_cond= new Item_cond_and(row_cond, idx_remainder_cond);
+ tab->set_select_cond(new_cond, __LINE__);
tab->select_cond->quick_fix_field();
((Item_cond_and*)tab->select_cond)->used_tables_cache=
row_cond->used_tables() | idx_remainder_cond->used_tables();
}
}
else
- tab->select_cond= idx_remainder_cond;
+ tab->set_select_cond(idx_remainder_cond, __LINE__);
if (tab->select)
{
DBUG_EXECUTE("where", print_where(tab->select->cond, "select_cond",
@@ -16083,7 +16090,8 @@ do_select(JOIN *join,List<Item> *fields,
DBUG_PRINT("error",("Error: do_select() failed"));
}
#endif
- DBUG_RETURN(join->thd->is_error() ? -1 : rc);
+ rc= join->thd->is_error() ? -1 : rc;
+ DBUG_RETURN(rc);
}
@@ -16206,10 +16214,9 @@ sub_select_sjm(JOIN *join, JOIN_TAB *joi
JOIN_TAB *last_tab= join_tab + (sjm->tables - 1);
Item *save_cond= last_tab->select_cond;
- last_tab->select_cond= sjm->join_cond;
-
+ last_tab->set_select_cond(sjm->join_cond, __LINE__);
rc= sub_select(join, last_tab, end_of_records);
- last_tab->select_cond= save_cond;
+ last_tab->set_select_cond(save_cond, __LINE__);
DBUG_RETURN(rc);
}
else
@@ -16665,6 +16672,9 @@ evaluate_join_record(JOIN *join, JOIN_TA
DBUG_ENTER("evaluate_join_record");
+ DBUG_PRINT("enter",
+ ("evaluate_join_record join: %p join_tab: %p"
+ " cond: %p error: %d", join, join_tab, select_cond, error));
if (error > 0 || (join->thd->is_error())) // Fatal error
DBUG_RETURN(NESTED_LOOP_ERROR);
if (error < 0)
@@ -16765,7 +16775,7 @@ evaluate_join_record(JOIN *join, JOIN_TA
(See above join->return_tab= tab).
*/
join->examined_rows++;
- DBUG_PRINT("counts", ("join->examined_rows++: %lu",
+ DBUG_PRINT("counts", ("evaluate_join_record join->examined_rows++: %lu",
(ulong) join->examined_rows));
if (found)
@@ -17214,7 +17224,10 @@ join_read_always_key(JOIN_TAB *tab)
for (uint i= 0 ; i < tab->ref.key_parts ; i++)
{
if ((tab->ref.null_rejecting & 1 << i) && tab->ref.items[i]->is_null())
- return -1;
+ {
+ DBUG_PRINT("info", ("join_read_always_key null rejected"));
+ return -1;
+ }
}
if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
@@ -18814,7 +18827,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
usable_keys.intersect(table->covering_keys);
if (tab->pre_idx_push_select_cond)
{
- tab->select_cond= tab->pre_idx_push_select_cond;
+ tab->set_select_cond(tab->pre_idx_push_select_cond, __LINE__);
if (tab->select)
tab->select->cond= tab->select_cond;
}
@@ -19103,7 +19116,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
table->set_keyread(TRUE);
if (tab->pre_idx_push_select_cond)
{
- tab->select_cond= tab->pre_idx_push_select_cond;
+ tab->set_select_cond(tab->pre_idx_push_select_cond, __LINE__);
if (tab->select)
tab->select->cond= tab->select_cond;
}
@@ -19332,7 +19345,7 @@ create_sort_index(THD *thd, JOIN *join,
table->quick_keys.clear_all(); // as far as we cleanup select->quick
table->sort.io_cache= tablesort_result_cache;
}
- tab->select_cond=0;
+ tab->set_select_cond(NULL, __LINE__);
tab->last_inner= 0;
tab->first_unmatched= 0;
tab->type=JT_ALL; // Read with normal read_record
@@ -19369,7 +19382,7 @@ static bool fix_having(JOIN *join, Item
sort_table_cond)) ||
table->select->cond->fix_fields(join->thd, &table->select->cond))
return 1;
- table->select_cond=table->select->cond;
+ table->set_select_cond(table->select->cond, __LINE__);
table->select_cond->top_level_item();
DBUG_EXECUTE("where",print_where(table->select_cond, "select and having",
QT_ORDINARY););
@@ -21088,11 +21101,12 @@ static bool add_ref_to_table_cond(THD *t
{
if (join_tab->select->cond)
error=(int) cond->add(join_tab->select->cond);
- join_tab->select_cond=join_tab->select->cond=cond;
+ join_tab->select->cond= cond;
+ join_tab->set_select_cond(cond, __LINE__);
}
else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0,
&error)))
- join_tab->select_cond=cond;
+ join_tab->set_select_cond(cond, __LINE__);
DBUG_RETURN(error ? TRUE : FALSE);
}
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2010-05-07 20:02:50 +0000
+++ b/sql/sql_select.h 2010-05-10 19:58:01 +0000
@@ -348,6 +348,12 @@ typedef struct st_join_table
return first_inner;
return first_sj_inner_tab;
}
+ void set_select_cond(COND *to, uint line)
+ {
+ DBUG_PRINT("info", ("select_cond changes %p -> %p at line %u tab %p",
+ select_cond, to, line, this));
+ select_cond= to;
+ }
} JOIN_TAB;
/*
=== modified file 'storage/myisam/mi_scan.c'
--- a/storage/myisam/mi_scan.c 2007-05-10 09:59:39 +0000
+++ b/storage/myisam/mi_scan.c 2010-05-10 19:58:01 +0000
@@ -38,8 +38,10 @@ int mi_scan_init(register MI_INFO *info)
int mi_scan(MI_INFO *info, uchar *buf)
{
+ int result;
DBUG_ENTER("mi_scan");
/* Init all but update-flag */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
- DBUG_RETURN ((*info->s->read_rnd)(info,buf,info->nextpos,1));
+ result= (*info->s->read_rnd)(info, buf, info->nextpos, 1);
+ DBUG_RETURN(result);
}
Attachment: [text/bzr-bundle] bzr/guilhem@mysql.com-20100510195801-dctkhw9pzo085jf4.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-bugfixing branch (guilhem:3163) | Guilhem Bichot | 14 May |