mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
aeaf3fcf12
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
241 lines
6.8 KiB
Perl
Executable file
241 lines
6.8 KiB
Perl
Executable file
#!/usr/bin/perl -w
|
|
|
|
# This is a test with uses 5 processes to insert, update and select from
|
|
# two tables.
|
|
# One inserts records in the tables, one updates some record in it and
|
|
# the last 3 does different selects on the tables.
|
|
# Er, hmmm..., something like that :^)
|
|
# Modified to do crazy-join, à la Nasdaq.
|
|
#
|
|
# This test uses the old obsolete mysql interface. For a test that uses
|
|
# DBI, please take a look at fork_big.pl
|
|
|
|
$opt_loop_count=10000; # Change this to make test harder/easier
|
|
|
|
##################### Standard benchmark inits ##############################
|
|
|
|
use Mysql;
|
|
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_host=""; $opt_db="test";
|
|
|
|
GetOptions("host=s","db=s","loop-count=i","skip-create","skip-in",
|
|
"skip-delete", "verbose","fast-insert","lock-tables","debug","fast",
|
|
"force") || die "Aborted";
|
|
$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$Mysql::db_errstr=$opt_force=undef; # Ignore warnings from these
|
|
|
|
print "Testing 10 multiple connections to a server with 1 insert/update\n";
|
|
print "and 8 select connections and one ALTER TABLE.\n";
|
|
|
|
|
|
@testtables = qw(bench_f21 bench_f22 bench_f23 bench_f24 bench_f25);
|
|
$numtables = $#testtables; # make emacs happier
|
|
$dtable = "directory";
|
|
####
|
|
#### Start timeing and start test
|
|
####
|
|
|
|
$start_time=new Benchmark;
|
|
if (!$opt_skip_create)
|
|
{
|
|
$dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
$Mysql::QUIET = 1;
|
|
foreach $table (@testtables) {
|
|
$dbh->Query("drop table $table");
|
|
}
|
|
$dbh->Query("drop table $dtable");
|
|
$Mysql::QUIET = 0;
|
|
|
|
foreach $table (@testtables) {
|
|
print "Creating table $table in database $opt_db\n";
|
|
$dbh->Query("create table $table".
|
|
" (id int(6) not null,".
|
|
" info varchar(32),".
|
|
" marker timestamp,".
|
|
" primary key(id))")
|
|
or die $Mysql::db_errstr;
|
|
}
|
|
print "Creating directory table $dtable in $opt_db\n";
|
|
$dbh->Query("create table $dtable (id int(6), last int(6))")
|
|
or die $Mysql::db_errstr;
|
|
# Populate directory table
|
|
for $i ( 0 .. $numtables ) {
|
|
$dbh->Query("insert into $dtable values($i, 0)");
|
|
}
|
|
$dbh=0; # Close handler
|
|
}
|
|
$|= 1; # Autoflush
|
|
|
|
####
|
|
#### Start the tests
|
|
####
|
|
|
|
#$test_index = 0;
|
|
|
|
test_1() if (($pid=fork()) == 0); $work{$pid}="insert";
|
|
test_2() if (($pid=fork()) == 0); $work{$pid}="simple1";
|
|
test_3() if (($pid=fork()) == 0); $work{$pid}="funny1";
|
|
test_2() if (($pid=fork()) == 0); $work{$pid}="simple2";
|
|
test_3() if (($pid=fork()) == 0); $work{$pid}="funny2";
|
|
test_2() if (($pid=fork()) == 0); $work{$pid}="simple3";
|
|
test_3() if (($pid=fork()) == 0); $work{$pid}="funny3";
|
|
test_2() if (($pid=fork()) == 0); $work{$pid}="simple4";
|
|
test_3() if (($pid=fork()) == 0); $work{$pid}="funny4";
|
|
alter_test() if (($pid=fork()) == 0); $work{$pid}="alter";
|
|
|
|
$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 = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
foreach $table (@testtables) {
|
|
$dbh->Query("drop table $table");
|
|
}
|
|
}
|
|
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 ?? tables the Nasdaq way
|
|
#
|
|
|
|
sub test_1
|
|
{
|
|
my ($dbh,$table,$tmpvar,$rows,$found,$i);
|
|
|
|
$dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
$tmpvar=1;
|
|
$rows=$found=0;
|
|
for ($i=0 ; $i < $opt_loop_count; $i++)
|
|
{
|
|
$tmpvar^= ((($tmpvar + 63) + $i)*3 % $numtables);
|
|
# Nasdaq step 1:
|
|
$sth=$dbh->Query("select id,last from $dtable where id='$tmpvar'")
|
|
or die "Select directory row: $Mysql::db_errstr\n";
|
|
# Nasdaq step 2:
|
|
my ($did,$dlast) = $sth->FetchRow
|
|
or die "Fetch directory row: $Mysql::db_errstr\n";
|
|
$dlast++;
|
|
$sth=$dbh->Query("INSERT into $testtables[$did]".
|
|
" VALUES($dlast,'This is entry $dlast',NULL)")
|
|
|| die "Got error on insert table $testtable[$did]:".
|
|
" $Mysql::db_errstr\n";
|
|
# Nasdaq step 3 - where my application hangs
|
|
$sth=$dbh->Query("update $dtable set last='$dlast' where id='$tmpvar'")
|
|
or die "Updating directory for table $testtable[$did]:".
|
|
" Mysql::db_errstr\n";
|
|
$rows++;
|
|
}
|
|
$dbh=0;
|
|
print "Test_1: Inserted $rows rows\n";
|
|
exit(0);
|
|
}
|
|
|
|
#
|
|
# Nasdaq simple select
|
|
#
|
|
|
|
sub test_2
|
|
{
|
|
my ($dbh,$id,$tmpvar,$rows,$found,$i);
|
|
|
|
$dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
$rows=$found=0;
|
|
$tmpvar=1;
|
|
for ($i=0 ; $i < $opt_loop_count ; $i++)
|
|
{
|
|
$tmpvar^= ((($tmpvar + 63) + $i)*3 % $numtables);
|
|
$sth=$dbh->Query("select a.id,a.info from $testtables[$tmpvar] as a,".
|
|
"$dtable as d".
|
|
" where a.id=d.last and $i >= 0")
|
|
|| die "Got error select max: $Mysql::db_errstr\n";
|
|
if ((@row = $sth->FetchRow()) && defined($row[0]))
|
|
{
|
|
$found++;
|
|
}
|
|
}
|
|
$dbh=0;
|
|
print "Test_2: Found $found rows\n";
|
|
exit(0);
|
|
}
|
|
|
|
|
|
#
|
|
# Nasdaq not-so-simple select
|
|
#
|
|
|
|
sub test_3
|
|
{
|
|
my ($dbh,$id,$tmpvar,$rows,$i);
|
|
$dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
$rows=0;
|
|
$tmpvar ||= $numtables;
|
|
for ($i=0 ; $i < $opt_loop_count ; $i++)
|
|
{
|
|
$tmpvar^= ((($tmpvar + 63) + $i)*3 % $numtables);
|
|
$id1 = ($tmpvar+1) % $numtables;
|
|
$id2 = ($id1+1) % $numtables;
|
|
$id3 = ($id2+1) % $numtables;
|
|
$sth = $dbh->Query("SELECT greatest(a.id, b.id, c.id), a.info".
|
|
" FROM $testtables[$id1] as a,".
|
|
" $testtables[$id2] as b,".
|
|
" $testtables[$id3] as c,".
|
|
" $dtable as d1, $dtable as d2, $dtable as d3".
|
|
" WHERE ".
|
|
" d1.last=a.id AND d2.last=b.id AND d3.last=c.id".
|
|
" AND d1.id='$id1' AND d2.id='$id2'".
|
|
" AND d3.id='$id3'")
|
|
or die "Funny select: $Mysql::db_errstr\n";
|
|
$rows+=$sth->numrows;
|
|
}
|
|
$dbh=0;
|
|
print "Test_3: Found $rows rows\n";
|
|
exit(0);
|
|
}
|
|
|
|
#
|
|
# Do an ALTER TABLE every 20 seconds
|
|
#
|
|
|
|
sub alter_test
|
|
{
|
|
my ($dbh,$count,$old_row_count,$row_count,$id,@row,$sth);
|
|
|
|
$dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr;
|
|
$id=$count=$row_count=0; $old_row_count= -1;
|
|
|
|
# Execute the test as long as we get more data into the table
|
|
while ($row_count != $old_row_count)
|
|
{
|
|
sleep(10);
|
|
$sth=$dbh->Query("ALTER TABLE $testtables[$id] modify info varchar(32)") or die "Couldn't execute ALTER TABLE\n";
|
|
$sth=0;
|
|
$id=($id+1) % $numtables;
|
|
|
|
# Test if insert test has ended
|
|
$sth=$dbh->query("select count(*) from $testtables[0]") or die "Couldn't execute count(*)\n";
|
|
@row = $sth->FetchRow();
|
|
$old_row_count= $row_count;
|
|
$row_count=$row[0];
|
|
$count++;
|
|
}
|
|
$dbh=0;
|
|
print "alter: Executed $count ALTER TABLE commands\n";
|
|
exit(0);
|
|
}
|