diff options
author | unknown <monty@hundin.mysql.fi> | 2002-06-04 22:59:12 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-06-04 22:59:12 +0300 |
commit | 532c5a78fb7445b1e9f550426b5c38702746b2d3 (patch) | |
tree | 3db4b964ebda2b7b95ab893e1d18b4dacf9415aa | |
parent | ad4e68655565878b31ac67ef1819d9ef29312c51 (diff) | |
download | mariadb-git-532c5a78fb7445b1e9f550426b5c38702746b2d3.tar.gz |
Fixed mutex problem in TRUNCATE TABLE
Docs/manual.texi:
Changelog
sql/mysqld.cc:
Portability fix
-rw-r--r-- | Docs/manual.texi | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 6 | ||||
-rw-r--r-- | sql/sql_delete.cc | 6 | ||||
-rwxr-xr-x | tests/truncate.pl | 125 |
4 files changed, 137 insertions, 3 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index 27799f0f233..336baf14a71 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -49343,6 +49343,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item +Added missing mutex in @code{TRUNCATE TABLE}; This fixes some core +dump/hangup problems when using @code{TRUNCATE TABLE}. +@item Fixed that @code{ALTER TABLE table_name RENAME new_table_name} is as fast as @code{RENAME TABLE}. @item diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1fd68d92a88..9111b090a99 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3472,12 +3472,12 @@ static struct my_option my_long_options[] = {"query_cache_limit", OPT_QUERY_CACHE_LIMIT, "Don't cache results that are bigger than this.", (gptr*) &query_cache_limit, (gptr*) &query_cache_limit, 0, GET_ULONG, - REQUIRED_ARG, 1024*1024L, 0, ULONG_MAX, 0, 1, 0}, + REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0}, #endif /*HAVE_QUERY_CACHE*/ {"query_cache_size", OPT_QUERY_CACHE_SIZE, "The memory allocated to store results from old queries.", (gptr*) &query_cache_size, (gptr*) &query_cache_size, 0, GET_ULONG, - REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0}, + REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1, 0}, #ifdef HAVE_QUERY_CACHE {"query_cache_startup_type", OPT_QUERY_CACHE_STARTUP_TYPE, "0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT SQL_CACHE ... queries.", @@ -3497,7 +3497,7 @@ static struct my_option my_long_options[] = {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, "Undocumented", (gptr*) &relay_log_space_limit, (gptr*) &relay_log_space_limit, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L, - ULONG_MAX, 0, 1, 0}, + (longlong) ULONG_MAX, 0, 1, 0}, {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT, "Number of seconds to wait for more data from a master/slave connection before aborting the read.", (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0, diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c8ed74c9bca..fd8ef4fb123 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -573,9 +573,15 @@ end: } send_ok(&thd->net); // This should return record count } + VOID(pthread_mutex_lock(&LOCK_open)); unlock_table_name(thd, table_list); + VOID(pthread_mutex_unlock(&LOCK_open)); } else if (error) + { + VOID(pthread_mutex_lock(&LOCK_open)); unlock_table_name(thd, table_list); + VOID(pthread_mutex_unlock(&LOCK_open)); + } DBUG_RETURN(error ? -1 : 0); } diff --git a/tests/truncate.pl b/tests/truncate.pl new file mode 100755 index 00000000000..57b50cf96b6 --- /dev/null +++ b/tests/truncate.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w +# +# This is a test with uses many processes to test a MySQL server. +# + +$opt_loop_count=10000; # Change this to make test harder/easier + +##################### Standard benchmark inits ############################## + +use DBI; +use Getopt::Long; +use Benchmark; + +package main; + +$opt_skip_create=$opt_skip_in=$opt_verbose=$opt_fast_insert= +$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=0; +$opt_threads=2; +$opt_host=$opt_user=$opt_password=""; $opt_db="test"; + +GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","skip-in","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","threads=i") || die "Aborted"; +$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these + +print "Testing truncate from $opt_threads multiple connections $opt_loop_count times\n"; + +@testtables = ( ["bench_f31", "type=heap"]); + +#### +#### Start timeing and start test +#### + +$start_time=new Benchmark; +$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; +if (!$opt_skip_create) +{ + my $table_def; + foreach $table_def (@testtables) + { + my ($table,$extra)= ($table_def->[0], $table_def->[1]); + print "Creating table $table in database $opt_db\n"; + $dbh->do("drop table if exists $table"); + $dbh->do("create table $table". + " (id int(6) not null,". + " info varchar(32)," . + " marker timestamp," . + " flag int not null," . + " primary key(id)) $extra") + + or die $DBI::errstr; + } +} + +$dbh->disconnect; $dbh=0; # Close handler +$|= 1; # Autoflush + +#### +#### Start the tests +#### + +for ($i=0 ; $i < $opt_threads ; $i ++) +{ + test_truncate() if (($pid=fork()) == 0); $work{$pid}="truncate"; +} + +print "Started $opt_threads threads\n"; + +$errors=0; +$running_insert_threads=$opt_threads; +while (($pid=wait()) != -1) +{ + $ret=$?/256; + print "thread '" . $work{$pid} . "' finished with exit code $ret\n"; + --$running_insert_threads; + $errors++ if ($ret != 0); +} + +# +# Cleanup +# + +if (!$opt_skip_delete && !$errors) +{ + my $table_def; + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + foreach $table_def (@testtables) + { + $dbh->do("drop table " . $table_def->[0]); + } + $dbh->disconnect; $dbh=0; # Close handler +} + +print ($errors ? "Test failed\n" :"Test ok\n"); +$end_time=new Benchmark; +print "Total time: " . + timestr(timediff($end_time, $start_time),"noc") . "\n"; + +exit(0); + + +# +# Insert records in the table +# + +sub test_truncate +{ + my ($dbh,$i,$j,$count,$table_def,$table); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + for ($count=0; $count < $opt_loop_count ; $count++) + { + my ($table)= ($testtables[0]->[0]); + $dbh->do("truncate table $table") || die "Got error on truncate: $DBI::errstr\n"; + } + $dbh->disconnect; $dbh=0; + print "Test_truncate: Run $count times\n"; + exit(0); +} |