# Copyright (C) 2000, 2001 MySQL AB # Use is subject to license terms # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
# # 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 ##############################
# # Insert records in the table. Delete table when test is finished #
sub test_insert
{
my ($dbh,$i,$error);
$dbh = DBI->connect("DBI:MariaDB:$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:MariaDB:$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);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.