diff options
author | unknown <thek@adventure.(none)> | 2007-07-12 15:30:34 +0200 |
---|---|---|
committer | unknown <thek@adventure.(none)> | 2007-07-12 15:30:34 +0200 |
commit | 5ee37c143924ef853f5c603c1110d143835f02df (patch) | |
tree | dc4dd71b27761b64dbdb9547e84a618fab3f35b9 /sql/ha_myisam.cc | |
parent | a64be676a4cd799c7b7259d950df7040879a8889 (diff) | |
parent | 30810f80b1070cbfd4579835353bb6e84fd1b233 (diff) | |
download | mariadb-git-5ee37c143924ef853f5c603c1110d143835f02df.tar.gz |
Merge adventure.(none):/home/thek/Development/cpp/bug28249/my50-bug28249
into adventure.(none):/home/thek/Development/cpp/mysql-5.0-runtime
mysql-test/t/query_cache.test:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/handler.h:
Auto merged
mysql-test/r/query_cache.result:
SCCS merged
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r-- | sql/ha_myisam.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 5e953092436..18c9e6feb34 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1921,3 +1921,77 @@ uint ha_myisam::checksum() const return (uint)file->state->checksum; } +#ifdef HAVE_QUERY_CACHE +/** + @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, currently 0 + @param[out] engine_data Engine data will be set to 0. + + @note Despite the name of this function, it is used to check each statement + before it is cached and not to register a table or callback function. + + @see handler::register_query_cache_table + + @return The error code. The engine_data and engine_callback will be set to 0. + @retval TRUE Success + @retval FALSE An error occured +*/ + +my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name, + uint table_name_len, + qc_engine_callback + *engine_callback, + ulonglong *engine_data) +{ + /* + No call back function is needed to determine if a cached statement + is valid or not. + */ + *engine_callback= 0; + + /* + No engine data is needed. + */ + *engine_data= 0; + + /* + If a concurrent INSERT has happened just before the currently processed + SELECT statement, the total size of the table is unknown. + + To determine if the table size is known, the current thread's snap shot of + the table size with the actual table size are compared. + + If the table size is unknown the SELECT statement can't be cached. + */ + ulonglong actual_data_file_length; + ulonglong current_data_file_length; + + /* + POSIX visibility rules specify that "2. Whatever memory values a + thread can see when it unlocks a mutex <...> can also be seen by any + thread that later locks the same mutex". In this particular case, + concurrent insert thread had modified the data_file_length in + MYISAM_SHARE before it has unlocked (or even locked) + structure_guard_mutex. So, here we're guaranteed to see at least that + value after we've locked the same mutex. We can see a later value + (modified by some other thread) though, but it's ok, as we only want + to know if the variable was changed, the actual new value doesn't matter + */ + actual_data_file_length= file->s->state.state.data_file_length; + current_data_file_length= file->save_state.data_file_length; + + if (current_data_file_length != actual_data_file_length) + { + /* Don't cache current statement. */ + return FALSE; + } + + /* It is ok to try to cache current statement. */ + return TRUE; +} +#endif |