Skip to content

Commit

Permalink
Don't increment 'Empty_queries' for queries with errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi committed Sep 15, 2016
1 parent 7ca60dd commit 6c1c27e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions mysql-test/r/empty_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ select * from t1;
nr b str
select * from t1 limit 0;
nr b str
show status like "Empty_queries";
Variable_name Value
Empty_queries 2
drop table t1;
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
show status like "Empty_queries";
Variable_name Value
Empty_queries 2
9 changes: 9 additions & 0 deletions mysql-test/t/empty_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary
select count(*) from t1;
select * from t1;
select * from t1 limit 0;
show status like "Empty_queries";
drop table t1;

#
# Accessing a non existing table should not increase Empty_queries
#

--error 1146
select * from t2;
show status like "Empty_queries";

# End of 4.1 tests
2 changes: 1 addition & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6359,7 +6359,7 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
}
}
/* Count number of empty select queries */
if (!thd->get_sent_row_count())
if (!thd->get_sent_row_count() && !res)
status_var_increment(thd->status_var.empty_queries);
else
status_var_add(thd->status_var.rows_sent, thd->get_sent_row_count());
Expand Down

0 comments on commit 6c1c27e

Please sign in to comment.