Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
70f066eb
Commit
70f066eb
authored
Oct 16, 2013
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge 5.5 -> 10.0-base
parents
3bf20bc7
73f8b4da
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
261 additions
and
2 deletions
+261
-2
mysql-test/r/query_cache.result
mysql-test/r/query_cache.result
+146
-0
mysql-test/t/query_cache.test
mysql-test/t/query_cache.test
+92
-0
sql/sp_head.cc
sql/sp_head.cc
+8
-0
sql/sql_cache.cc
sql/sql_cache.cc
+5
-1
sql/sql_parse.cc
sql/sql_parse.cc
+4
-1
sql/sql_prepare.cc
sql/sql_prepare.cc
+6
-0
No files found.
mysql-test/r/query_cache.result
View file @
70f066eb
...
...
@@ -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;
...
...
mysql-test/t/query_cache.test
View file @
70f066eb
...
...
@@ -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
;
...
...
sql/sp_head.cc
View file @
70f066eb
...
...
@@ -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
;
...
...
sql/sql_cache.cc
View file @
70f066eb
...
...
@@ -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
...
...
sql/sql_parse.cc
View file @
70f066eb
...
...
@@ -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
;
}
...
...
sql/sql_prepare.cc
View file @
70f066eb
...
...
@@ -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
();
}
}
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment