1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock

A race condition in the integration between MyISAM and the query cache code 
caused the query cache to fail to invalidate itself on concurrently inserted
data.

This patch fix this problem by using the existing handler interface which, upon
each statement cache attempt, compare the size of the table as viewed from the 
cache writing thread and with any snap shot of the global table state. If the
two sizes are different the global table size is unknown and the current
statement can't be cached.


mysql-test/r/query_cache.result:
  Added test case
mysql-test/t/query_cache.test:
  Added test case
sql/ha_myisam.cc:
  - Implemented handler interface for ha_myisam class to dermine if the table
   belonging to the currently processed statement can be cached or not.
sql/ha_myisam.h:
  - Implemented handler interface for ha_myisam class to dermine if the table
   belonging to the currently processed statement can be cached or not.
sql/handler.h:
  - Documented register_query_cache_table method in the handler interface.
This commit is contained in:
unknown
2007-07-12 13:29:51 +02:00
parent 7c70011e21
commit 30810f80b1
5 changed files with 232 additions and 6 deletions

View File

@@ -841,16 +841,49 @@ public:
/* Type of table for caching query */
virtual uint8 table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
/* ask handler about permission to cache table when query is to be cached */
/**
@brief Register a named table with a call back function to the query cache.
@param thd The thread handle
@param table_key A pointer to the table name in the table cache
@param key_length The length of the table name
@param[out] engine_callback The pointer to the storage engine call back
function
@param[out] engine_data Storage engine specific data which could be
anything
This method offers the storage engine, the possibility to store a reference
to a table name which is going to be used with query cache.
The method is called each time a statement is written to the cache and can
be used to verify if a specific statement is cachable. It also offers
the possibility to register a generic (but static) call back function which
is called each time a statement is matched against the query cache.
@note If engine_data supplied with this function is different from
engine_data supplied with the callback function, and the callback returns
FALSE, a table invalidation on the current table will occur.
@return Upon success the engine_callback will point to the storage engine
call back function, if any, and engine_data will point to any storage
engine data used in the specific implementation.
@retval TRUE Success
@retval FALSE The specified table or current statement should not be
cached
*/
virtual my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length,
qc_engine_callback
*engine_callback,
ulonglong *engine_data)
uint key_length,
qc_engine_callback
*engine_callback,
ulonglong *engine_data)
{
*engine_callback= 0;
return 1;
return TRUE;
}
/*
RETURN
true Primary key (if there is one) is clustered key covering all fields