Commit 70f066eb authored by Alexander Barkov's avatar Alexander Barkov

Merge 5.5 -> 10.0-base

parents 3bf20bc7 73f8b4da
......@@ -1932,6 +1932,152 @@ set local query_cache_type= on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 ON ON
#
# MDEV-4981: Account for queries handled by query-cache in
# USER_STATISTICS (and in HOST_STATISTICS)
#
SET GLOBAL userstat=1;
set GLOBAL query_cache_size=1355776;
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
reset query cache;
flush status;
create table t1 (a int);
insert into t1 values (1);
select * from t1;
a
1
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
1 1 0
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
2 2 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a
1
select * from t1;
a
1
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
5 5 0
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
6 6 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 2
drop table t1;
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
create table t1 (a int);
select * from t1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
1 0 1
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
2 1 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a
select * from t1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
5 2 3
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
6 3 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 2
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
create procedure p1()
select * from t1;
call p1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
1 0 1
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
2 1 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
call p1;
a
call p1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
5 2 3
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
6 3 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 2
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
SET GLOBAL query_cache_size= 0;
call p1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
1 0 1
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
2 1 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
call p1;
a
call p1;
a
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
5 2 3
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
6 3 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop procedure p1;
drop table t1;
set GLOBAL query_cache_size=1355776;
SET GLOBAL userstat=default;
End of 5.5 tests
restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size= default;
......
......@@ -1617,6 +1617,98 @@ select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set local query_cache_type= on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
--echo #
--echo # MDEV-4981: Account for queries handled by query-cache in
--echo # USER_STATISTICS (and in HOST_STATISTICS)
--echo #
SET GLOBAL userstat=1;
set GLOBAL query_cache_size=1355776;
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
reset query cache;
flush status;
create table t1 (a int);
insert into t1 values (1);
select * from t1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
select * from t1;
select * from t1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
drop table t1;
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
create table t1 (a int);
select * from t1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
select * from t1;
select * from t1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
create procedure p1()
select * from t1;
call p1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
call p1;
call p1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
FLUSH USER_STATISTICS;
FLUSH CLIENT_STATISTICS;
flush status;
SET GLOBAL query_cache_size= 0;
call p1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
call p1;
call p1;
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
where CLIENT="localhost";
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
where USER="root";
show status like "Qcache_hits";
drop procedure p1;
drop table t1;
set GLOBAL query_cache_size=1355776;
SET GLOBAL userstat=default;
--echo End of 5.5 tests
--echo restore defaults
SET GLOBAL query_cache_type= default;
......
......@@ -3170,7 +3170,15 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
log_slow_statement(thd);
}
else
{
/* change statistics */
enum_sql_command save_sql_command= thd->lex->sql_command;
thd->lex->sql_command= SQLCOM_SELECT;
status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]);
thd->update_stats();
thd->lex->sql_command= save_sql_command;
*nextp= m_ip+1;
}
thd->set_query(query_backup);
thd->query_name_consts= 0;
......
......@@ -2074,9 +2074,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
}
#endif /*!EMBEDDED_LIBRARY*/
thd->limit_found_rows = query->found_rows();
thd->sent_row_count= thd->limit_found_rows = query->found_rows();
thd->status_var.last_query_cost= 0.0;
thd->query_plan_flags= (thd->query_plan_flags & ~QPLAN_QC_NO) | QPLAN_QC;
if (!thd->sent_row_count)
status_var_increment(thd->status_var.empty_queries);
else
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
/*
End the statement transaction potentially started by an
......
......@@ -4899,7 +4899,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
/* Count number of empty select queries */
if (!thd->sent_row_count)
status_var_increment(thd->status_var.empty_queries);
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
else
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
return res;
}
......@@ -6038,6 +6039,8 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
{
/* Update statistics for getting the query from the cache */
thd->lex->sql_command= SQLCOM_SELECT;
status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]);
thd->update_stats();
}
DBUG_VOID_RETURN;
}
......
......@@ -3913,6 +3913,12 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
error= mysql_execute_command(thd);
MYSQL_QUERY_EXEC_DONE(error);
}
else
{
thd->lex->sql_command= SQLCOM_SELECT;
status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]);
thd->update_stats();
}
}
/*
......
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