diff options
author | unknown <bell@sanja.is.com.ua> | 2002-09-19 10:36:19 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-09-19 10:36:19 +0300 |
commit | 8ff9e7089f7e73ad53ed745ca4cf58aa19d911a0 (patch) | |
tree | 823169d867628a7dd6c4c1867fb1cabe1d179509 | |
parent | 2ba53ba51b673d3408c28c8644c7c55d7a6ae25d (diff) | |
download | mariadb-git-8ff9e7089f7e73ad53ed745ca4cf58aa19d911a0.tar.gz |
new function for innodb
windows case insensitive tables name work around
sql/sql_cache.h:
new function for innodb
sql/sql_class.cc:
new query cache invalidation function support
sql/sql_class.h:
new query cache invalidation function support
-rw-r--r-- | sql/sql_cache.cc | 40 | ||||
-rw-r--r-- | sql/sql_cache.h | 2 | ||||
-rw-r--r-- | sql/sql_class.cc | 31 | ||||
-rw-r--r-- | sql/sql_class.h | 3 |
4 files changed, 56 insertions, 20 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 1acdc3149ab..c93ed308ecf 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -708,11 +708,11 @@ Query_cache::Query_cache(ulong query_cache_limit, def_table_hash_size(ALIGN_SIZE(def_table_hash_size)), initialized(0) { - ulong min_needed=(ALIGN_SIZE(sizeof(Query_cache_block)) + - ALIGN_SIZE(sizeof(Query_cache_block_table)) + - ALIGN_SIZE(sizeof(Query_cache_query)) + 3); + ulong min_needed= (ALIGN_SIZE(sizeof(Query_cache_block)) + + ALIGN_SIZE(sizeof(Query_cache_block_table)) + + ALIGN_SIZE(sizeof(Query_cache_query)) + 3); set_if_bigger(min_allocation_unit,min_needed); - this->min_allocation_unit = ALIGN_SIZE(min_allocation_unit); + this->min_allocation_unit= ALIGN_SIZE(min_allocation_unit); set_if_bigger(this->min_result_data_size,min_allocation_unit); } @@ -723,7 +723,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size, query_cache_size_arg)); free_cache(0); - query_cache_size=query_cache_size_arg; + query_cache_size= query_cache_size_arg; DBUG_RETURN(init_cache()); } @@ -1104,6 +1104,28 @@ void Query_cache::invalidate(THD *thd, TABLE *table, DBUG_VOID_RETURN; } +void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length, + my_bool using_transactions) +{ + DBUG_ENTER("Query_cache::invalidate (key)"); + + if (query_cache_size > 0) + { + using_transactions = using_transactions && + (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)); + if (using_transactions) // used for innodb => has_transactions() is TRUE + thd->add_changed_table(key, key_length); + else + { + STRUCT_LOCK(&structure_guard_mutex); + if (query_cache_size > 0) + invalidate_table((byte*)key, key_length); + STRUCT_UNLOCK(&structure_guard_mutex); + } + } + DBUG_VOID_RETURN; +} + /* Remove all cached queries that uses the given database */ @@ -1356,8 +1378,15 @@ ulong Query_cache::init_cache() VOID(hash_init(&queries,def_query_hash_size, 0, 0, query_cache_query_get_key, 0, 0)); +#ifndef __WIN__ VOID(hash_init(&tables,def_table_hash_size, 0, 0, query_cache_table_get_key, 0, 0)); +#else + // windows case insensitive file names work around + VOID(hash_init(&tables,def_table_hash_size, 0, 0, + query_cache_table_get_key, 0, + (lower_case_table_names?0:HASH_CASE_INSENSITIVE))); +#endif queries_in_cache = 0; queries_blocks = 0; @@ -2828,7 +2857,6 @@ uint Query_cache::filename_2_table_key (char *key, const char *path, filename) -key) + 1); } - /**************************************************************************** Functions to be used when debugging ****************************************************************************/ diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 3088331f19a..52d2e8998a7 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -361,6 +361,8 @@ protected: my_bool using_transactions); void invalidate(CHANGED_TABLE_LIST *tables_used); void invalidate(THD* thd, TABLE *table, my_bool using_transactions); + void invalidate(THD *thd, const char *key, uint32 key_length, + my_bool using_transactions); /* Remove all queries that uses any of the tables in following database */ void invalidate(char *db); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a0dc8253ea4..02cf8a73c08 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -301,28 +301,33 @@ void THD::add_changed_table(TABLE *table) DBUG_ASSERT((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && table->file->has_transactions()); + DBUG_RETURN(add_changed_table(table->table_cache_key, table->key_length)); +} +void THD::add_changed_table(const char *key, long key_length) +{ + DBUG_ENTER("THD::add_changed_table(key)"); CHANGED_TABLE_LIST** prev = &transaction.changed_tables; CHANGED_TABLE_LIST* curr = transaction.changed_tables; for (; curr; prev = &(curr->next), curr = curr->next) { - int cmp = (long)curr->key_length - (long)table->key_length; + int cmp = (long)curr->key_length - (long)key_length; if (cmp < 0) { - list_include(prev, curr, changed_table_dup(table)); + list_include(prev, curr, changed_table_dup(key, key_length)); DBUG_PRINT("info", - ("key_length %u %u", table->key_length, (*prev)->key_length)); + ("key_length %u %u", key_length, (*prev)->key_length)); DBUG_VOID_RETURN; } else if (cmp == 0) { - cmp = memcmp(curr->key ,table->table_cache_key, curr->key_length); + cmp = memcmp(curr->key, key, curr->key_length); if (cmp < 0) { - list_include(prev, curr, changed_table_dup(table)); + list_include(prev, curr, changed_table_dup(key, key_length)); DBUG_PRINT("info", - ("key_length %u %u", table->key_length, + ("key_length %u %u", key_length, (*prev)->key_length)); DBUG_VOID_RETURN; } @@ -333,22 +338,22 @@ void THD::add_changed_table(TABLE *table) } } } - *prev = changed_table_dup(table); - DBUG_PRINT("info", ("key_length %u %u", table->key_length, + *prev = changed_table_dup(key, key_length); + DBUG_PRINT("info", ("key_length %u %u", key_length, (*prev)->key_length)); DBUG_VOID_RETURN; } -CHANGED_TABLE_LIST* THD::changed_table_dup(TABLE *table) +CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length) { CHANGED_TABLE_LIST* new_table = (CHANGED_TABLE_LIST*) trans_alloc(ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST))+ - table->key_length + 1); + key_length + 1); if (!new_table) { my_error(EE_OUTOFMEMORY, MYF(ME_BELL), - ALIGN_SIZE(sizeof(TABLE_LIST)) + table->key_length + 1); + ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1); killed= 1; return 0; } @@ -356,8 +361,8 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(TABLE *table) new_table->key = (char *) (((byte*)new_table)+ ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST))); new_table->next = 0; - new_table->key_length = table->key_length; - ::memcpy(new_table->key, table->table_cache_key, table->key_length); + new_table->key_length = key_length; + ::memcpy(new_table->key, key, key_length); return new_table; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 3a2d9779eab..c161b25b4c5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -550,7 +550,8 @@ public: return alloc_root(&transaction.mem_root,size); } void add_changed_table(TABLE *table); - CHANGED_TABLE_LIST * changed_table_dup(TABLE *table); + void add_changed_table(const char *key, long key_length); + CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length); }; /* |