summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 5ba32e0bbd7..c1ccd35d5c1 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -3300,7 +3300,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
if (!insert_table(key_length, key, (*block_table),
tables_used->view_db.length,
HA_CACHE_TBL_NONTRANSACT, 0, 0, TRUE))
+ {
+ // Mark failed
+ (*block_table)->next= (*block_table)->prev= NULL;
+ (*block_table)->parent= NULL;
DBUG_RETURN(0);
+ }
/*
We do not need to register view tables here because they are already
present in the global list.
@@ -3324,11 +3329,21 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
tables_used->callback_func,
tables_used->engine_data,
TRUE))
+ {
+ // Mark failed
+ (*block_table)->next= (*block_table)->prev= NULL;
+ (*block_table)->parent= NULL;
DBUG_RETURN(0);
+ }
if (tables_used->table->file->
register_query_cache_dependant_tables(thd, this, block_table, &n))
+ {
+ // Mark failed
+ (*block_table)->next= (*block_table)->prev= NULL;
+ (*block_table)->parent= NULL;
DBUG_RETURN(0);
+ }
}
}
DBUG_RETURN(n - counter);
@@ -3365,9 +3380,12 @@ my_bool Query_cache::register_all_tables(THD *thd,
for (Query_cache_block_table *tmp = block->table(0) ;
tmp != block_table;
tmp++)
- unlink_table(tmp);
- if (block_table->parent)
- unlink_table(block_table);
+ {
+ if (tmp->prev) // not marked as failed and unuseable
+ unlink_table(tmp);
+ else
+ break;
+ }
}
return test(n);
}