Commit da440a0b authored by unknown's avatar unknown

Merge of query cache from 4.1 to 5.0


mysql-test/r/ndb_cache.result:
  Added 'order by' to select's
mysql-test/r/ndb_cache2.result:
  Added 'order by' to select's
mysql-test/t/ndb_cache.test:
  Added 'order by' to select's
mysql-test/t/ndb_cache2.test:
  Added 'order by' to select's
sql/ha_innodb.h:
  Changed function name
sql/ha_ndbcluster.cc:
  Merge from query cache from 4.1 to 5.0
  Added better comments
  ndb_get_table_statistics had changed, so there where some adaptions to make
sql/ha_ndbcluster.h:
  Changed name of function
sql/handler.h:
  Changed name of function
sql/sql_cache.cc:
  Changed name of function
parent 62a0af01
...@@ -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
......
...@@ -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
......
...@@ -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";
......
...@@ -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";
......
...@@ -180,7 +180,7 @@ class ha_innobase: public handler ...@@ -180,7 +180,7 @@ 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)
......
...@@ -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
ndbcluster_cache_retrieval_allowed
thd thread handle
full_name concatenation of database name,
the null character '\0', and the table the null character '\0', and the table
name */ name
uint full_name_len, /* in: length of the full name, i.e. full_name_len length of the full name,
len(dbname) + len(tablename) + 1 */ i.e. len(dbname) + len(tablename) + 1
ulonglong *engine_data) /* in: value set in call to
ha_ndbcluster::cached_table_registration engine_data parameter retrieved when query was first inserted into
out: if return FALSE this is used to invalidate the cache. If the value of engine_data is changed,
all cached queries with this table*/ 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);
} }
my_bool
ha_ndbcluster::cached_table_registration( /**
/*======================================*/ Register a table for use in the query cache. Fetch the commit_count
/* out: TRUE if permitted, FALSE if not; for the table and return it in engine_data, this will later be used
note that the value FALSE means invalidation to check if the table has changed, before the cached query is reused.
of query cache if *engine_data is changed */
THD* thd, /* in: thd of the user who is trying to SYNOPSIS
store a result to the query cache or ha_ndbcluster::can_query_cache_table
retrieve it */ thd thread handle
char* full_name, /* in: concatenation of database name, full_name concatenation of database name,
the null character '\0', and the table the null character '\0', and the table
name */ name
uint full_name_len, /* in: length of the full name, i.e. full_name_len length of the full name,
len(dbname) + len(tablename) + 1 */ i.e. len(dbname) + len(tablename) + 1
qc_engine_callback qc_engine_callback function to be called before using cache on this table
*engine_callback, /* out: function to be called before using engine_data out, commit_count for this table
cache on this table */
ulonglong *engine_data) /* out: if return FALSE this is used to RETURN VALUE
invalidate all cached queries with this table*/ TRUE Yes, it's ok to cahce this query
FALSE No, don't cach the query
*/
my_bool
ha_ndbcluster::register_query_cache_table(THD* thd,
char* full_name, uint full_name_len,
qc_engine_callback *engine_callback,
ulonglong *engine_data)
{ {
DBUG_ENTER("ha_ndbcluster::cached_table_registration"); DBUG_ENTER("ha_ndbcluster::register_query_cache_table");
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
{ {
......
...@@ -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);
......
...@@ -592,10 +592,11 @@ class handler :public Sql_alloc ...@@ -592,10 +592,11 @@ class handler :public Sql_alloc
/* 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
*engine_callback,
ulonglong *engine_data) ulonglong *engine_data)
{ {
*engine_callback= 0; *engine_callback= 0;
......
...@@ -2770,7 +2770,8 @@ my_bool Query_cache::ask_handler_allowance(THD *thd, ...@@ -2770,7 +2770,8 @@ 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;
if (!handler->register_query_cache_table(thd, table->s->table_cache_key,
table->s->key_length, table->s->key_length,
&tables_used->callback_func, &tables_used->callback_func,
&tables_used->engine_data)) &tables_used->engine_data))
......
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