Commit c0422729 authored by unknown's avatar unknown
Browse files

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

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


sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
parents 21918cf7 d4f43e51
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -687,4 +687,21 @@ select * from t3;
delete from t4 where a=1;
flush query cache;
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;
+16 −1
Original line number Diff line number Diff line
@@ -504,6 +504,21 @@ select * from t3;
enable_result_log;
delete from t4 where a=1;
flush query cache;

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;
+7 −2
Original line number Diff line number Diff line
@@ -3229,7 +3229,7 @@ enum options_mysqld {
  OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
  OPT_OPEN_FILES_LIMIT, 
  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_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
  OPT_READONLY, OPT_DEBUGGING,
@@ -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*) &max_system_variables.query_cache_type,
   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,
   "Persistent buffer for query parsing and execution",
   (gptr*) &global_system_variables.query_prealloc_size,
   (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
   REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
#endif /*HAVE_QUERY_CACHE*/
  {"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.",
   (gptr*) &global_system_variables.read_buff_size,
+4 −0
Original line number Diff line number Diff line
@@ -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",
					     &SV::query_cache_type,
					     &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 */
sys_var_long_ptr	sys_server_id("server_id",&server_id);
sys_var_bool_ptr	sys_slave_compressed_protocol("slave_compressed_protocol",
@@ -408,6 +411,7 @@ sys_var *sys_variables[]=
#ifdef HAVE_QUERY_CACHE
  &sys_query_cache_limit,
  &sys_query_cache_type,
  &sys_query_cache_wlock_invalidate,
#endif /* HAVE_QUERY_CACHE */
  &sys_quote_show_create,
  &sys_rand_seed1,
+31 −0
Original line number Diff line number Diff line
@@ -1090,6 +1090,37 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
  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
*/
Loading