Commit 4c78e463 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.0

into sanja.is.com.ua:/home/bell/mysql/bk/work-4.0
parents 34a332c0 d03034d3
...@@ -687,4 +687,21 @@ select * from t3; ...@@ -687,4 +687,21 @@ select * from t3;
delete from t4 where a=1; delete from t4 where a=1;
flush query cache; flush query cache;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
set query_cache_wlock_invalidate=1;
create table t1 (a int not null);
create table t2 (a int not null);
select * from t1;
a
select * from t2;
a
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
lock table t1 write, t2 read;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
unlock table;
drop table t1,t2;
set query_cache_wlock_invalidate=default;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -504,6 +504,21 @@ select * from t3; ...@@ -504,6 +504,21 @@ select * from t3;
enable_result_log; enable_result_log;
delete from t4 where a=1; delete from t4 where a=1;
flush query cache; flush query cache;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
#
# WRITE LOCK & QC
#
set query_cache_wlock_invalidate=1;
create table t1 (a int not null);
create table t2 (a int not null);
select * from t1;
select * from t2;
show status like "Qcache_queries_in_cache";
lock table t1 write, t2 read;
show status like "Qcache_queries_in_cache";
unlock table;
drop table t1,t2;
set query_cache_wlock_invalidate=default;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -3229,7 +3229,7 @@ enum options_mysqld { ...@@ -3229,7 +3229,7 @@ enum options_mysqld {
OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT, OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
OPT_OPEN_FILES_LIMIT, OPT_OPEN_FILES_LIMIT,
OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE, OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE,
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER, OPT_QUERY_CACHE_TYPE, OPT_QUERY_CACHE_WLOCK_INVALIDATE, OPT_RECORD_BUFFER,
OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT, OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT,
OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME, OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
OPT_READONLY, OPT_DEBUGGING, OPT_READONLY, OPT_DEBUGGING,
...@@ -4017,12 +4017,17 @@ this value; if zero (the default): when the size exceeds max_binlog_size. \ ...@@ -4017,12 +4017,17 @@ this value; if zero (the default): when the size exceeds max_binlog_size. \
(gptr*) &global_system_variables.query_cache_type, (gptr*) &global_system_variables.query_cache_type,
(gptr*) &max_system_variables.query_cache_type, (gptr*) &max_system_variables.query_cache_type,
0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0},
{"query_cache_wlock_invalidate", OPT_QUERY_CACHE_WLOCK_INVALIDATE,
"Invalidate queries in query cache on LOCK for write",
(gptr*) &global_system_variables.query_cache_wlock_invalidate,
(gptr*) &max_system_variables.query_cache_wlock_invalidate,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
#endif /*HAVE_QUERY_CACHE*/
{"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE, {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
"Persistent buffer for query parsing and execution", "Persistent buffer for query parsing and execution",
(gptr*) &global_system_variables.query_prealloc_size, (gptr*) &global_system_variables.query_prealloc_size,
(gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
#endif /*HAVE_QUERY_CACHE*/
{"read_buffer_size", OPT_RECORD_BUFFER, {"read_buffer_size", OPT_RECORD_BUFFER,
"Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.", "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
(gptr*) &global_system_variables.read_buff_size, (gptr*) &global_system_variables.read_buff_size,
......
...@@ -231,6 +231,9 @@ sys_var_long_ptr sys_query_cache_limit("query_cache_limit", ...@@ -231,6 +231,9 @@ sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
sys_var_thd_enum sys_query_cache_type("query_cache_type", sys_var_thd_enum sys_query_cache_type("query_cache_type",
&SV::query_cache_type, &SV::query_cache_type,
&query_cache_type_typelib); &query_cache_type_typelib);
sys_var_thd_bool
sys_query_cache_wlock_invalidate("query_cache_wlock_invalidate",
&SV::query_cache_wlock_invalidate);
#endif /* HAVE_QUERY_CACHE */ #endif /* HAVE_QUERY_CACHE */
sys_var_long_ptr sys_server_id("server_id",&server_id); sys_var_long_ptr sys_server_id("server_id",&server_id);
sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol", sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
...@@ -408,6 +411,7 @@ sys_var *sys_variables[]= ...@@ -408,6 +411,7 @@ sys_var *sys_variables[]=
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
&sys_query_cache_limit, &sys_query_cache_limit,
&sys_query_cache_type, &sys_query_cache_type,
&sys_query_cache_wlock_invalidate,
#endif /* HAVE_QUERY_CACHE */ #endif /* HAVE_QUERY_CACHE */
&sys_quote_show_create, &sys_quote_show_create,
&sys_rand_seed1, &sys_rand_seed1,
......
...@@ -1090,6 +1090,37 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used) ...@@ -1090,6 +1090,37 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
Invalidate locked for write
SYNOPSIS
Query_cache::invalidate_locked_for_write()
tables_used - table list
NOTE
can be used only for opened tables
*/
void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used)
{
DBUG_ENTER("Query_cache::invalidate (changed table list)");
if (query_cache_size > 0 && tables_used)
{
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size > 0)
{
DUMP(this);
for (; tables_used; tables_used= tables_used->next)
{
if (tables_used->lock_type & (TL_WRITE_LOW_PRIORITY | TL_WRITE))
invalidate_table(tables_used->table);
}
}
STRUCT_UNLOCK(&structure_guard_mutex);
}
DBUG_VOID_RETURN;
}
/* /*
Remove all cached queries that uses the given table Remove all cached queries that uses the given table
*/ */
......
...@@ -360,6 +360,7 @@ protected: ...@@ -360,6 +360,7 @@ protected:
void invalidate(THD* thd, TABLE_LIST *tables_used, void invalidate(THD* thd, TABLE_LIST *tables_used,
my_bool using_transactions); my_bool using_transactions);
void invalidate(CHANGED_TABLE_LIST *tables_used); void invalidate(CHANGED_TABLE_LIST *tables_used);
void invalidate_locked_for_write(TABLE_LIST *tables_used);
void invalidate(THD* thd, TABLE *table, my_bool using_transactions); void invalidate(THD* thd, TABLE *table, my_bool using_transactions);
void invalidate(THD *thd, const char *key, uint32 key_length, void invalidate(THD *thd, const char *key, uint32 key_length,
my_bool using_transactions); my_bool using_transactions);
......
...@@ -337,6 +337,7 @@ struct system_variables ...@@ -337,6 +337,7 @@ struct system_variables
my_bool log_warnings; my_bool log_warnings;
my_bool low_priority_updates; my_bool low_priority_updates;
my_bool new_mode; my_bool new_mode;
my_bool query_cache_wlock_invalidate;
CONVERT *convert_set; CONVERT *convert_set;
}; };
......
...@@ -2307,8 +2307,12 @@ mysql_execute_command(void) ...@@ -2307,8 +2307,12 @@ mysql_execute_command(void)
goto error; goto error;
thd->in_lock_tables=1; thd->in_lock_tables=1;
thd->options|= OPTION_TABLE_LOCK; thd->options|= OPTION_TABLE_LOCK;
if (!(res=open_and_lock_tables(thd,tables))) if (!(res= open_and_lock_tables(thd, tables)))
{ {
#ifdef HAVE_QUERY_CACHE
if (thd->variables.query_cache_wlock_invalidate)
query_cache.invalidate_locked_for_write(tables);
#endif /*HAVE_QUERY_CACHE*/
thd->locked_tables=thd->lock; thd->locked_tables=thd->lock;
thd->lock=0; thd->lock=0;
send_ok(&thd->net); send_ok(&thd->net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment