############################################################################ # Stress test for MySQL/Innobase combined database # (c) 2000 Innobase Oy & MySQL AB # ############################################################################ use DBI; use Benchmark; $opt_loop_count = 1000; $opt_loop_count2 = 50; chomp($pwd = `pwd`); $pwd = "." if ($pwd eq ''); require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n"; print "Generating random keys\n"; $random[$opt_loop_count] = 0; $rnd_str[$opt_loop_count] = "a"; for ($i = 0; $i < $opt_loop_count; $i++) { $random[$i] = ($i * 63857) % $opt_loop_count; if ($i < 10) { if (0 == ($random[$i] % 3)) { $rnd_str[$i] = "kjgclgrtfuylfluyfyufyulfulfyyulofuyolfyufyufuyfyufyufyufyufyyufujhfghd"; } else { if (1 == ($random[$i] % 3)) { $rnd_str[$i] = "khd"; } else { if (2 == ($random[$i] % 3)) { $rnd_str[$i] = "kh"; }}} for ($j = 0; $j < (($i * 764877) % 50000); $j++) { $rnd_str[$i] = $rnd_str[$i]."k"; } } } #### #### Connect #### print length($rnd_str[5])."\n"; print length($rnd_str[6])."\n"; print length($rnd_str[7])."\n"; $dbh = $server->connect(); $dbh->do("set autocommit = 1"); $dbh->do("drop table blobt3"); $dbh->do( "create table blobt3 (A INT NOT NULL, D INT NOT NULL, B BLOB NOT NULL, C TEXT, PRIMARY KEY (B(10), A, D), INDEX (D), INDEX(A), INDEX (C(255), B(255)), INDEX (B(5), C(10), A)) TYPE = INNODB"); $dbh->{LongReadLen}= 1000000; # Set retrieval buffer for ($i = 0; $i < 1; $i++) { $k = 0; print "loop $i\n"; for ($t = 0; $t < 100; $t++) { for ($j = 1; $j < $opt_loop_count - 10; $j = $j + 1) { if ($dbh->do( "insert into blobt3 values (".$random[$j].", 5,'".$rnd_str[($j % 10)]."' ,'".$rnd_str[($j % 10)]."')")) { $sth = $dbh->prepare("select * from blobt3 where a = ".$random[$j]) or die "Cannot prepare\n"; if (!$sth->execute || !(@row = $sth->fetchrow_array)) { print "$DBI::errstr - ".length($row[2])."ins select **\n"; } if ($row[2] != $rnd_str[($j % 10)]) { print "Error in insert of B\n"; } if (length($row[2]) != length($rnd_str[($j % 10)])) { print "Error in insert of B\n"; } if ($row[3] != $rnd_str[($j % 10)]) { print "Error in insert of C\n"; } $sth->finish; } else { print $dbh->errstr; } $dbh->do( "insert into blobt3 values (".$random[$j].", 6,'".$rnd_str[($j % 10)]."' ,'".$rnd_str[($j % 10)]."')"); if ($dbh->do("update blobt3 set B = '".$rnd_str[($j + 1) % 10]."' where A =".$random[$j])) { $sth = $dbh->prepare("select * from blobt3 where a = ".$random[$j]); if (!$sth->execute || !(@row = $sth->fetchrow_array)) { print "$DBI::errstr - ".length($row[2])." err upd **\n"; } if ($row[2] != $rnd_str[(($j + 1) % 10)]) { print "Error in update of B\n"; } $sth->finish; } else { print $dbh->errstr; } $s = fetch_all_rows($dbh, "select tab1.a, tab1.b, tab1.c, tab1.d, tab2.a, tab2.b, tab2.c, tab2.d from blobt3 tab1 LEFT JOIN blobt3 tab2 ON tab1.a = tab2.a where tab1.a = ".$random[$j]." group by tab1.a order by tab2.c desc limit 0, 3" ); $s = fetch_all_rows($dbh, "select * from blobt3 where b like 'khdkkk%'"); $s = fetch_all_rows($dbh, "select * from blobt3 where c like 'khdkkk%'"); $s = fetch_all_rows($dbh, "select * from blobt3 where b like 'khdkkkkkkkkkkkkkkkkkkkkkkkk%'"); $s = fetch_all_rows($dbh, "select * from blobt3 where c like 'khd%'"); $dbh->do("delete from blobt3 where A = ".$random[$random[$j]]) or print $dbh->errstr; if (0 == ($j % 21)) { print "rollback $j\n"; $dbh->do("rollback") or print $dbh->errstr; } if (0 == ($j % 5)) { print "commit $j\n"; $dbh->do("commit") or print $dbh->errstr; } if (0 == ($j % 171)) { $dbh->do("check table blobt3"); print "table checked\n"; } if (0 == ($j % 100)) { $s = fetch_all_rows($dbh, "select * from blobt3"); } } } $dbh->do("commit"); } $dbh->disconnect; # close connection