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
b0722aad
Commit
b0722aad
authored
Mar 21, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed BUG in query cahe statistic counting
parent
f657ea97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
mysql-test/r/grant_cache.result
mysql-test/r/grant_cache.result
+39
-3
mysql-test/t/grant_cache.test
mysql-test/t/grant_cache.test
+12
-0
sql/sql_cache.cc
sql/sql_cache.cc
+14
-3
No files found.
mysql-test/r/grant_cache.result
View file @
b0722aad
...
@@ -41,17 +41,53 @@ grant SELECT on mysqltest.* to mysqltest_1@localhost;
...
@@ -41,17 +41,53 @@ grant SELECT on mysqltest.* to mysqltest_1@localhost;
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
grant SELECT on test.t1 to mysqltest_2@localhost;
grant SELECT on test.t1 to mysqltest_2@localhost;
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 0
select "user1";
select "user1";
user1
user1
user1
user1
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
select * from t1;
select * from t1;
a b c
a b c
1 1 1
1 1 1
2 2 2
2 2 2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
select a from t1 ;
select a from t1 ;
a
a
1
1
2
2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 2
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
select c from t1;
select c from t1;
c
c
1
1
...
@@ -94,7 +130,7 @@ Variable_name Value
...
@@ -94,7 +130,7 @@ Variable_name Value
Qcache_hits 7
Qcache_hits 7
show status like "Qcache_not_cached";
show status like "Qcache_not_cached";
Variable_name Value
Variable_name Value
Qcache_not_cached
3
Qcache_not_cached
2
select "user3";
select "user3";
user3
user3
user3
user3
...
@@ -118,7 +154,7 @@ Variable_name Value
...
@@ -118,7 +154,7 @@ Variable_name Value
Qcache_hits 7
Qcache_hits 7
show status like "Qcache_not_cached";
show status like "Qcache_not_cached";
Variable_name Value
Variable_name Value
Qcache_not_cached
8
Qcache_not_cached
7
select "user4";
select "user4";
user4
user4
user4
user4
...
@@ -144,7 +180,7 @@ Variable_name Value
...
@@ -144,7 +180,7 @@ Variable_name Value
Qcache_hits 8
Qcache_hits 8
show status like "Qcache_not_cached";
show status like "Qcache_not_cached";
Variable_name Value
Variable_name Value
Qcache_not_cached
9
Qcache_not_cached
8
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
...
...
mysql-test/t/grant_cache.test
View file @
b0722aad
...
@@ -40,10 +40,22 @@ grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
...
@@ -40,10 +40,22 @@ grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
# The following queries should be fetched from cache
# The following queries should be fetched from cache
connect
(
user1
,
localhost
,
mysqltest_1
,,
mysqltest
,
$MASTER_MYPORT
,
master
.
sock
);
connect
(
user1
,
localhost
,
mysqltest_1
,,
mysqltest
,
$MASTER_MYPORT
,
master
.
sock
);
connection
user1
;
connection
user1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_not_cached"
;
select
"user1"
;
select
"user1"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_not_cached"
;
select
*
from
t1
;
select
*
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_not_cached"
;
# The pre and end space are intentional
# The pre and end space are intentional
select
a
from
t1
;
select
a
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_not_cached"
;
select
c
from
t1
;
select
c
from
t1
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
...
sql/sql_cache.cc
View file @
b0722aad
...
@@ -589,7 +589,6 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
...
@@ -589,7 +589,6 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
if
(
!
query_cache
.
append_result_data
(
&
result
,
length
,
(
gptr
)
packet
,
if
(
!
query_cache
.
append_result_data
(
&
result
,
length
,
(
gptr
)
packet
,
query_block
))
query_block
))
{
{
query_cache
.
refused
++
;
DBUG_PRINT
(
"warning"
,
(
"Can't append data"
));
DBUG_PRINT
(
"warning"
,
(
"Can't append data"
));
header
->
result
(
result
);
header
->
result
(
result
);
DBUG_PRINT
(
"qcache"
,
(
"free query 0x%lx"
,
(
ulong
)
query_block
));
DBUG_PRINT
(
"qcache"
,
(
"free query 0x%lx"
,
(
ulong
)
query_block
));
...
@@ -845,7 +844,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
...
@@ -845,7 +844,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
}
}
}
}
else
else
statistic_increment
(
refused
,
&
structure_guard_mutex
);
if
(
thd
->
lex
.
sql_command
==
SQLCOM_SELECT
)
statistic_increment
(
refused
,
&
structure_guard_mutex
);
end:
end:
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
@@ -981,7 +981,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
...
@@ -981,7 +981,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT
(
"qcache"
,
DBUG_PRINT
(
"qcache"
,
(
"probably no SELECT access to %s.%s => return to normal processing"
,
(
"probably no SELECT access to %s.%s => return to normal processing"
,
table_list
.
db
,
table_list
.
alias
));
table_list
.
db
,
table_list
.
alias
));
refused
++
;
// This is actually a hit
STRUCT_UNLOCK
(
&
structure_guard_mutex
);
STRUCT_UNLOCK
(
&
structure_guard_mutex
);
thd
->
safe_to_cache_query
=
0
;
// Don't try to cache this
thd
->
safe_to_cache_query
=
0
;
// Don't try to cache this
BLOCK_UNLOCK_RD
(
query_block
);
BLOCK_UNLOCK_RD
(
query_block
);
...
@@ -1610,6 +1609,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
...
@@ -1610,6 +1609,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
*/
*/
if
(
result_block
!=
0
)
if
(
result_block
!=
0
)
{
{
if
(
result_block
->
type
!=
Query_cache_block
::
RESULT
)
{
// removing unfinished query
refused
++
;
inserts
--
;
}
Query_cache_block
*
block
=
result_block
;
Query_cache_block
*
block
=
result_block
;
do
do
{
{
...
@@ -1618,6 +1623,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
...
@@ -1618,6 +1623,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
free_memory_block
(
current
);
free_memory_block
(
current
);
}
while
(
block
!=
result_block
);
}
while
(
block
!=
result_block
);
}
}
else
{
// removing unfinished query
refused
++
;
inserts
--
;
}
query
->
unlock_n_destroy
();
query
->
unlock_n_destroy
();
free_memory_block
(
query_block
);
free_memory_block
(
query_block
);
...
...
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