Commit 647dee03 authored by istruewing@chilla.local's avatar istruewing@chilla.local

Merge bk-internal.mysql.com:/home/bk/mysql-4.1-engines

into  chilla.local:/home/mydev/mysql-4.1-bug12240
parents 3ee35a76 c4dee7ca
...@@ -1183,11 +1183,12 @@ JOIN::exec() ...@@ -1183,11 +1183,12 @@ JOIN::exec()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* /*
don't reset the found rows count if there're no tables Don't reset the found rows count if there're no tables as
as FOUND_ROWS() may be called. FOUND_ROWS() may be called. Never reset the examined row count here.
It must be accumulated from all join iterations of all join parts.
*/ */
if (tables) if (tables)
thd->limit_found_rows= thd->examined_row_count= 0; thd->limit_found_rows= 0;
if (zero_result_cause) if (zero_result_cause)
{ {
...@@ -1235,6 +1236,12 @@ JOIN::exec() ...@@ -1235,6 +1236,12 @@ JOIN::exec()
List<Item> *curr_all_fields= &all_fields; List<Item> *curr_all_fields= &all_fields;
List<Item> *curr_fields_list= &fields_list; List<Item> *curr_fields_list= &fields_list;
TABLE *curr_tmp_table= 0; TABLE *curr_tmp_table= 0;
/*
Initialize examined rows here because the values from all join parts
must be accumulated in examined_row_count. Hence every join
iteration must count from zero.
*/
curr_join->examined_rows= 0;
/* Create a tmp table if distinct or if the sort is too complicated */ /* Create a tmp table if distinct or if the sort is too complicated */
if (need_tmp) if (need_tmp)
...@@ -1583,7 +1590,10 @@ JOIN::exec() ...@@ -1583,7 +1590,10 @@ JOIN::exec()
error= thd->net.report_error ? -1 : error= thd->net.report_error ? -1 :
do_select(curr_join, curr_fields_list, NULL, procedure); do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records; thd->limit_found_rows= curr_join->send_records;
thd->examined_row_count= curr_join->examined_rows; /* Accumulate the counts from all join iterations of all join parts. */
thd->examined_row_count+= curr_join->examined_rows;
DBUG_PRINT("counts", ("thd->examined_row_count: %lu",
(ulong) thd->examined_row_count));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -6184,6 +6194,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) ...@@ -6184,6 +6194,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
return -2; /* purecov: inspected */ return -2; /* purecov: inspected */
} }
join->examined_rows++; join->examined_rows++;
DBUG_PRINT("counts", ("join->examined_rows++: %lu",
(ulong) join->examined_rows));
join->thd->row_count++; join->thd->row_count++;
if (!on_expr || on_expr->val_int()) if (!on_expr || on_expr->val_int())
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment