Commit 73780de1 authored by monty@mysql.com's avatar monty@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-4.0

into mysql.com:/home/my/mysql-4.0
parents ef971bb6 4c78e463
......@@ -46,6 +46,7 @@ jani@rhols221.adsl.netsonic.fi
jani@rhols221.arenanet.fi
jani@ua126d19.elisa.omakaista.fi
jani@ua141d10.elisa.omakaista.fi
jani@ua72d24.elisa.omakaista.fi
jcole@abel.spaceapes.com
jcole@main.burghcom.com
jcole@mugatu.spaceapes.com
......
......@@ -480,7 +480,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
......@@ -562,9 +562,12 @@ static int parse_args(int *argc, char*** argv)
static MYSQL* safe_connect()
{
MYSQL *local_mysql = mysql_init(NULL);
if(!local_mysql)
die("Failed on mysql_init");
mysql_options(local_mysql, MYSQL_INIT_COMMAND,
"/*!32210 SET @@session.max_insert_delayed_threads=0*/");
if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0))
die("failed on connect: %s", mysql_error(local_mysql));
......
......@@ -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;
......@@ -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;
......@@ -37,7 +37,7 @@ WARNING: THIS PROGRAM IS STILL IN BETA. Comments/patches welcome.
# Documentation continued at end of file
my $VERSION = "1.20";
my $VERSION = "1.21";
my $opt_tmpdir = $ENV{TMPDIR} || "/tmp";
......@@ -73,6 +73,7 @@ Usage: $0 db_name[./table_regex/] [new_db_name | directory]
--resetslave reset the master.info once all tables are locked
--tmpdir=# temporary directory (instead of $opt_tmpdir)
--record_log_pos=# record slave and master status in specified db.table
--chroot=# base directory of chroot jail in which mysqld operates
Try \'perldoc $0 for more complete documentation\'
_OPTIONS
......@@ -117,6 +118,7 @@ GetOptions( \%opt,
"resetslave",
"tmpdir|t=s",
"dryrun|n",
"chroot=s",
) or usage("Invalid option");
# @db_desc
......@@ -210,6 +212,7 @@ while ( my ($var,$value) = $sth_vars->fetchrow_array ) {
}
my $datadir = $mysqld_vars{'datadir'}
|| die "datadir not in mysqld variables";
$datadir= $opt{chroot}.$datadir if ($opt{chroot});
$datadir =~ s:/$::;
......
......@@ -688,7 +688,7 @@ extern ulong ha_read_first_count, ha_read_last_count;
extern ulong ha_read_rnd_count, ha_read_rnd_next_count;
extern ulong ha_commit_count, ha_rollback_count,table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong max_insert_delayed_threads, max_user_connections;
extern ulong max_user_connections;
extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode;
extern ulong query_buff_size, thread_stack,thread_stack_min;
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
......
......@@ -401,7 +401,7 @@ ulong select_range_check_count, select_range_count, select_scan_count;
ulong select_full_range_join_count,select_full_join_count;
ulong specialflag=0,opened_tables=0,created_tmp_tables=0,
created_tmp_disk_tables=0;
ulong max_connections,max_insert_delayed_threads,max_used_connections,
ulong max_connections, max_used_connections,
max_connect_errors, max_user_connections = 0;
ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0;
......@@ -1728,7 +1728,8 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
This should actually be '+ max_number_of_slaves' instead of +10,
but the +10 should be quite safe.
*/
init_thr_alarm(max_connections+max_insert_delayed_threads+10);
init_thr_alarm(max_connections +
global_system_variables.max_insert_delayed_threads + 10);
#if SIGINT != THR_KILL_SIGNAL
if (test_flags & TEST_SIGINT)
{
......@@ -3243,7 +3244,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,
......@@ -3911,7 +3912,8 @@ The minimum value for this variable is 4096.",
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
{"max_delayed_threads", OPT_MAX_DELAYED_THREADS,
"Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.",
(gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads,
(gptr*) &global_system_variables.max_insert_delayed_threads,
(gptr*) &max_system_variables.max_insert_delayed_threads,
0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0},
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
"Don't allow creation of heap tables bigger than this.",
......@@ -4030,12 +4032,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,
......
......@@ -155,8 +155,10 @@ sys_var_long_ptr sys_max_connections("max_connections",
fix_max_connections);
sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
&max_connect_errors);
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads",
&max_insert_delayed_threads,
sys_var_thd_ulong sys_max_insert_delayed_threads("max_insert_delayed_threads",
&SV::max_insert_delayed_threads);
sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads",
&SV::max_insert_delayed_threads,
fix_max_connections);
sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size",
&SV::max_heap_table_size);
......@@ -229,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",
......@@ -389,6 +394,7 @@ sys_var *sys_variables[]=
&sys_max_connect_errors,
&sys_max_connections,
&sys_max_delayed_threads,
&sys_max_insert_delayed_threads,
&sys_max_heap_table_size,
&sys_max_join_size,
&sys_max_relay_log_size,
......@@ -413,6 +419,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,
......@@ -782,7 +789,8 @@ static void fix_max_relay_log_size(THD *thd, enum_var_type type)
static void fix_max_connections(THD *thd, enum_var_type type)
{
resize_thr_alarm(max_connections + max_insert_delayed_threads + 10);
resize_thr_alarm(max_connections +
global_system_variables.max_insert_delayed_threads + 10);
}
......
......@@ -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
*/
......
......@@ -360,6 +360,7 @@ class Query_cache
void invalidate(THD* thd, TABLE_LIST *tables_used,
my_bool using_transactions);
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, const char *key, uint32 key_length,
my_bool using_transactions);
......
......@@ -310,6 +310,7 @@ struct system_variables
ulong max_heap_table_size;
ulong max_sort_length;
ulong max_tmp_tables;
ulong max_insert_delayed_threads;
ulong myisam_repair_threads;
ulong myisam_sort_buff_size;
ulong net_buffer_length;
......@@ -336,6 +337,7 @@ struct system_variables
my_bool log_warnings;
my_bool low_priority_updates;
my_bool new_mode;
my_bool query_cache_wlock_invalidate;
CONVERT *convert_set;
};
......
......@@ -139,7 +139,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
*/
if ((lock_type == TL_WRITE_DELAYED &&
((specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) ||
thd->slave_thread || !max_insert_delayed_threads)) ||
thd->slave_thread || !thd->variables.max_insert_delayed_threads)) ||
(lock_type == TL_WRITE_CONCURRENT_INSERT && duplic == DUP_REPLACE))
lock_type=TL_WRITE;
......@@ -655,7 +655,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
if (!(tmp=find_handler(thd,table_list)))
{
/* Don't create more than max_insert_delayed_threads */
if (delayed_insert_threads >= max_insert_delayed_threads)
if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
DBUG_RETURN(0);
thd->proc_info="Creating delayed handler";
pthread_mutex_lock(&LOCK_delayed_create);
......
......@@ -2307,8 +2307,12 @@ mysql_execute_command(void)
goto error;
thd->in_lock_tables=1;
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->lock=0;
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