diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b0a25c2..581c6fc 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -457,6 +457,8 @@ bool st_select_lex_unit::exec() SELECT_LEX *select_cursor=first_select(); ulonglong add_rows=0; ha_rows examined_rows= 0; + int tmp_x= 0; + int tmp_y= 0; DBUG_ENTER("st_select_lex_unit::exec"); if (executed && !uncacheable && !describe) @@ -515,7 +517,10 @@ bool st_select_lex_unit::exec() if (!saved_error) { records_at_start= table->file->stats.records; + tmp_x= thd->examined_row_count; sl->join->exec(); + tmp_y= thd->examined_row_count; + thd->examined_row_count= tmp_x; if (sl == union_distinct) { if (table->file->ha_disable_indexes(HA_KEY_SWITCH_ALL)) @@ -528,13 +533,14 @@ bool st_select_lex_unit::exec() 0); if (!saved_error) { - examined_rows+= thd->examined_row_count; + examined_rows+= tmp_y - tmp_x; if (union_result->flush()) { thd->lex->current_select= lex_select_save; DBUG_RETURN(1); } } + tmp_x= tmp_y; } if (saved_error) { @@ -644,7 +650,10 @@ bool st_select_lex_unit::exec() { join->examined_rows= 0; saved_error= join->reinit(); + tmp_x= thd->examined_row_count; join->exec(); + tmp_y= thd->examined_row_count; + thd->examined_row_count= tmp_x; } } @@ -652,6 +661,7 @@ bool st_select_lex_unit::exec() if (!saved_error) { thd->limit_found_rows = (ulonglong)table->file->stats.records + add_rows; + examined_rows+= tmp_y - tmp_x; thd->examined_row_count+= examined_rows; } /*