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
e54ea918
Commit
e54ea918
authored
Feb 04, 2005
by
msvensson@neptunus.homeip.net
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge of query cache from 4.1 to 5.0
parent
3181f5d2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
114 deletions
+136
-114
mysql-test/r/ndb_cache.result
mysql-test/r/ndb_cache.result
+13
-13
mysql-test/r/ndb_cache2.result
mysql-test/r/ndb_cache2.result
+12
-12
mysql-test/t/ndb_cache.test
mysql-test/t/ndb_cache.test
+10
-10
mysql-test/t/ndb_cache2.test
mysql-test/t/ndb_cache2.test
+10
-10
sql/ha_innodb.h
sql/ha_innodb.h
+4
-4
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+71
-51
sql/ha_ndbcluster.h
sql/ha_ndbcluster.h
+5
-5
sql/handler.h
sql/handler.h
+6
-5
sql/sql_cache.cc
sql/sql_cache.cc
+5
-4
No files found.
mysql-test/r/ndb_cache.result
View file @
e54ea918
...
@@ -36,22 +36,22 @@ Variable_name Value
...
@@ -36,22 +36,22 @@ Variable_name Value
Qcache_hits 1
Qcache_hits 1
insert into t1 value (2, 7, 8, 'Second row');
insert into t1 value (2, 7, 8, 'Second row');
insert into t1 value (4, 5, 6, 'Fourth row');
insert into t1 value (4, 5, 6, 'Fourth row');
select * from t1;
select * from t1
order by pk
;
pk a b c
pk a b c
1 3 3 First row
2 7 8 Second row
2 7 8 Second row
4 5 6 Fourth row
4 5 6 Fourth row
1 3 3 First row
show status like "Qcache_inserts";
show status like "Qcache_inserts";
Variable_name Value
Variable_name Value
Qcache_inserts 3
Qcache_inserts 3
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 1
Qcache_hits 1
select * from t1;
select * from t1
order by pk
;
pk a b c
pk a b c
1 3 3 First row
2 7 8 Second row
2 7 8 Second row
4 5 6 Fourth row
4 5 6 Fourth row
1 3 3 First row
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 2
Qcache_hits 2
...
@@ -81,10 +81,10 @@ show status like "Qcache_hits";
...
@@ -81,10 +81,10 @@ show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 3
Qcache_hits 3
use test;
use test;
select * from t1;
select * from t1
order by pk
;
pk a b c
pk a b c
2 7 8 Second row
1 3 3 First row
1 3 3 First row
2 7 8 Second row
select * from t1 where b=3;
select * from t1 where b=3;
pk a b c
pk a b c
1 3 3 First row
1 3 3 First row
...
@@ -96,11 +96,11 @@ use test;
...
@@ -96,11 +96,11 @@ use test;
show status like "Qcache_queries_in_cache";
show status like "Qcache_queries_in_cache";
Variable_name Value
Variable_name Value
Qcache_queries_in_cache 0
Qcache_queries_in_cache 0
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -110,11 +110,11 @@ Qcache_inserts 7
...
@@ -110,11 +110,11 @@ Qcache_inserts 7
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 5
Qcache_hits 5
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -138,7 +138,7 @@ Qcache_inserts 7
...
@@ -138,7 +138,7 @@ Qcache_inserts 7
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -161,7 +161,7 @@ Qcache_inserts 8
...
@@ -161,7 +161,7 @@ Qcache_inserts 8
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 5 3 First row
1 5 3 First row
...
@@ -171,7 +171,7 @@ Qcache_inserts 9
...
@@ -171,7 +171,7 @@ Qcache_inserts 9
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 5 3 First row
1 5 3 First row
...
...
mysql-test/r/ndb_cache2.result
View file @
e54ea918
...
@@ -37,10 +37,10 @@ Variable_name Value
...
@@ -37,10 +37,10 @@ Variable_name Value
Qcache_hits 1
Qcache_hits 1
insert into t1 value (2, 7, 8, 'Second row');
insert into t1 value (2, 7, 8, 'Second row');
insert into t1 value (4, 5, 6, 'Fourth row');
insert into t1 value (4, 5, 6, 'Fourth row');
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
4 5 6 Fourth row
4 5 6 Fourth row
2 7 8 Second row
1 3 3 First row
1 3 3 First row
show status like "Qcache_inserts";
show status like "Qcache_inserts";
Variable_name Value
Variable_name Value
...
@@ -48,10 +48,10 @@ Qcache_inserts 3
...
@@ -48,10 +48,10 @@ Qcache_inserts 3
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 1
Qcache_hits 1
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
4 5 6 Fourth row
4 5 6 Fourth row
2 7 8 Second row
1 3 3 First row
1 3 3 First row
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
...
@@ -82,7 +82,7 @@ show status like "Qcache_hits";
...
@@ -82,7 +82,7 @@ show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 3
Qcache_hits 3
use test;
use test;
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 3 3 First row
1 3 3 First row
...
@@ -97,11 +97,11 @@ use test;
...
@@ -97,11 +97,11 @@ use test;
show status like "Qcache_queries_in_cache";
show status like "Qcache_queries_in_cache";
Variable_name Value
Variable_name Value
Qcache_queries_in_cache 0
Qcache_queries_in_cache 0
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -111,11 +111,11 @@ Qcache_inserts 7
...
@@ -111,11 +111,11 @@ Qcache_inserts 7
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 5
Qcache_hits 5
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -139,7 +139,7 @@ Qcache_inserts 7
...
@@ -139,7 +139,7 @@ Qcache_inserts 7
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 4 3 First row
1 4 3 First row
...
@@ -162,7 +162,7 @@ Qcache_inserts 8
...
@@ -162,7 +162,7 @@ Qcache_inserts 8
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 5 3 First row
1 5 3 First row
...
@@ -172,7 +172,7 @@ Qcache_inserts 9
...
@@ -172,7 +172,7 @@ Qcache_inserts 9
show status like "Qcache_hits";
show status like "Qcache_hits";
Variable_name Value
Variable_name Value
Qcache_hits 7
Qcache_hits 7
select * from t1;
select * from t1
order by pk desc
;
pk a b c
pk a b c
2 7 8 Second row
2 7 8 Second row
1 5 3 First row
1 5 3 First row
...
...
mysql-test/t/ndb_cache.test
View file @
e54ea918
...
@@ -35,10 +35,10 @@ show status like "Qcache_hits";
...
@@ -35,10 +35,10 @@ show status like "Qcache_hits";
# Insert a new record and make sure the correct data is returned
# Insert a new record and make sure the correct data is returned
insert
into
t1
value
(
2
,
7
,
8
,
'Second row'
);
insert
into
t1
value
(
2
,
7
,
8
,
'Second row'
);
insert
into
t1
value
(
4
,
5
,
6
,
'Fourth row'
);
insert
into
t1
value
(
4
,
5
,
6
,
'Fourth row'
);
select
*
from
t1
;
select
*
from
t1
order
by
pk
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
# Perform a "new" query and make sure the query cache is not hit
# Perform a "new" query and make sure the query cache is not hit
...
@@ -60,7 +60,7 @@ show status like "Qcache_hits";
...
@@ -60,7 +60,7 @@ show status like "Qcache_hits";
connect
(
con1
,
localhost
,
root
,,);
connect
(
con1
,
localhost
,
root
,,);
connection
con1
;
connection
con1
;
use
test
;
use
test
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
;
select
*
from
t1
where
b
=
3
;
select
*
from
t1
where
b
=
3
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -70,13 +70,13 @@ connect (con2,localhost,root,,);
...
@@ -70,13 +70,13 @@ connect (con2,localhost,root,,);
connection
con2
;
connection
con2
;
use
test
;
use
test
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con1
;
connection
con1
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -92,7 +92,7 @@ show status like "Qcache_queries_in_cache";
...
@@ -92,7 +92,7 @@ show status like "Qcache_queries_in_cache";
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con2
;
connection
con2
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -103,11 +103,11 @@ show status like "Qcache_queries_in_cache";
...
@@ -103,11 +103,11 @@ show status like "Qcache_queries_in_cache";
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con2
;
connection
con2
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con1
;
connection
con1
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
...
mysql-test/t/ndb_cache2.test
View file @
e54ea918
...
@@ -41,10 +41,10 @@ show status like "Qcache_hits";
...
@@ -41,10 +41,10 @@ show status like "Qcache_hits";
# Insert a new record and make sure the correct data is returned
# Insert a new record and make sure the correct data is returned
insert
into
t1
value
(
2
,
7
,
8
,
'Second row'
);
insert
into
t1
value
(
2
,
7
,
8
,
'Second row'
);
insert
into
t1
value
(
4
,
5
,
6
,
'Fourth row'
);
insert
into
t1
value
(
4
,
5
,
6
,
'Fourth row'
);
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
# Perform a "new" query and make sure the query cache is not hit
# Perform a "new" query and make sure the query cache is not hit
...
@@ -66,7 +66,7 @@ show status like "Qcache_hits";
...
@@ -66,7 +66,7 @@ show status like "Qcache_hits";
connect
(
con1
,
localhost
,
root
,,);
connect
(
con1
,
localhost
,
root
,,);
connection
con1
;
connection
con1
;
use
test
;
use
test
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
select
*
from
t1
where
b
=
3
;
select
*
from
t1
where
b
=
3
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -76,13 +76,13 @@ connect (con2,localhost,root,,);
...
@@ -76,13 +76,13 @@ connect (con2,localhost,root,,);
connection
con2
;
connection
con2
;
use
test
;
use
test
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con1
;
connection
con1
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -95,7 +95,7 @@ show status like "Qcache_queries_in_cache";
...
@@ -95,7 +95,7 @@ show status like "Qcache_queries_in_cache";
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con2
;
connection
con2
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
@@ -107,11 +107,11 @@ show status like "Qcache_queries_in_cache";
...
@@ -107,11 +107,11 @@ show status like "Qcache_queries_in_cache";
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con2
;
connection
con2
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
connection
con1
;
connection
con1
;
select
*
from
t1
;
select
*
from
t1
order
by
pk
desc
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_queries_in_cache"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_inserts"
;
show
status
like
"Qcache_hits"
;
show
status
like
"Qcache_hits"
;
...
...
sql/ha_innodb.h
View file @
e54ea918
...
@@ -180,10 +180,10 @@ class ha_innobase: public handler
...
@@ -180,10 +180,10 @@ class ha_innobase: public handler
/*
/*
ask handler about permission to cache table during query registration
ask handler about permission to cache table during query registration
*/
*/
my_bool
cached_table_registration
(
THD
*
thd
,
char
*
table_key
,
my_bool
register_query_cache_table
(
THD
*
thd
,
char
*
table_key
,
uint
key_length
,
uint
key_length
,
qc_engine_callback
*
call_back
,
qc_engine_callback
*
call_back
,
ulonglong
*
engine_data
)
ulonglong
*
engine_data
)
{
{
*
call_back
=
innobase_query_caching_of_table_permitted
;
*
call_back
=
innobase_query_caching_of_table_permitted
;
*
engine_data
=
0
;
*
engine_data
=
0
;
...
...
sql/ha_ndbcluster.cc
View file @
e54ea918
...
@@ -4026,7 +4026,6 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
...
@@ -4026,7 +4026,6 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_force_send
(
TRUE
),
m_force_send
(
TRUE
),
m_autoincrement_prefetch
(
32
),
m_autoincrement_prefetch
(
32
),
m_transaction_on
(
TRUE
),
m_transaction_on
(
TRUE
),
m_use_local_query_cache
(
FALSE
),
m_multi_cursor
(
NULL
)
m_multi_cursor
(
NULL
)
{
{
int
i
;
int
i
;
...
@@ -4820,31 +4819,48 @@ uint ndb_get_commitcount(THD* thd, char* dbname, char* tabname,
...
@@ -4820,31 +4819,48 @@ uint ndb_get_commitcount(THD* thd, char* dbname, char* tabname,
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
ndb
->
setDatabaseName
(
dbname
);
ndb
->
setDatabaseName
(
dbname
);
if
(
ndb_get_table_statistics
(
ndb
,
tabname
,
0
,
commit_count
))
struct
Ndb_statistics
stat
;
if
(
ndb_get_table_statistics
(
ndb
,
tabname
,
&
stat
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
*
commit_count
=
stat
.
commit_count
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
static
/*
my_bool
Check if a cached query can be used.
ndbcluster_cache_retrieval_allowed
(
This is done by comparing the supplied engine_data to commit_count of
/*======================================*/
the table.
/* out: TRUE if permitted, FALSE if not;
The commit_count is either retrieved from the share for the table, where
note that the value FALSE means invalidation
it has been cached by the util thread. If the util thread is not started,
of query cache if *engine_data is changed */
NDB has to be contacetd to retrieve the commit_count, this will introduce
THD
*
thd
,
/* in: thd of the user who is trying to
a small delay while waiting for NDB to answer.
store a result to the query cache or
retrieve it */
char
*
full_name
,
/* in: concatenation of database name,
SYNOPSIS
the null character '\0', and the table
ndbcluster_cache_retrieval_allowed
name */
thd thread handle
uint
full_name_len
,
/* in: length of the full name, i.e.
full_name concatenation of database name,
len(dbname) + len(tablename) + 1 */
the null character '\0', and the table
ulonglong
*
engine_data
)
/* in: value set in call to
name
ha_ndbcluster::cached_table_registration
full_name_len length of the full name,
out: if return FALSE this is used to invalidate
i.e. len(dbname) + len(tablename) + 1
all cached queries with this table*/
engine_data parameter retrieved when query was first inserted into
the cache. If the value of engine_data is changed,
all queries for this table should be invalidated.
RETURN VALUE
TRUE Yes, use the query from cache
FALSE No, don't use the cached query, and if engine_data
has changed, all queries for this table should be invalidated
*/
static
my_bool
ndbcluster_cache_retrieval_allowed
(
THD
*
thd
,
char
*
full_name
,
uint
full_name_len
,
ulonglong
*
engine_data
)
{
{
DBUG_ENTER
(
"ndbcluster_cache_retrieval_allowed"
);
DBUG_ENTER
(
"ndbcluster_cache_retrieval_allowed"
);
...
@@ -4861,7 +4877,7 @@ ndbcluster_cache_retrieval_allowed(
...
@@ -4861,7 +4877,7 @@ ndbcluster_cache_retrieval_allowed(
if
(
ndb_get_commitcount
(
thd
,
dbname
,
tabname
,
&
commit_count
))
if
(
ndb_get_commitcount
(
thd
,
dbname
,
tabname
,
&
commit_count
))
{
{
*
engine_data
=
*
engine_data
+
1
;
// invalidate
*
engine_data
+=
1
;
// invalidate
DBUG_RETURN
(
FALSE
);
DBUG_RETURN
(
FALSE
);
}
}
DBUG_PRINT
(
"info"
,
(
"*engine_data=%llu, commit_count=%llu"
,
DBUG_PRINT
(
"info"
,
(
"*engine_data=%llu, commit_count=%llu"
,
...
@@ -4877,27 +4893,36 @@ ndbcluster_cache_retrieval_allowed(
...
@@ -4877,27 +4893,36 @@ ndbcluster_cache_retrieval_allowed(
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
/**
Register a table for use in the query cache. Fetch the commit_count
for the table and return it in engine_data, this will later be used
to check if the table has changed, before the cached query is reused.
SYNOPSIS
ha_ndbcluster::can_query_cache_table
thd thread handle
full_name concatenation of database name,
the null character '\0', and the table
name
full_name_len length of the full name,
i.e. len(dbname) + len(tablename) + 1
qc_engine_callback function to be called before using cache on this table
engine_data out, commit_count for this table
RETURN VALUE
TRUE Yes, it's ok to cahce this query
FALSE No, don't cach the query
*/
my_bool
my_bool
ha_ndbcluster
::
cached_table_registration
(
ha_ndbcluster
::
register_query_cache_table
(
THD
*
thd
,
/*======================================*/
char
*
full_name
,
uint
full_name_len
,
/* out: TRUE if permitted, FALSE if not;
qc_engine_callback
*
engine_callback
,
note that the value FALSE means invalidation
ulonglong
*
engine_data
)
of query cache if *engine_data is changed */
{
THD
*
thd
,
/* in: thd of the user who is trying to
DBUG_ENTER
(
"ha_ndbcluster::register_query_cache_table"
);
store a result to the query cache or
retrieve it */
char
*
full_name
,
/* in: concatenation of database name,
the null character '\0', and the table
name */
uint
full_name_len
,
/* in: length of the full name, i.e.
len(dbname) + len(tablename) + 1 */
qc_engine_callback
*
engine_callback
,
/* out: function to be called before using
cache on this table */
ulonglong
*
engine_data
)
/* out: if return FALSE this is used to
invalidate all cached queries with this table*/
{
DBUG_ENTER
(
"ha_ndbcluster::cached_table_registration"
);
bool
is_autocommit
=
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
));
bool
is_autocommit
=
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
));
DBUG_PRINT
(
"enter"
,(
"dbname=%s, tabname=%s, is_autocommit=%d"
,
DBUG_PRINT
(
"enter"
,(
"dbname=%s, tabname=%s, is_autocommit=%d"
,
...
@@ -5139,10 +5164,6 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
...
@@ -5139,10 +5164,6 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
pOp
->
close
(
TRUE
);
pOp
->
close
(
TRUE
);
ndb
->
closeTransaction
(
pTrans
);
ndb
->
closeTransaction
(
pTrans
);
if
(
row_count
)
*
row_count
=
sum_rows
;
if
(
commit_count
)
*
commit_count
=
sum_commits
;
ndbstat
->
row_count
=
sum_rows
;
ndbstat
->
row_count
=
sum_rows
;
ndbstat
->
commit_count
=
sum_commits
;
ndbstat
->
commit_count
=
sum_commits
;
...
@@ -5662,13 +5683,12 @@ extern "C" pthread_handler_decl(ndb_util_thread_func,arg __attribute__((unused))
...
@@ -5662,13 +5683,12 @@ extern "C" pthread_handler_decl(ndb_util_thread_func,arg __attribute__((unused))
// Contact NDB to get commit count for table
// Contact NDB to get commit count for table
g_ndb
->
setDatabaseName
(
db
);
g_ndb
->
setDatabaseName
(
db
);
Uint64
rows
,
commit_count
;
struct
Ndb_statistics
stat
;;
if
(
ndb_get_table_statistics
(
g_ndb
,
tabname
,
if
(
ndb_get_table_statistics
(
g_ndb
,
tabname
,
&
stat
)
==
0
){
&
rows
,
&
commit_count
)
==
0
){
DBUG_PRINT
(
"ndb_util_thread"
,
DBUG_PRINT
(
"ndb_util_thread"
,
(
"Table: %s, rows: %llu, commit_count: %llu"
,
(
"Table: %s, rows: %llu, commit_count: %llu"
,
share
->
table_name
,
rows
,
commit_count
));
share
->
table_name
,
stat
.
row_count
,
stat
.
commit_count
));
share
->
commit_count
=
commit_count
;
share
->
commit_count
=
stat
.
commit_count
;
}
}
else
else
{
{
...
...
sql/ha_ndbcluster.h
View file @
e54ea918
...
@@ -157,11 +157,11 @@ class ha_ndbcluster: public handler
...
@@ -157,11 +157,11 @@ class ha_ndbcluster: public handler
static
Thd_ndb
*
seize_thd_ndb
();
static
Thd_ndb
*
seize_thd_ndb
();
static
void
release_thd_ndb
(
Thd_ndb
*
thd_ndb
);
static
void
release_thd_ndb
(
Thd_ndb
*
thd_ndb
);
uint8
table_cache_type
();
uint8
table_cache_type
();
my_bool
cached_table_registration
(
THD
*
thd
,
char
*
table_key
,
my_bool
register_query_cache_table
(
THD
*
thd
,
char
*
table_key
,
uint
key_length
,
uint
key_length
,
qc_engine_callback
*
engine_callback
,
qc_engine_callback
*
engine_callback
,
ulonglong
*
engine_data
);
ulonglong
*
engine_data
);
private:
private:
int
alter_table_name
(
const
char
*
to
);
int
alter_table_name
(
const
char
*
to
);
int
drop_table
();
int
drop_table
();
int
create_index
(
const
char
*
name
,
KEY
*
key_info
,
bool
unique
);
int
create_index
(
const
char
*
name
,
KEY
*
key_info
,
bool
unique
);
...
...
sql/handler.h
View file @
e54ea918
...
@@ -592,11 +592,12 @@ public:
...
@@ -592,11 +592,12 @@ public:
/* Type of table for caching query */
/* Type of table for caching query */
virtual
uint8
table_cache_type
()
{
return
HA_CACHE_TBL_NONTRANSACT
;
}
virtual
uint8
table_cache_type
()
{
return
HA_CACHE_TBL_NONTRANSACT
;
}
/* ask handler about permission to cache table during query registration */
/* ask handler about permission to cache table when query is to be cached */
virtual
my_bool
cached_table_registration
(
THD
*
thd
,
char
*
table_key
,
virtual
my_bool
register_query_cache_table
(
THD
*
thd
,
char
*
table_key
,
uint
key_length
,
uint
key_length
,
qc_engine_callback
*
engine_callback
,
qc_engine_callback
ulonglong
*
engine_data
)
*
engine_callback
,
ulonglong
*
engine_data
)
{
{
*
engine_callback
=
0
;
*
engine_callback
=
0
;
return
1
;
return
1
;
...
...
sql/sql_cache.cc
View file @
e54ea918
...
@@ -2770,10 +2770,11 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
...
@@ -2770,10 +2770,11 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
for
(;
tables_used
;
tables_used
=
tables_used
->
next_global
)
for
(;
tables_used
;
tables_used
=
tables_used
->
next_global
)
{
{
TABLE
*
table
=
tables_used
->
table
;
TABLE
*
table
=
tables_used
->
table
;
if
(
!
handler
->
cached_table_registration
(
thd
,
table
->
s
->
table_cache_key
,
handler
*
handler
=
table
->
file
;
table
->
s
->
key_length
,
if
(
!
handler
->
register_query_cache_table
(
thd
,
table
->
s
->
table_cache_key
,
&
tables_used
->
callback_func
,
table
->
s
->
key_length
,
&
tables_used
->
engine_data
))
&
tables_used
->
callback_func
,
&
tables_used
->
engine_data
))
{
{
DBUG_PRINT
(
"qcache"
,
(
"Handler does not allow caching for %s.%s"
,
DBUG_PRINT
(
"qcache"
,
(
"Handler does not allow caching for %s.%s"
,
tables_used
->
db
,
tables_used
->
alias
));
tables_used
->
db
,
tables_used
->
alias
));
...
...
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