mariadb/tests/rename_test.pl
unknown aeaf3fcf12 Don't do signal() on windows (Causes instability problems)
Safer, a bit faster filesort.
Code changes to avoid calls to current_thd() (faster code).
Removed all compiler warnings from readline.


BitKeeper/etc/ignore:
  Add my_global.h back.
Docs/manual.texi:
  4.0.1 Changelog
include/my_sys.h:
  Added strmake_root
libmysql/libmysql.c:
  Don't do signal() on windows (Causes instability problems)
mysys/my_alloc.c:
  Added strmake_root
readline/bind.c:
  Remove warnings
readline/complete.c:
  Remove warnings
readline/display.c:
  Remove warnings
readline/funmap.c:
  Remove warnings
readline/histexpand.c:
  Remove warnings
readline/histfile.c:
  Remove warnings
readline/history.h:
  Remove warnings
readline/histsearch.c:
  Remove warnings
readline/isearch.c:
  Remove warnings
readline/kill.c:
  Remove warnings
readline/macro.c:
  Remove warnings
readline/readline.c:
  Remove warnings
readline/readline.h:
  Remove warnings
readline/rltty.c:
  Remove warnings
readline/search.c:
  Remove warnings
readline/shell.c:
  Remove warnings
readline/terminal.c:
  Remove warnings
readline/tilde.c:
  Remove warnings
readline/tilde.h:
  Remove warnings
readline/undo.c:
  Remove warnings
readline/util.c:
  Remove warnings
readline/vi_mode.c:
  Remove warnings
sql-bench/server-cfg.sh:
  Added use of truncate table
sql-bench/test-insert.sh:
  Added use of truncate table
  Changed some tests to use keys instead of 'range'
sql-bench/test-wisconsin.sh:
  Cleanup
sql/field.cc:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/field.h:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/filesort.cc:
  Safer memory allocation;  Don't allocate pointer to buffers directly, but use an IO_CACHE instead.
  This will allow us to use more memory for keys and will also work better if the number of rows that is to be sorted is much larger than expected.
sql/item.cc:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/item.h:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/item_func.h:
  Cleanup
sql/opt_range.cc:
  Use mem_root instead of sql_alloc() to get more speed
sql/sql_class.cc:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/sql_class.h:
  Added strmake()
sql/sql_handler.cc:
  Add 'thd' to send() (To avoid usage of 'current_thd')
sql/sql_lex.cc:
  Use mem_root instead of sql_alloc() to get more speed
sql/sql_select.cc:
  Add 'thd' to send() (To avoid usage of 'current_thd')
tests/fork2_test.pl:
  Fixed typos
tests/fork_big.pl:
  Fixed typos
tests/insert_and_repair.pl:
  Fixed typos
tests/rename_test.pl:
  Fixed typos
tests/test_delayed_insert.pl:
  Fixed typos
2001-10-17 19:39:39 +03:00

204 lines
5.3 KiB
Perl
Executable file

#!/usr/bin/perl -w
#
# This is a test with uses processes to insert, select and drop tables.
#
$opt_loop_count=100000; # Change this to make test harder/easier
##################### Standard benchmark inits ##############################
use DBI;
use Getopt::Long;
use Benchmark;
package main;
$opt_skip_create=$opt_skip_delete=$opt_skip_flush=0;
$opt_host=""; $opt_db="test";
GetOptions("host=s","db=s","loop-count=i","skip-create","skip-delete",
"skip-flush") || die "Aborted";
print "Testing 5 multiple connections to a server with 1 insert, 1 rename\n";
print "1 select and 1 flush thread\n";
$firsttable = "bench_f1";
####
#### Start timing and start test
####
$start_time=new Benchmark;
if (!$opt_skip_create)
{
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
$dbh->do("drop table if exists $firsttable, ${firsttable}_1, ${firsttable}_2");
print "Creating table $firsttable in database $opt_db\n";
$dbh->do("create table $firsttable (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr;
$dbh->disconnect; $dbh=0; # Close handler
}
$|= 1; # Autoflush
####
#### Start the tests
####
test_insert() if (($pid=fork()) == 0); $work{$pid}="insert";
test_rename(1) if (($pid=fork()) == 0); $work{$pid}="rename 1";
test_rename(2) if (($pid=fork()) == 0); $work{$pid}="rename 2";
test_select() if (($pid=fork()) == 0); $work{$pid}="select";
if (!$opt_skip_flush)
{
test_flush() if (($pid=fork()) == 0); $work{$pid}="flush";
}
$errors=0;
while (($pid=wait()) != -1)
{
$ret=$?/256;
print "thread '" . $work{$pid} . "' finished with exit code $ret\n";
$errors++ if ($ret != 0);
}
if (!$opt_skip_delete && !$errors)
{
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
$dbh->do("drop table $firsttable");
$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. Delete table when test is finished
#
sub test_insert
{
my ($dbh,$i,$error);
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
for ($i=0 ; $i < $opt_loop_count; $i++)
{
if (!$dbh->do("insert into $firsttable values ($i,'This is entry $i','')"))
{
$error=$dbh->errstr;
$dbh->do("drop table ${firsttable}"); # End other threads
die "Warning; Got error on insert: " . $error . "\n";
}
}
sleep(1);
$dbh->do("drop table ${firsttable}") || die "Got error on drop table: " . $dbh->errstr . "\n";
$dbh->disconnect; $dbh=0;
print "Test_insert: Inserted $i rows\n";
exit(0);
}
sub test_rename
{
my ($id) = @_;
my ($dbh,$i,$error_counter,$sleep_time);
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
$error_counter=0;
$sleep_time=2;
for ($i=0 ; $i < $opt_loop_count ; $i++)
{
sleep($sleep_time);
$dbh->do("create table ${firsttable}_$id (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr;
if (!$dbh->do("rename table $firsttable to ${firsttable}_${id}_1, ${firsttable}_$id to ${firsttable}"))
{
last if ($dbh->errstr =~ /^Can\'t find/);
die "Got error on rename: " . $dbh->errstr . "\n";
}
$dbh->do("drop table ${firsttable}_${id}_1") || die "Got error on drop table: " . $dbh->errstr . "\n";
}
$dbh->disconnect; $dbh=0;
print "Test_drop: Did a drop $i times\n";
exit(0);
}
#
# select records
#
sub test_select
{
my ($dbh,$i,$sth,@row,$sleep_time);
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
$sleep_time=3;
for ($i=0 ; $i < $opt_loop_count ; $i++)
{
sleep($sleep_time);
$sth=$dbh->prepare("select sum(t.id) from $firsttable as t,$firsttable as t2") || die "Got error on select: $dbh->errstr;\n";
if ($sth->execute)
{
@row = $sth->fetchrow_array();
$sth->finish;
}
else
{
$sth->finish;
last if (! ($dbh->errstr =~ /doesn\'t exist/));
die "Got error on select: " . $dbh->errstr . "\n";
}
}
$dbh->disconnect; $dbh=0;
print "Test_select: ok\n";
exit(0);
}
#
# flush records
#
sub test_flush
{
my ($dbh,$i,$sth,@row,$error_counter,$sleep_time);
$dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
$opt_user, $opt_password,
{ PrintError => 0}) || die $DBI::errstr;
$error_counter=0;
$sleep_time=5;
for ($i=0 ; $i < $opt_loop_count ; $i++)
{
sleep($sleep_time);
$sth=$dbh->prepare("select count(*) from $firsttable") || die "Got error on prepar: $dbh->errstr;\n";
if ($sth->execute)
{
@row = $sth->fetchrow_array();
$sth->finish;
$sleep_time=5;
$dbh->do("flush tables $firsttable") || die "Got error on flush table: " . $dbh->errstr . "\n";
}
else
{
last if (! ($dbh->errstr =~ /doesn\'t exist/));
die "Got error on flush: " . $dbh->errstr . "\n";
}
}
$dbh->disconnect; $dbh=0;
print "Test_select: ok\n";
exit(0);
}