summaryrefslogtreecommitdiff
path: root/sql/ha_myisam.cc
diff options
context:
space:
mode:
authorChad MILLER <chad@mysql.com>2008-07-10 14:50:07 -0400
committerChad MILLER <chad@mysql.com>2008-07-10 14:50:07 -0400
commitc425bf421da9ffa55d3d568f70508fa12dd07aa0 (patch)
tree667c2782c7fcee247010d3413aaf80a81fc6dd92 /sql/ha_myisam.cc
parent6a6e77eeffc7dbd72888ef685fdb93fc2ae7aed6 (diff)
parent0db1f520c629455b4766c3d8f57a9767d7f6a98f (diff)
downloadmariadb-git-c425bf421da9ffa55d3d568f70508fa12dd07aa0.tar.gz
Merge chunk from trunk.
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r--sql/ha_myisam.cc64
1 files changed, 37 insertions, 27 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 382fbc18667..5ed791d0f68 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -1954,6 +1954,7 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
*engine_callback,
ulonglong *engine_data)
{
+ DBUG_ENTER("ha_myisam::register_query_cache_table");
/*
No call back function is needed to determine if a cached statement
is valid or not.
@@ -1965,39 +1966,48 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
*/
*engine_data= 0;
- /*
- If a concurrent INSERT has happened just before the currently processed
- SELECT statement, the total size of the table is unknown.
+ if (file->s->concurrent_insert)
+ {
+ /*
+ 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.
+ 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;
+ If the table size is unknown the SELECT statement can't be cached.
- /*
- 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;
+ When concurrent inserts are disabled at table open, mi_open()
+ does not assign a get_status() function. In this case the local
+ ("current") status is never updated. We would wrongly think that
+ we cannot cache the statement.
+ */
+ ulonglong actual_data_file_length;
+ ulonglong current_data_file_length;
- if (current_data_file_length != actual_data_file_length)
- {
- /* Don't cache current statement. */
- return FALSE;
+ /*
+ 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. */
+ DBUG_RETURN(FALSE);
+ }
}
/* It is ok to try to cache current statement. */
- return TRUE;
+ DBUG_RETURN(TRUE);
}
#endif