~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/ha_myisam.cc

Removed old test scripts and source files from Makefile and directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1901
1901
  NULL                        /* config options                  */
1902
1902
}
1903
1903
mysql_declare_plugin_end;
1904
 
 
1905
 
 
1906
 
#ifdef HAVE_QUERY_CACHE
1907
 
/**
1908
 
  @brief Register a named table with a call back function to the query cache.
1909
 
 
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.
1916
 
 
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.
1919
 
 
1920
 
  @see handler::register_query_cache_table
1921
 
 
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
1925
 
*/
1926
 
 
1927
 
my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
1928
 
                                              uint table_name_len,
1929
 
                                              qc_engine_callback
1930
 
                                              *engine_callback,
1931
 
                                              uint64_t *engine_data)
1932
 
{
1933
 
  /*
1934
 
    No call back function is needed to determine if a cached statement
1935
 
    is valid or not.
1936
 
  */
1937
 
  *engine_callback= 0;
1938
 
 
1939
 
  /*
1940
 
    No engine data is needed.
1941
 
  */
1942
 
  *engine_data= 0;
1943
 
 
1944
 
  if (file->s->concurrent_insert)
1945
 
  {
1946
 
    /*
1947
 
      If a concurrent INSERT has happened just before the currently
1948
 
      processed SELECT statement, the total size of the table is
1949
 
      unknown.
1950
 
 
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.
1953
 
 
1954
 
      If the table size is unknown the SELECT statement can't be cached.
1955
 
 
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.
1960
 
    */
1961
 
    uint64_t actual_data_file_length;
1962
 
    uint64_t current_data_file_length;
1963
 
 
1964
 
    /*
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
1974
 
    */
1975
 
    actual_data_file_length= file->s->state.state.data_file_length;
1976
 
    current_data_file_length= file->save_state.data_file_length;
1977
 
 
1978
 
    if (current_data_file_length != actual_data_file_length)
1979
 
    {
1980
 
      /* Don't cache current statement. */
1981
 
      return(false);
1982
 
    }
1983
 
  }
1984
 
 
1985
 
  /* It is ok to try to cache current statement. */
1986
 
  return(true);
1987
 
}
1988
 
#endif