1901
1901
NULL /* config options */
1903
1903
mysql_declare_plugin_end;
1906
#ifdef HAVE_QUERY_CACHE
1908
@brief Register a named table with a call back function to the query cache.
1910
@param thd The thread handle
1911
@param table_key A pointer to the table name in the table cache
1912
@param key_length The length of the table name
1913
@param[out] engine_callback The pointer to the storage engine call back
1914
function, currently 0
1915
@param[out] engine_data Engine data will be set to 0.
1917
@note Despite the name of this function, it is used to check each statement
1918
before it is cached and not to register a table or callback function.
1920
@see handler::register_query_cache_table
1922
@return The error code. The engine_data and engine_callback will be set to 0.
1923
@retval true Success
1924
@retval false An error occured
1927
my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
1928
uint table_name_len,
1931
uint64_t *engine_data)
1934
No call back function is needed to determine if a cached statement
1937
*engine_callback= 0;
1940
No engine data is needed.
1944
if (file->s->concurrent_insert)
1947
If a concurrent INSERT has happened just before the currently
1948
processed SELECT statement, the total size of the table is
1951
To determine if the table size is known, the current thread's snap
1952
shot of the table size with the actual table size are compared.
1954
If the table size is unknown the SELECT statement can't be cached.
1956
When concurrent inserts are disabled at table open, mi_open()
1957
does not assign a get_status() function. In this case the local
1958
("current") status is never updated. We would wrongly think that
1959
we cannot cache the statement.
1961
uint64_t actual_data_file_length;
1962
uint64_t current_data_file_length;
1965
POSIX visibility rules specify that "2. Whatever memory values a
1966
thread can see when it unlocks a mutex <...> can also be seen by any
1967
thread that later locks the same mutex". In this particular case,
1968
concurrent insert thread had modified the data_file_length in
1969
MYISAM_SHARE before it has unlocked (or even locked)
1970
structure_guard_mutex. So, here we're guaranteed to see at least that
1971
value after we've locked the same mutex. We can see a later value
1972
(modified by some other thread) though, but it's ok, as we only want
1973
to know if the variable was changed, the actual new value doesn't matter
1975
actual_data_file_length= file->s->state.state.data_file_length;
1976
current_data_file_length= file->save_state.data_file_length;
1978
if (current_data_file_length != actual_data_file_length)
1980
/* Don't cache current statement. */
1985
/* It is ok to try to cache current statement. */