diff options
author | monty@mysql.com <> | 2003-12-17 17:35:34 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2003-12-17 17:35:34 +0200 |
commit | e0cc6799ecc831d296c568c5068947c1421fcaa5 (patch) | |
tree | 93924b5aab311e02a0f0931cf91e67cdfad04bdf /sql/sql_cache.cc | |
parent | 0462f48b344633c7d88d12d9667f4bd50b91c552 (diff) | |
parent | 30e318311b35b109d230f7184fe0be1b6e29f02b (diff) | |
download | mariadb-git-e0cc6799ecc831d296c568c5068947c1421fcaa5.tar.gz |
Merge with 4.0.17
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 396764cd532..71dd7123d98 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1206,9 +1206,29 @@ void Query_cache::invalidate(char *db) if (query_cache_size > 0) { DUMP(this); - /* invalidate_table reduce list while only root of list remain */ - while (tables_blocks !=0 ) - invalidate_table(tables_blocks); + restart_search: + if (tables_blocks) + { + Query_cache_block *curr= tables_blocks; + Query_cache_block *next; + do + { + next= curr->next; + if (strcmp(db, (char*)(curr->table()->db())) == 0) + invalidate_table(curr); + /* + invalidate_table can freed block on which point 'next' (if + table of this block used only in queries which was deleted + by invalidate_table). As far as we do not allocate new blocks + and mark all headers of freed blocks as 'FREE' (even if they are + merged with other blocks) we can just test type of block + to be sure that block is not deleted + */ + if (next->type == Query_cache_block::FREE) + goto restart_search; + curr= next; + } while (curr != tables_blocks); + } } STRUCT_UNLOCK(&structure_guard_mutex); } @@ -2218,9 +2238,11 @@ void Query_cache::free_memory_block(Query_cache_block *block) { DBUG_ENTER("Query_cache::free_memory_block"); block->used=0; - DBUG_PRINT("qcache",("first_block 0x%lx, block 0x%lx, pnext 0x%lx pprev 0x%lx", - (ulong) first_block, (ulong) block,block->pnext, - (ulong) block->pprev)); + block->type= Query_cache_block::FREE; // mark block as free in any case + DBUG_PRINT("qcache", + ("first_block 0x%lx, block 0x%lx, pnext 0x%lx pprev 0x%lx", + (ulong) first_block, (ulong) block, (ulong) block->pnext, + (ulong) block->pprev)); if (block->pnext != first_block && block->pnext->is_free()) block = join_free_blocks(block, block->pnext); |